Skip to content

Commit 85d566f

Browse files
committed
setting overlay now renders just the area that changed
1 parent 372fa78 commit 85d566f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

libs/banglejs/jswrap_bangle.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2571,16 +2571,16 @@ void jswrap_banglejs_setLCDOverlay(JsVar *imgVar, JsVar *xv, int y, JsVar *optio
25712571
// Send the command to the LCD
25722572
#ifdef LCD_CONTROLLER_LPM013M126
25732573
lcdMemLCD_setOverlay(imgVar, x, y);
2574+
// lcdMemLCD_setOverlay sets the modified area
25742575
#endif
25752576
#if defined(LCD_CONTROLLER_ST7789V) || defined(LCD_CONTROLLER_ST7735) || defined(LCD_CONTROLLER_GC9A01)
25762577
lcdSetOverlay_SPILCD(imgVar, x, y);
2577-
#endif
25782578
// set all as modified
2579-
// TODO: Could look at old vs new overlay state and update only lines that had changed?
25802579
graphicsInternal.data.modMinX = 0;
25812580
graphicsInternal.data.modMinY = 0;
25822581
graphicsInternal.data.modMaxX = LCD_WIDTH-1;
25832582
graphicsInternal.data.modMaxY = LCD_HEIGHT-1;
2583+
#endif
25842584
}
25852585

25862586
/*JSON{

libs/graphics/lcd_memlcd.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,15 @@ void lcdMemLCD_extcominBacklight(bool isOn) {
430430

431431
// Enable overlay mode (to overlay a graphics instance on top of the LCD contents)
432432
void lcdMemLCD_setOverlay(JsVar *imgVar, int x, int y) {
433-
if (lcdOverlayImage) jsvUnLock(lcdOverlayImage);
433+
if (lcdOverlayImage) {
434+
lcdMemLCD_setOverlayModified(&graphicsInternal); // add the area where the overlay *was*
435+
jsvUnLock(lcdOverlayImage);
436+
}
434437
if (imgVar) {
435438
lcdOverlayImage = jsvLockAgain(imgVar);
436439
lcdOverlayX = (short)x;
437440
lcdOverlayY = (short)y;
441+
lcdMemLCD_setOverlayModified(&graphicsInternal); // add the area where the overlay *is now*
438442
} else {
439443
lcdOverlayImage = 0;
440444
lcdOverlayX = 0;
@@ -456,6 +460,11 @@ void lcdMemLCD_setOverlayModified(JsGraphics *gfx) {
456460
graphicsSetModified(gfx, x,y,x2,y2);
457461
_jswrap_graphics_freeImageInfo(&overlayImg);
458462
}
463+
} else { // no overlay - redraw everything
464+
graphicsInternal.data.modMinX = 0;
465+
graphicsInternal.data.modMinY = 0;
466+
graphicsInternal.data.modMaxX = LCD_WIDTH-1;
467+
graphicsInternal.data.modMaxY = LCD_HEIGHT-1;
459468
}
460469
}
461470

0 commit comments

Comments
 (0)