truncate display_block area if too large

pull/5/head
Paul Klinger 5 years ago
parent 0dbd2a14d7
commit 6a4b62579d

@ -465,9 +465,9 @@ 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 (line > (DISPLAY_HEIGHT/8-1)) return;
if (x + width > DISPLAY_WIDTH - 1) {
width = DISPLAY_WIDTH - x - 1;
if (line > (DISPLAY_HEIGHT/8-1) || x > DISPLAY_WIDTH - 1){return;}
if (x + width > DISPLAY_WIDTH) { // no -1 here, x alone is width 1
width = DISPLAY_WIDTH - x;
}
lcd_goto_xpix_y(x,line);
lcd_data(&displayBuffer[line][x], width);

Loading…
Cancel
Save