From 750261d2058e769ac93936277838031137c883cf Mon Sep 17 00:00:00 2001 From: srg74 <28492985+srg74@users.noreply.github.com> Date: Sun, 5 Jan 2020 14:47:31 -0500 Subject: [PATCH] Turn off display after 5 min. Better shut off display after few minutes to preserve display life time. --- usermods/ssd1306_i2c_oled_u8g2/wled06_usermod.ino | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usermods/ssd1306_i2c_oled_u8g2/wled06_usermod.ino b/usermods/ssd1306_i2c_oled_u8g2/wled06_usermod.ino index 593625b91..cef01cddf 100644 --- a/usermods/ssd1306_i2c_oled_u8g2/wled06_usermod.ino +++ b/usermods/ssd1306_i2c_oled_u8g2/wled06_usermod.ino @@ -39,6 +39,8 @@ uint8_t knownMode = 0; uint8_t knownPalette = 0; long lastUpdate = 0; +long startupTimestamp = millis(); +bool displayTurnedOff = false; // How often we are redrawing screen #define USER_LOOP_REFRESH_RATE_MS 5000 @@ -49,6 +51,11 @@ void userLoop() { return; } 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. if ((apActive == true ? String(apSSID) : WiFi.SSID()) != knownSsid) {