mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Ensure memory LCD turns off, toggle EXTCOMIN as per spec (120Hz when backlight on)
This commit is contained in:
parent
d41a7af184
commit
28fa59fb8a
@ -635,6 +635,10 @@ void jswrap_banglejs_pwrBacklight(bool on) {
|
||||
#ifdef LCD_BL
|
||||
jshPinOutput(LCD_BL, on);
|
||||
#endif
|
||||
#ifdef LCD_CONTROLLER_LPM013M126
|
||||
lcdMemLCD_extcominBacklight(on);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// Flip buffer contents with the screen.
|
||||
@ -788,6 +792,11 @@ void peripheralPollHandler() {
|
||||
homeBtnTimer = 0;
|
||||
}
|
||||
|
||||
#ifdef LCD_CONTROLLER_LPM013M126
|
||||
// toggle EXTCOMIN to avoid burn-in on LCD
|
||||
lcdMemLCD_extcominToggle();
|
||||
#endif
|
||||
|
||||
if (lcdPowerTimeout && lcdPowerOn && flipTimer>=lcdPowerTimeout) {
|
||||
// 10 seconds of inactivity, turn off display
|
||||
bangleTasks |= JSBT_LCD_OFF;
|
||||
@ -3063,10 +3072,6 @@ bool jswrap_banglejs_idle() {
|
||||
}
|
||||
jsvUnLock(graphics);
|
||||
#endif
|
||||
#ifdef LCD_CONTROLLER_LPM013M126
|
||||
// toggle EXTCOMIN to avoid burn-in
|
||||
lcdMemLCD_extcomin();
|
||||
#endif
|
||||
#ifdef ESPR_BACKLIGHT_FADE
|
||||
if (lcdFadeHandlerActive && realLcdBrightness == (lcdPowerOn?lcdBrightness:0)) {
|
||||
jstStopExecuteFn(backlightFadeHandler, NULL);
|
||||
@ -3725,6 +3730,10 @@ static void jswrap_banglejs_periph_off() {
|
||||
//jswrap_banglejs_setLCDPower calls JS events (and sometimes timers), so avoid it and manually turn controller + backlight off:
|
||||
jswrap_banglejs_setLCDPowerController(0);
|
||||
jswrap_banglejs_pwrBacklight(0);
|
||||
#ifdef LCD_CONTROLLER_LPM013M126
|
||||
jshPinOutput(LCD_EXTCOMIN,0);
|
||||
jshPinOutput(LCD_DISP,0);
|
||||
#endif
|
||||
#ifdef ACCEL_DEVICE_KX023
|
||||
jswrap_banglejs_accelWr(0x18,0x0a); // accelerometer off
|
||||
#endif
|
||||
@ -3744,6 +3753,7 @@ static void jswrap_banglejs_periph_off() {
|
||||
jswrap_banglejs_barometerWr(0xF4, 0); // Barometer off
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BTN2_PININDEX
|
||||
nrf_gpio_cfg_sense_set(pinInfo[BTN2_PININDEX].pin, NRF_GPIO_PIN_NOSENSE);
|
||||
#endif
|
||||
|
||||
@ -20,11 +20,13 @@
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#define LCD_SPI EV_SPI1
|
||||
#define LCD_ROWHEADER 2
|
||||
#define LCD_STRIDE (LCD_ROWHEADER+((LCD_WIDTH*LCD_BPP+7)>>3)) // data in required BPP, plus 2 bytes LCD command
|
||||
unsigned char lcdBuffer[LCD_STRIDE*LCD_HEIGHT +2/*2 bytes end of transfer*/];
|
||||
|
||||
#define LCD_SPI EV_SPI1
|
||||
unsigned char lcdBuffer[LCD_STRIDE*LCD_HEIGHT +2/*2 bytes end of transfer*/];
|
||||
bool isBacklightOn;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -132,10 +134,24 @@ void lcdMemLCD_init(JsGraphics *gfx) {
|
||||
}
|
||||
|
||||
// toggle EXTCOMIN to avoid burn-in
|
||||
void lcdMemLCD_extcomin() {
|
||||
static bool extcomin = false;
|
||||
extcomin = !extcomin;
|
||||
jshPinSetValue(LCD_EXTCOMIN, extcomin);
|
||||
void lcdMemLCD_extcominToggle() {
|
||||
if (!isBacklightOn) {
|
||||
jshPinSetValue(LCD_EXTCOMIN, 1);
|
||||
jshPinSetValue(LCD_EXTCOMIN, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// If backlight is on, we need to raise EXTCOMIN freq (use HW PWM)
|
||||
void lcdMemLCD_extcominBacklight(bool isOn) {
|
||||
if (isBacklightOn != isOn) {
|
||||
isBacklightOn = isOn;
|
||||
if (isOn) {
|
||||
jshPinAnalogOutput(LCD_EXTCOMIN, 0.05, 120, JSAOF_NONE);
|
||||
} else {
|
||||
jshPinOutput(LCD_EXTCOMIN, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void lcdMemLCD_setCallbacks(JsGraphics *gfx) {
|
||||
|
||||
@ -18,4 +18,8 @@ void lcdMemLCD_setCallbacks(JsGraphics *gfx);
|
||||
|
||||
void lcdMemLCD_flip(JsGraphics *gfx); // run this to flip the offscreen buffer to the screen
|
||||
void lcdMemLCD_cmd(int cmd, int dataLen, const char *data); // to send specific commands to the display
|
||||
void lcdMemLCD_extcomin(); // toggle EXTCOMIN to avoid burn-in
|
||||
|
||||
/// toggle EXTCOMIN to avoid burn-in
|
||||
void lcdMemLCD_extcominToggle();
|
||||
/// If backlight is on, we need to raise EXTCOMIN freq (use HW PWM)
|
||||
void lcdMemLCD_extcominBacklight(bool isOn);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user