Turn off display after 5 min.

Better shut off display after few minutes to preserve display life time.
This commit is contained in:
srg74 2020-01-05 14:47:31 -05:00 committed by GitHub
parent df1b25f381
commit 750261d205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,8 @@ uint8_t knownMode = 0;
uint8_t knownPalette = 0; uint8_t knownPalette = 0;
long lastUpdate = 0; long lastUpdate = 0;
long startupTimestamp = millis();
bool displayTurnedOff = false;
// How often we are redrawing screen // How often we are redrawing screen
#define USER_LOOP_REFRESH_RATE_MS 5000 #define USER_LOOP_REFRESH_RATE_MS 5000
@ -49,6 +51,11 @@ void userLoop() {
return; return;
} }
lastUpdate = millis(); lastUpdate = millis();
// Turn off display after 5 minutes from powering.
if( !displayTurnedOff && millis() - startupTimestamp > 5*60*1000) {
u8x8.setPowerSave(1);
displayTurnedOff = true;
}
// Check if values which are shown on display changed from the last tiem. // Check if values which are shown on display changed from the last tiem.
if ((apActive == true ? String(apSSID) : WiFi.SSID()) != knownSsid) { if ((apActive == true ? String(apSSID) : WiFi.SSID()) != knownSsid) {