Skip to content

Commit

Permalink
Bangle.js2: When rendering overlays, *do not* use the current FG/BG c…
Browse files Browse the repository at this point in the history
…olor for 1 bit overlays

espruino/BangleApps#3003 (comment)
  • Loading branch information
gfwilliams committed Sep 13, 2023
1 parent d324e4b commit 6baf1a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
2v20 : Ensure String.charCodeAt returns NaN for out of bounds chars
Bangle.js2: When rendering overlays, *do not* use the current FG/BG color for 1 bit overlays

2v19 : Fix Object.values/entries for numeric keys after 2v18 regression (fix #2375)
nRF52: for SD>5 use static buffers for advertising and scan response data (#2367)
Expand Down
11 changes: 9 additions & 2 deletions libs/graphics/lcd_memlcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ void lcdMemLCD_flip(JsGraphics *gfx) {
bool isRotated180 = (graphicsInternal.data.flags & (JSGRAPHICSFLAGS_SWAP_XY | JSGRAPHICSFLAGS_INVERT_X | JSGRAPHICSFLAGS_INVERT_Y)) ==
(JSGRAPHICSFLAGS_INVERT_X | JSGRAPHICSFLAGS_INVERT_Y);
int ovY = isRotated180 ? (LCD_HEIGHT-(lcdOverlayY+overlayImg.height)) : lcdOverlayY;

// Set colors to current theme
unsigned int oldFgColor = gfx->data.fgColor;
unsigned int oldBgColor = gfx->data.bgColor;
gfx->data.fgColor = graphicsTheme.fg;
gfx->data.bgColor = graphicsTheme.bg;
// initialise image layer
GfxDrawImageLayer l;
l.x1 = 0;
Expand Down Expand Up @@ -346,11 +350,14 @@ void lcdMemLCD_flip(JsGraphics *gfx) {
}
jsvStringIteratorFree(&l.it);
_jswrap_graphics_freeImageInfo(&overlayImg);
// any 2 final bytes to finish the transfer
// and 2 final bytes to finish the transfer
#ifndef EMULATED
jshSPISendMany(LCD_SPI, lcdBuffer, NULL, 2, NULL);
lcdMemLCD_flip_spi_callback();
#endif
// Restore colors to previous state
gfx->data.fgColor = oldFgColor;
gfx->data.bgColor = oldBgColor;
} else { // standard, non-overlay
#ifdef EMULATED
memcpy(fakeLCDBuffer, lcdBuffer, LCD_HEIGHT*LCD_STRIDE);
Expand Down

0 comments on commit 6baf1a5

Please sign in to comment.