From 934941294b27b3e9a9012be1abe86f4e05db2204 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sat, 25 Jun 2005 00:28:09 +0000 Subject: Core functions taking advantage of the new, optimised lcd_hline() and lcd_vline() functions. Some cleanup. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6859 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 6 +++--- apps/recorder/keyboard.c | 4 ++-- apps/recorder/peakmeter.c | 19 ++++++++----------- apps/screens.c | 4 ++-- firmware/drivers/lcd-h100.c | 9 ++++----- firmware/drivers/lcd-recorder.c | 9 ++++----- firmware/export/lcd.h | 4 ---- uisimulator/battery.c | 14 ++++++-------- 8 files changed, 29 insertions(+), 40 deletions(-) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index a1097ba925..805c8db2ba 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -1143,10 +1143,10 @@ bool view_battery(void) for (i = BAT_LAST_VAL - 1; i >= 0; i--) { y = (power_history[i] - minv) * BAT_YSPACE / (maxv - minv); lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); - lcd_drawline(x, LCD_HEIGHT-1, x, 20); + lcd_vline(x, LCD_HEIGHT-1, 20); lcd_set_drawmode(DRMODE_SOLID); - lcd_drawline(x, LCD_HEIGHT-1, x, - MIN(MAX(LCD_HEIGHT-1 - y, 20), LCD_HEIGHT-1)); + lcd_vline(x, LCD_HEIGHT-1, + MIN(MAX(LCD_HEIGHT-1 - y, 20), LCD_HEIGHT-1)); x++; } diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index cfaf03c94a..bbca117bdb 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c @@ -167,7 +167,7 @@ int kbd_input(char* text, int buflen) lcd_putsxy(0, 8+i * font_h, line[i]); /* separator */ - lcd_drawline(0, main_y - margin, LCD_WIDTH - 1, main_y - margin); + lcd_hline(0, LCD_WIDTH - 1, main_y - margin); /* write out the text */ curpos = MIN(editpos, max_chars - MIN(len - editpos, 2)); @@ -184,7 +184,7 @@ int kbd_input(char* text, int buflen) /* cursor */ i = (curpos + 1) * font_w; - lcd_drawline(i, main_y, i, main_y + font_h); + lcd_vline(i, main_y, main_y + font_h); #if CONFIG_KEYPAD == RECORDER_PAD /* draw the status bar */ diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c index 8fffc9500d..779200cb85 100644 --- a/apps/recorder/peakmeter.c +++ b/apps/recorder/peakmeter.c @@ -938,8 +938,7 @@ void peak_meter_draw(int x, int y, int width, int height) /* draw left */ lcd_fillrect (x, y, left, height / 2 - 2 ); if (peak_meter_max_l > 0) { - lcd_drawline(x + peak_meter_max_l, y, - x + peak_meter_max_l, y + height / 2 - 2 ); + lcd_vline(x + peak_meter_max_l, y, y + height / 2 - 2 ); } if (peak_meter_l_clip) { lcd_fillrect(x + meterwidth, y, 3, height / 2 - 1); @@ -948,17 +947,15 @@ void peak_meter_draw(int x, int y, int width, int height) /* draw right */ lcd_fillrect(x, y + height / 2 + 1, right, height / 2 - 2); if (peak_meter_max_r > 0) { - lcd_drawline( x + peak_meter_max_r, y + height / 2, - x + peak_meter_max_r, y + height - 2); + lcd_vline( x + peak_meter_max_r, y + height / 2, y + height - 2); } if (peak_meter_r_clip) { lcd_fillrect(x + meterwidth, y + height / 2, 3, height / 2 - 1); } /* draw scale end */ - lcd_drawline(x + meterwidth, y, - x + meterwidth, y + height - 2); - + lcd_vline(x + meterwidth, y, y + height - 2); + lcd_set_drawmode(DRMODE_COMPLEMENT); /* draw dots for scale marks */ for (i = 0; i < db_scale_count; i++) { @@ -976,12 +973,12 @@ void peak_meter_draw(int x, int y, int width, int height) ycenter = y + height / 2; /* display threshold value */ start_trigx = x+peak_meter_scale_value(trig_strt_threshold,meterwidth); - lcd_drawline(start_trigx, ycenter - 2, start_trigx, ycenter); + lcd_vline(start_trigx, ycenter - 2, ycenter); start_trigx ++; if (start_trigx < LCD_WIDTH) lcd_drawpixel(start_trigx, ycenter - 1); stop_trigx = x + peak_meter_scale_value(trig_stp_threshold,meterwidth); - lcd_drawline(stop_trigx, ycenter - 2, stop_trigx, ycenter); + lcd_vline(stop_trigx, ycenter - 2, ycenter); if (stop_trigx > 0) lcd_drawpixel(stop_trigx - 1, ycenter - 1); } #endif @@ -1196,7 +1193,7 @@ bool peak_meter_histogram(void) { for (i = 0; i < PEEKS_PER_DRAW_SIZE; i++) { x = peeks_per_redraw[i] * (LCD_WIDTH - 1)/ max; - lcd_drawline(0, y + i, x, y + i); + lcd_hline(0, x, y + i); } y = PEEKS_PER_DRAW_SIZE + 1; @@ -1208,7 +1205,7 @@ bool peak_meter_histogram(void) { for (i = 0; i < TICKS_PER_DRAW_SIZE; i++) { x = ticks_per_redraw[i] * (LCD_WIDTH - 1)/ max; - lcd_drawline(0, y + i, x, y + i); + lcd_hline(0, x, y + i); } lcd_update(); diff --git a/apps/screens.c b/apps/screens.c index c35d20c37e..1ae7030822 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -854,8 +854,8 @@ void splash(int ticks, /* how long the splash is displayed */ lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); lcd_fillrect(0, y-2, LCD_WIDTH, LCD_HEIGHT-y*2+4); lcd_set_drawmode(DRMODE_SOLID); - lcd_drawline(0, y-2, LCD_WIDTH-1, y-2); - lcd_drawline(0, LCD_HEIGHT-y+2, LCD_WIDTH-1, LCD_HEIGHT-y+2); + lcd_hline(0, LCD_WIDTH-1, y-2); + lcd_hline(0, LCD_WIDTH-1, LCD_HEIGHT-y+2); } } else diff --git a/firmware/drivers/lcd-h100.c b/firmware/drivers/lcd-h100.c index db2aba8673..666949ff72 100644 --- a/firmware/drivers/lcd-h100.c +++ b/firmware/drivers/lcd-h100.c @@ -332,7 +332,7 @@ static void nopixel(int x, int y) } lcd_pixelfunc_type* pixelfunc[8] = {flippixel, nopixel, setpixel, setpixel, - nopixel, clearpixel, nopixel, clearpixel}; + nopixel, clearpixel, nopixel, clearpixel}; static void flipblock(unsigned char *address, unsigned mask, unsigned bits) { @@ -361,10 +361,9 @@ lcd_blockfunc_type* blockfunc[4] = {flipblock, bgblock, fgblock, solidblock}; /* Clear the whole display */ void lcd_clear_display(void) { - if (drawmode & DRMODE_INVERSEVID) - memset (lcd_framebuffer, 0xFF, sizeof lcd_framebuffer); - else - memset (lcd_framebuffer, 0, sizeof lcd_framebuffer); + unsigned bits = (drawmode & DRMODE_INVERSEVID) ? 0xFFu : 0; + + memset(lcd_framebuffer, bits, sizeof lcd_framebuffer); scrolling_lines = 0; } diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index a83f58e35d..1255516b51 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c @@ -391,7 +391,7 @@ static void nopixel(int x, int y) } lcd_pixelfunc_type* pixelfunc[8] = {flippixel, nopixel, setpixel, setpixel, - nopixel, clearpixel, nopixel, clearpixel}; + nopixel, clearpixel, nopixel, clearpixel}; static void flipblock(unsigned char *address, unsigned mask, unsigned bits) { @@ -420,10 +420,9 @@ lcd_blockfunc_type* blockfunc[4] = {flipblock, bgblock, fgblock, solidblock}; /* Clear the whole display */ void lcd_clear_display(void) { - if (drawmode & DRMODE_INVERSEVID) - memset (lcd_framebuffer, 0xFF, sizeof lcd_framebuffer); - else - memset (lcd_framebuffer, 0, sizeof lcd_framebuffer); + unsigned bits = (drawmode & DRMODE_INVERSEVID) ? 0xFFu : 0; + + memset(lcd_framebuffer, bits, sizeof lcd_framebuffer); scrolling_lines = 0; } diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index c6e0fe0f0e..3824096aba 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -122,10 +122,6 @@ extern void lcd_jump_scroll_delay(int ms); #define DRMODE_SOLID 3 #define DRMODE_INVERSEVID 4 /* used as bit modifier for basic modes */ -#define DRAW_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] |= (1<<((y)&7)) -#define CLEAR_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] &= ~(1<<((y)&7)) -#define INVERT_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] ^= (1<<((y)&7)) - typedef void lcd_pixelfunc_type(int x, int y); /* for b&w */ typedef void lcd_blockfunc_type(unsigned char *address, unsigned mask, unsigned bits); diff --git a/uisimulator/battery.c b/uisimulator/battery.c index d8580b42d1..acb0835e9f 100644 --- a/uisimulator/battery.c +++ b/uisimulator/battery.c @@ -62,18 +62,16 @@ void draw_battery(int xbase, int ybase, int len, int wid, int percent) } /* top batt. edge */ - lcd_drawline(xbase, ybase, xbase+len-2, ybase); + lcd_hline(xbase, xbase+len-2, ybase); /* bot batt. edge */ - lcd_drawline(xbase, ybase+wid, - xbase+len-2, ybase+wid); + lcd_hine(xbase, xbase+len-2, ybase+wid); /* left batt. edge */ - lcd_drawline(xbase, ybase, xbase, ybase+wid); + lcd_vline(xbase, ybase, ybase+wid); /* right batt. edge */ - lcd_drawline(xbase+len, ybase+1, - xbase+len, ybase+wid-1); + lcd_vline(xbase+len, ybase+1, ybase+wid-1); /* 2 dots that account for the nub on the right side of the battery */ lcd_drawpixel(xbase+len-1, ybase+1); @@ -85,8 +83,8 @@ void draw_battery(int xbase, int ybase, int len, int wid, int percent) bar_len = capacity; for(i = 0; i < bar_wid+1; i++) { - lcd_drawline(xbase+bar_xoffset, ybase+bar_yoffset+i, - xbase+bar_xoffset+bar_len, ybase+bar_yoffset+i); + lcd_hline(xbase+bar_xoffset, + xbase+bar_xoffset+bar_len, ybase+bar_yoffset+i); } } lcd_update(); -- cgit v1.2.3