Improved OLED power save functions

This commit is contained in:
Sottosistema W10 2021-09-14 19:58:35 +02:00
parent 40234f4d50
commit 8dd7e45e40
2 changed files with 14 additions and 8 deletions

View File

@ -166,8 +166,8 @@
</div> </div>
<div class="grid-container quarters"> <div class="grid-container quarters">
<div> <div>
<label for="oled_enabled">Display dimmer enabled</label> <label for="oled_enabled">OLED Display enabled</label>
<input name="oled_enabled" id="oled_enabled" type="checkbox" value="1" title="enable or disable oled dimmer"> <input name="oled_enabled" id="oled_enabled" type="checkbox" value="1" title="ON: Display will turn ON when pushing button. OFF: Stays OFF">
</div> </div>
<div> <div>
<label for="bt_enabled">Bluetooth enabled</label> <label for="bt_enabled">Bluetooth enabled</label>
@ -179,7 +179,7 @@
</div> </div>
<div> <div>
<label for="shutdown_act">Auto power off</label> <label for="shutdown_act">Auto power off</label>
<input name="shutdown_act" id="shutdown_act" type="checkbox" value="1" title="activate auto shutdown after usb plug off"> <input name="shutdown_act" id="shutdown_act" type="checkbox" value="1" title="activate auto shutdown after usb plug off (not for T-BEAM 0.7)">
</div> </div>
</div> </div>
<div class="grid-container quarters"> <div class="grid-container quarters">

View File

@ -182,7 +182,9 @@ boolean shutdown_countdown_timer_enable = false;
boolean shutdown_usb_status_bef = false; boolean shutdown_usb_status_bef = false;
// Variables required to Power Save OLED // 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 bool tempOled = true; // Turn ON OLED at first startup
ulong oled_timer = millis(); ulong oled_timer = millis();
@ -392,10 +394,10 @@ void writedisplaytext(String HeaderTxt, String Line1, String Line2, String Line3
display.println(Line5); display.println(Line5);
if (enabled_oled){ if (enabled_oled){
//axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); // enable oled //axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); // enable oled
//display.dim(true); //display.dim(false);
}else{ }else{
//axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF); // disable oled //axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF); // disable oled
//display.dim(false); display.dim(true);
} }
display.display(); display.display();
time_to_refresh = millis() + showRXTime; time_to_refresh = millis() + showRXTime;
@ -658,6 +660,8 @@ void setup(){
preferences.putInt(PREF_DEV_SHOW_RX_TIME, showRXTime/1000); preferences.putInt(PREF_DEV_SHOW_RX_TIME, showRXTime/1000);
} }
showRXTime = preferences.getInt(PREF_DEV_SHOW_RX_TIME) * 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)){ if (!preferences.getBool(PREF_DEV_AUTO_SHUT_PRESET_INIT)){
preferences.putBool(PREF_DEV_AUTO_SHUT_PRESET_INIT, true); preferences.putBool(PREF_DEV_AUTO_SHUT_PRESET_INIT, true);
@ -843,7 +847,7 @@ void loop() {
delay(300); delay(300);
time_delay = millis() + 1500; time_delay = millis() + 1500;
if(digitalRead(BUTTON)==HIGH){ if(digitalRead(BUTTON)==HIGH){
if (!tempOled) { if (!tempOled && enabled_oled) {
enableOled(); // turn ON OLED temporary enableOled(); // turn ON OLED temporary
} else { } else {
if(gps_state == true && gps.location.isValid()){ 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 // 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) { if (tempOled && millis()>= oled_timer) {
tempOled = false; // After some time reset backlight tempOled = false; // After some time reset backlight