diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd-recorder.c | 39 | ||||
-rw-r--r-- | firmware/drivers/serial.c | 2 | ||||
-rw-r--r-- | firmware/export/lcd.h | 8 |
3 files changed, 26 insertions, 23 deletions
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 9cc677ce15..910f1dc693 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c | |||
@@ -107,7 +107,7 @@ static int curfont = FONT_SYSFIXED; | |||
107 | static int xoffset = 0; /* needed for flip */ | 107 | static int xoffset = 0; /* needed for flip */ |
108 | #endif | 108 | #endif |
109 | 109 | ||
110 | unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; | 110 | unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; |
111 | 111 | ||
112 | /* All zeros and ones bitmaps for area filling */ | 112 | /* All zeros and ones bitmaps for area filling */ |
113 | static unsigned char zeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; | 113 | static unsigned char zeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
@@ -166,7 +166,6 @@ void lcd_init (void) | |||
166 | 166 | ||
167 | /* Performance function that works with an external buffer | 167 | /* Performance function that works with an external buffer |
168 | note that y and height are in 8-pixel units! */ | 168 | note that y and height are in 8-pixel units! */ |
169 | void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) __attribute__ ((section (".icode"))); | ||
170 | void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) | 169 | void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) |
171 | { | 170 | { |
172 | /* Copy display bitmap to hardware */ | 171 | /* Copy display bitmap to hardware */ |
@@ -189,7 +188,7 @@ void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int s | |||
189 | void lcd_update (void) __attribute__ ((section (".icode"))); | 188 | void lcd_update (void) __attribute__ ((section (".icode"))); |
190 | void lcd_update (void) | 189 | void lcd_update (void) |
191 | { | 190 | { |
192 | int x, y; | 191 | int y; |
193 | 192 | ||
194 | /* Copy display bitmap to hardware */ | 193 | /* Copy display bitmap to hardware */ |
195 | for (y = 0; y < LCD_HEIGHT/8; y++) | 194 | for (y = 0; y < LCD_HEIGHT/8; y++) |
@@ -198,8 +197,7 @@ void lcd_update (void) | |||
198 | lcd_write (true, LCD_CNTL_HIGHCOL | ((xoffset>>4) & 0xf)); | 197 | lcd_write (true, LCD_CNTL_HIGHCOL | ((xoffset>>4) & 0xf)); |
199 | lcd_write (true, LCD_CNTL_LOWCOL | (xoffset & 0xf)); | 198 | lcd_write (true, LCD_CNTL_LOWCOL | (xoffset & 0xf)); |
200 | 199 | ||
201 | for (x = 0; x < LCD_WIDTH; x++) | 200 | lcd_write_data (lcd_framebuffer[y], LCD_WIDTH); |
202 | lcd_write (false, lcd_framebuffer[x][y]); | ||
203 | } | 201 | } |
204 | } | 202 | } |
205 | 203 | ||
@@ -211,17 +209,15 @@ void lcd_update_rect (int x_start, int y, | |||
211 | int width, int height) | 209 | int width, int height) |
212 | { | 210 | { |
213 | int ymax; | 211 | int ymax; |
214 | int xmax; | ||
215 | int x; | ||
216 | 212 | ||
217 | /* The Y coordinates have to work on even 8 pixel rows */ | 213 | /* The Y coordinates have to work on even 8 pixel rows */ |
218 | ymax = (y + height)/8; | 214 | ymax = (y + height-1)/8; |
219 | y /= 8; | 215 | y /= 8; |
220 | 216 | ||
221 | xmax = x_start + width; | 217 | if(x_start + width > LCD_WIDTH) |
222 | 218 | width = LCD_WIDTH - x_start; | |
223 | if(xmax > LCD_WIDTH) | 219 | if (width <= 0) |
224 | xmax = LCD_WIDTH; | 220 | return; /* nothing left to do, 0 is harmful to lcd_write_data() */ |
225 | if(ymax >= LCD_HEIGHT/8) | 221 | if(ymax >= LCD_HEIGHT/8) |
226 | ymax = LCD_HEIGHT/8-1; | 222 | ymax = LCD_HEIGHT/8-1; |
227 | 223 | ||
@@ -232,8 +228,7 @@ void lcd_update_rect (int x_start, int y, | |||
232 | lcd_write (true, LCD_CNTL_HIGHCOL | (((x_start+xoffset)>>4) & 0xf)); | 228 | lcd_write (true, LCD_CNTL_HIGHCOL | (((x_start+xoffset)>>4) & 0xf)); |
233 | lcd_write (true, LCD_CNTL_LOWCOL | ((x_start+xoffset) & 0xf)); | 229 | lcd_write (true, LCD_CNTL_LOWCOL | ((x_start+xoffset) & 0xf)); |
234 | 230 | ||
235 | for (x = x_start; x < xmax; x++) | 231 | lcd_write_data (&lcd_framebuffer[y][x_start], width); |
236 | lcd_write (false, lcd_framebuffer[x][y]); | ||
237 | } | 232 | } |
238 | } | 233 | } |
239 | 234 | ||
@@ -459,7 +454,15 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, | |||
459 | ny = LCD_HEIGHT - y; | 454 | ny = LCD_HEIGHT - y; |
460 | 455 | ||
461 | shift = y & 7; | 456 | shift = y & 7; |
462 | dst2 = &lcd_framebuffer[x][y/8]; | 457 | dst2 = &lcd_framebuffer[y/8][x]; |
458 | |||
459 | /* short cut for byte aligned match (e.g. standard text) */ | ||
460 | if (!shift && ny==8) | ||
461 | { | ||
462 | memcpy(dst2, src, nx); | ||
463 | return; | ||
464 | } | ||
465 | |||
463 | ny += shift; | 466 | ny += shift; |
464 | 467 | ||
465 | /* Calculate bit masks */ | 468 | /* Calculate bit masks */ |
@@ -479,7 +482,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, | |||
479 | for (x = 0; x < nx; x++) | 482 | for (x = 0; x < nx; x++) |
480 | { | 483 | { |
481 | dst = dst2; | 484 | dst = dst2; |
482 | dst2 += LCD_HEIGHT/8; | 485 | dst2++; |
483 | data = 0; | 486 | data = 0; |
484 | y = 0; | 487 | y = 0; |
485 | 488 | ||
@@ -489,7 +492,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, | |||
489 | data = *src++ << shift; | 492 | data = *src++ << shift; |
490 | *dst = (*dst & mask) | data; | 493 | *dst = (*dst & mask) | data; |
491 | data >>= 8; | 494 | data >>= 8; |
492 | dst++; | 495 | dst += LCD_WIDTH; |
493 | 496 | ||
494 | /* Intermediate rows */ | 497 | /* Intermediate rows */ |
495 | for (y = 8; y < ny-8; y += 8) | 498 | for (y = 8; y < ny-8; y += 8) |
@@ -497,7 +500,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, | |||
497 | data |= *src++ << shift; | 500 | data |= *src++ << shift; |
498 | *dst = (*dst & mask2) | data; | 501 | *dst = (*dst & mask2) | data; |
499 | data >>= 8; | 502 | data >>= 8; |
500 | dst++; | 503 | dst += LCD_WIDTH; |
501 | } | 504 | } |
502 | } | 505 | } |
503 | 506 | ||
diff --git a/firmware/drivers/serial.c b/firmware/drivers/serial.c index bc32dde5eb..5aae38e58c 100644 --- a/firmware/drivers/serial.c +++ b/firmware/drivers/serial.c | |||
@@ -177,7 +177,7 @@ static void screen_dump(void) | |||
177 | { | 177 | { |
178 | for(x = 0;x < LCD_WIDTH;x++) | 178 | for(x = 0;x < LCD_WIDTH;x++) |
179 | { | 179 | { |
180 | serial_tx(lcd_framebuffer[x][y]); | 180 | serial_tx(lcd_framebuffer[y][x]); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | set_irq_level(level); | 183 | set_irq_level(level); |
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index c81d2de2b3..733efdded3 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h | |||
@@ -111,14 +111,14 @@ void lcd_remove_cursor(void); | |||
111 | #define LCD_HEIGHT 64 /* Display height in pixels */ | 111 | #define LCD_HEIGHT 64 /* Display height in pixels */ |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #define DRAW_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] |= (1<<((y)&7)) | 114 | #define DRAW_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] |= (1<<((y)&7)) |
115 | #define CLEAR_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] &= ~(1<<((y)&7)) | 115 | #define CLEAR_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] &= ~(1<<((y)&7)) |
116 | #define INVERT_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] ^= (1<<((y)&7)) | 116 | #define INVERT_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] ^= (1<<((y)&7)) |
117 | 117 | ||
118 | /* | 118 | /* |
119 | * Memory copy of display bitmap | 119 | * Memory copy of display bitmap |
120 | */ | 120 | */ |
121 | extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; | 121 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; |
122 | 122 | ||
123 | extern void lcd_setmargins(int xmargin, int ymargin); | 123 | extern void lcd_setmargins(int xmargin, int ymargin); |
124 | extern int lcd_getxmargin(void); | 124 | extern int lcd_getxmargin(void); |