Skip to content

Commit bbd32bc

Browse files
committed
Bangle.js2: Add Bangle.setOptions({lcdDoubleRefresh:true}) to pulse EXTCOMIN for LCD twice, avoiding contrast 'toggle' effect when viewing LCD off axis
1 parent 232d826 commit bbd32bc

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Bangle.js: Locale currency deprecated, 'number' updated to BangleApps version with thousands separator, date now doesn't sometimes have trailing spaces
2020
Bangle.js: 6x15 font tweaks for ISO8859-1
2121
Bangle.js2: Fix 'UNFINISHED STRING' error if non-UTF8 char within UTF8 start char range is at end of string
22+
Bangle.js2: Add Bangle.setOptions({lcdDoubleRefresh:true}) to pulse EXTCOMIN for LCD twice, avoiding contrast 'toggle' effect when viewing LCD off axis
2223

2324
2v21 : nRF52: free up 800b more flash by removing vector table padding
2425
Throw Exception when a Promise tries to resolve with another Promise (#2450)

libs/banglejs/jswrap_bangle.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ typedef enum {
963963
JSBF_LCD_BL_ON = 1<<17,
964964
JSBF_LOCKED = 1<<18,
965965
JSBF_HRM_INSTANT_LISTENER = 1<<19,
966+
JSBF_LCD_DBL_REFRESH = 1<<20, ///< On Bangle.js 2, toggle extcomin twice for each poll interval (avoids screen 'flashing' behaviour off axis)
966967

967968
JSBF_DEFAULT = ///< default at power-on
968969
JSBF_WAKEON_TWIST|
@@ -1246,7 +1247,7 @@ void peripheralPollHandler() {
12461247
}
12471248

12481249
#ifdef LCD_CONTROLLER_LPM013M126
1249-
// toggle EXTCOMIN to avoid burn-in on LCD
1250+
// pulse EXTCOMIN to avoid burn-in on LCD
12501251
if (bangleFlags & JSBF_LCD_ON)
12511252
lcdMemLCD_extcominToggle();
12521253
#endif
@@ -1672,6 +1673,13 @@ void peripheralPollHandler() {
16721673

16731674
// we're done, ensure we clear I2C flag
16741675
i2cBusy = false;
1676+
1677+
#ifdef LCD_CONTROLLER_LPM013M126
1678+
// pulse EXTCOMIN to avoid burn-in on LCD (second toggle, if JSBF_LCD_DBL_REFRESH is set)
1679+
if ((bangleFlags & JSBF_LCD_ON) && (bangleFlags & JSBF_LCD_DBL_REFRESH))
1680+
lcdMemLCD_extcominToggle();
1681+
#endif
1682+
16751683
}
16761684

16771685
#ifdef HEARTRATE
@@ -2586,6 +2594,7 @@ for before the clock is reloaded? 1500ms default, or 0 means never.
25862594
* `seaLevelPressure` (Bangle.js 2) Normally 1013.25 millibars - this is used for
25872595
calculating altitude with the pressure sensor
25882596
* `lcdBufferPtr` (Bangle.js 2 2v21+) Return a pointer to the first pixel of the 3 bit graphics buffer used by Bangle.js for the screen (stride = 178 bytes)
2597+
* `lcdDoubleRefresh` (Bangle.js 2 2v22+) If enabled, pulses EXTCOMIN twice per poll interval (avoids off-axis flicker)
25892598
25902599
Where accelerations are used they are in internal units, where `8192 = 1g`
25912600
@@ -2616,6 +2625,7 @@ JsVar * _jswrap_banglejs_setOptions(JsVar *options, bool createObject) {
26162625
#endif
26172626
#ifdef LCD_CONTROLLER_LPM013M126
26182627
int lcdBufferPtr = (int)(size_t)lcdMemLCD_getRowPtr(0);
2628+
bool lcdDoubleRefresh = bangleFlags&JSBF_LCD_DBL_REFRESH;
26192629
#endif
26202630
jsvConfigObject configs[] = {
26212631
#ifdef HEARTRATE
@@ -2661,6 +2671,7 @@ JsVar * _jswrap_banglejs_setOptions(JsVar *options, bool createObject) {
26612671
#endif
26622672
#ifdef LCD_CONTROLLER_LPM013M126
26632673
{"lcdBufferPtr", JSV_INTEGER, &lcdBufferPtr},
2674+
{"lcdDoubleRefresh", JSV_BOOLEAN, &lcdDoubleRefresh}
26642675
#endif
26652676
};
26662677
if (createObject) {
@@ -2691,6 +2702,9 @@ JsVar * _jswrap_banglejs_setOptions(JsVar *options, bool createObject) {
26912702
touchMinY = touchY1;
26922703
touchMaxX = touchX2;
26932704
touchMaxY = touchY2;
2705+
#endif
2706+
#ifdef LCD_CONTROLLER_LPM013M126
2707+
bangleFlags = (bangleFlags&~JSBF_LCD_DBL_REFRESH) | (lcdDoubleRefresh?JSBF_LCD_DBL_REFRESH:0);
26942708
#endif
26952709
}
26962710
return 0;

libs/graphics/lcd_memlcd.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
- 4 bytes at end (needed to allow fast scrolling) also handled by the extra line
3333
*/
3434
unsigned char lcdBuffer[LCD_STRIDE*(LCD_HEIGHT+2)];
35-
bool isBacklightOn; ///< is LCD backlight on? If so we need to toggle EXTCOMIN faster
35+
bool isBacklightOn; ///< is LCD backlight on? If so we need to pulse EXTCOMIN faster
3636
JsVar *lcdOverlayImage; ///< if set, an Image to use for overlays
3737
short lcdOverlayX,lcdOverlayY; ///< coordinates of the graphics instance
3838
volatile bool lcdIsBusy; ///< We're now allowing SPI send in the background - if we're sending, block execution until it finishes
@@ -409,7 +409,7 @@ void lcdMemLCD_init(JsGraphics *gfx) {
409409
jshSPISetup(LCD_SPI, &inf);
410410
}
411411

412-
// toggle EXTCOMIN to avoid burn-in
412+
// pulse EXTCOMIN to avoid burn-in
413413
void lcdMemLCD_extcominToggle() {
414414
if (!isBacklightOn) {
415415
jshPinSetValue(LCD_EXTCOMIN, 1);

libs/graphics/lcd_memlcd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void lcdMemLCD_setCallbacks(JsGraphics *gfx);
1919
void lcdMemLCD_flip(JsGraphics *gfx); // run this to flip the offscreen buffer to the screen
2020
void lcdMemLCD_cmd(int cmd, int dataLen, const char *data); // to send specific commands to the display
2121

22-
/// toggle EXTCOMIN to avoid burn-in
22+
/// pulse EXTCOMIN to avoid burn-in
2323
void lcdMemLCD_extcominToggle();
2424
/// If backlight is on, we need to raise EXTCOMIN freq (use HW PWM)
2525
void lcdMemLCD_extcominBacklight(bool isOn);

0 commit comments

Comments
 (0)