From 0dbd2a14d7ef39fba94fcf40e61fee9da32f7320 Mon Sep 17 00:00:00 2001 From: Paul Klinger Date: Tue, 12 Feb 2019 18:26:26 +0100 Subject: [PATCH] truncate display_block area if too large --- lcd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lcd.c b/lcd.c index f19c8e9..2c5460a 100644 --- a/lcd.c +++ b/lcd.c @@ -465,7 +465,10 @@ uint8_t lcd_check_buffer(uint8_t x, uint8_t y) { return displayBuffer[(y / (DISPLAY_HEIGHT/8))][x] & (1 << (y % (DISPLAY_HEIGHT/8))); } void lcd_display_block(uint8_t x, uint8_t line, uint8_t width) { - if ( x+width > (DISPLAY_WIDTH) || line > (DISPLAY_HEIGHT/8-1)) return; + if (line > (DISPLAY_HEIGHT/8-1)) return; + if (x + width > DISPLAY_WIDTH - 1) { + width = DISPLAY_WIDTH - x - 1; + } lcd_goto_xpix_y(x,line); lcd_data(&displayBuffer[line][x], width); }