diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-e200v2')
-rw-r--r-- | firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c index 0d990dc538..f4d1a7cf56 100644 --- a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c +++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c | |||
@@ -493,41 +493,41 @@ void lcd_update(void) | |||
493 | void lcd_update_rect(int x, int y, int width, int height) | 493 | void lcd_update_rect(int x, int y, int width, int height) |
494 | { | 494 | { |
495 | const fb_data *ptr; | 495 | const fb_data *ptr; |
496 | int xmax, ymax; | ||
497 | 496 | ||
498 | if (!display_on) | 497 | if (!display_on) |
499 | return; | 498 | return; |
500 | 499 | ||
501 | xmax = x + width; | 500 | /* nothing to draw? */ |
502 | if (xmax >= LCD_WIDTH) | 501 | if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || |
503 | xmax = LCD_WIDTH - 1; /* Clip right */ | 502 | (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) |
504 | if (x < 0) | 503 | return; |
505 | x = 0; /* Clip left */ | ||
506 | if (x >= xmax) | ||
507 | return; /* nothing left to do */ | ||
508 | |||
509 | width = xmax - x + 1; /* Fix width */ | ||
510 | 504 | ||
511 | ymax = y + height; | 505 | if (x < 0) |
512 | if (ymax >= LCD_HEIGHT) | 506 | { /* clip left */ |
513 | ymax = LCD_HEIGHT - 1; /* Clip bottom */ | 507 | width += x; |
508 | x = 0; | ||
509 | } | ||
514 | if (y < 0) | 510 | if (y < 0) |
515 | y = 0; /* Clip top */ | 511 | { /* clip top */ |
516 | if (y >= ymax) | 512 | height += y; |
517 | return; /* nothing left to do */ | 513 | y = 0; |
514 | } | ||
515 | if (x + width > LCD_WIDTH) | ||
516 | width = LCD_WIDTH - x; /* clip right */ | ||
517 | if (y + height > LCD_HEIGHT) | ||
518 | height = LCD_HEIGHT - y; /* clip bottom */ | ||
518 | 519 | ||
519 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); | 520 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); |
520 | 521 | ||
521 | lcd_window(x, y, xmax, ymax); | 522 | lcd_window(x, y, x+width-1, y+height-1); |
522 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | 523 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); |
523 | 524 | ||
524 | ptr = &lcd_framebuffer[y][x]; | 525 | ptr = &lcd_framebuffer[y][x]; |
525 | 526 | ||
526 | height = ymax - y; /* fix height */ | ||
527 | do | 527 | do |
528 | { | 528 | { |
529 | lcd_write_data(ptr, width); | 529 | lcd_write_data(ptr, width); |
530 | ptr += LCD_WIDTH; | 530 | ptr += LCD_WIDTH; |
531 | } | 531 | } |
532 | while (--height >= 0); | 532 | while (--height > 0); |
533 | } | 533 | } |