summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/lcd-recorder.c39
-rw-r--r--firmware/drivers/serial.c2
2 files changed, 22 insertions, 19 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;
107static int xoffset = 0; /* needed for flip */ 107static int xoffset = 0; /* needed for flip */
108#endif 108#endif
109 109
110unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; 110unsigned 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 */
113static unsigned char zeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 113static 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! */
169void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) __attribute__ ((section (".icode")));
170void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) 169void 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
189void lcd_update (void) __attribute__ ((section (".icode"))); 188void lcd_update (void) __attribute__ ((section (".icode")));
190void lcd_update (void) 189void 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);