From 8dd7e45e40a19738b9d06b81be8a462dcc906e18 Mon Sep 17 00:00:00 2001 From: Sottosistema W10 Date: Tue, 14 Sep 2021 19:58:35 +0200 Subject: [PATCH] Improved OLED power save functions --- data_embed/index.html | 6 +++--- src/TTGO_T-Beam_LoRa_APRS.ino | 16 +++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/data_embed/index.html b/data_embed/index.html index af976eb..7d23e11 100644 --- a/data_embed/index.html +++ b/data_embed/index.html @@ -166,8 +166,8 @@
- - + +
@@ -179,7 +179,7 @@
- +
diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index b1d2d1a..66a9d1c 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -182,7 +182,9 @@ boolean shutdown_countdown_timer_enable = false; boolean shutdown_usb_status_bef = false; // Variables required to Power Save OLED -ulong oled_timeout = 20000; // OLED Timeout +// With "Display dimmer enabled" it will turn OLED off after some time +// if the checkbox is disabled the display stays OFF +uint oled_timeout; // OLED Timeout, same as "Display show RX Time" bool tempOled = true; // Turn ON OLED at first startup ulong oled_timer = millis(); @@ -392,10 +394,10 @@ void writedisplaytext(String HeaderTxt, String Line1, String Line2, String Line3 display.println(Line5); if (enabled_oled){ //axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); // enable oled - //display.dim(true); + //display.dim(false); }else{ //axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF); // disable oled - //display.dim(false); + display.dim(true); } display.display(); time_to_refresh = millis() + showRXTime; @@ -658,6 +660,8 @@ void setup(){ preferences.putInt(PREF_DEV_SHOW_RX_TIME, showRXTime/1000); } showRXTime = preferences.getInt(PREF_DEV_SHOW_RX_TIME) * 1000; + // Use same timer for OLED timeout + oled_timeout = showRXTime; if (!preferences.getBool(PREF_DEV_AUTO_SHUT_PRESET_INIT)){ preferences.putBool(PREF_DEV_AUTO_SHUT_PRESET_INIT, true); @@ -843,7 +847,7 @@ void loop() { delay(300); time_delay = millis() + 1500; if(digitalRead(BUTTON)==HIGH){ - if (!tempOled) { + if (!tempOled && enabled_oled) { enableOled(); // turn ON OLED temporary } else { if(gps_state == true && gps.location.isValid()){ @@ -860,7 +864,9 @@ void loop() { } // Only wake up OLED when necessary, note that DIM is to turn OFF the backlight - display.dim(!tempOled); + if (enabled_oled) { + display.dim(!tempOled); + } if (tempOled && millis()>= oled_timer) { tempOled = false; // After some time reset backlight