diff --git a/BoundaryConfig.h b/BoundaryConfig.h index 9cf048c..0e9f11d 100644 --- a/BoundaryConfig.h +++ b/BoundaryConfig.h @@ -256,6 +256,35 @@ static void config_send_html() { html += F(" dBm (with PA)

"); #endif + // ── Options Section ── + html += F( + "

⚙ Options

" + "" + ""); + html += F("

Turn off display after inactivity to save power

"); + // ── Submit ── html += F( "" @@ -292,6 +321,20 @@ static void config_handle_save() { // ── WiFi enable setting ── boundary_state.wifi_enabled = (config_server->arg("wifi_en").toInt() == 1); + // ── Display blanking (EEPROM stores minutes, 0 = disabled) ── + int blank_minutes = config_server->arg("disp_blank").toInt(); + if (blank_minutes <= 0) { + display_blanking_enabled = false; + eeprom_update(eeprom_addr(ADDR_CONF_BSET), CONF_OK_BYTE); + eeprom_update(eeprom_addr(ADDR_CONF_DBLK), 0); + } else { + uint8_t blank_val = (uint8_t)(blank_minutes > 255 ? 255 : blank_minutes); + display_blanking_enabled = true; + display_blanking_timeout = (uint32_t)blank_val * 60UL * 1000UL; + eeprom_update(eeprom_addr(ADDR_CONF_BSET), CONF_OK_BYTE); + eeprom_update(eeprom_addr(ADDR_CONF_DBLK), blank_val); + } + // ── TCP backbone settings ── boundary_state.tcp_mode = (uint8_t)config_server->arg("tcp_mode").toInt(); // 0=disabled, 1=client if (boundary_state.tcp_mode > 1) boundary_state.tcp_mode = 0; diff --git a/Display.h b/Display.h index b9c6395..a71104d 100755 --- a/Display.h +++ b/Display.h @@ -160,7 +160,7 @@ float epd_update_fps = 0.5; #define DISP_MODE_LANDSCAPE 0x01 #define DISP_MODE_PORTRAIT 0x02 #define DISP_PIN_SIZE 6 -#define DISPLAY_BLANKING_TIMEOUT 15*1000 +#define DISPLAY_BLANKING_TIMEOUT 1*60*1000 uint8_t disp_mode = DISP_MODE_UNKNOWN; uint8_t disp_ext_fb = false; unsigned char fb[512]; @@ -371,6 +371,7 @@ bool display_init() { uint8_t display_address = DISP_ADDR; #endif + // EEPROM blanking value is stored as minutes (0 = disabled) #if HAS_EEPROM if (EEPROM.read(eeprom_addr(ADDR_CONF_BSET)) == CONF_OK_BYTE) { uint8_t db_timeout = EEPROM.read(eeprom_addr(ADDR_CONF_DBLK)); @@ -378,7 +379,7 @@ bool display_init() { display_blanking_enabled = false; } else { display_blanking_enabled = true; - display_blanking_timeout = db_timeout*1000; + display_blanking_timeout = (uint32_t)db_timeout * 60UL * 1000UL; } } #elif MCU_VARIANT == MCU_NRF52 @@ -388,7 +389,7 @@ bool display_init() { display_blanking_enabled = false; } else { display_blanking_enabled = true; - display_blanking_timeout = db_timeout*1000; + display_blanking_timeout = (uint32_t)db_timeout * 60UL * 1000UL; } } #endif diff --git a/Utilities.h b/Utilities.h index 34fc233..e4547d1 100755 --- a/Utilities.h +++ b/Utilities.h @@ -1789,12 +1789,13 @@ void da_conf_save(uint8_t dadr) { } void db_conf_save(uint8_t val) { + // val is in minutes (0 = disabled) #if HAS_DISPLAY if (val == 0x00) { display_blanking_enabled = false; } else { display_blanking_enabled = true; - display_blanking_timeout = val*1000; + display_blanking_timeout = (uint32_t)val * 60UL * 1000UL; } eeprom_update(eeprom_addr(ADDR_CONF_BSET), CONF_OK_BYTE); eeprom_update(eeprom_addr(ADDR_CONF_DBLK), val);