v1.0.14: Display blanking config in captive portal

- Add Options section to captive portal with display blanking dropdown
- Options: Never, 1, 5, 10, 30, 60 minutes
- Change EEPROM blanking value from seconds to minutes (supports up to 255 min)
- Update Display.h and Utilities.h to interpret stored value as minutes
- Default blanking timeout changed from 15s to 1 minute
This commit is contained in:
James L
2026-02-28 15:15:21 -05:00
parent 5c153e56dc
commit a3ea18b4a7
3 changed files with 49 additions and 4 deletions

View File

@@ -256,6 +256,35 @@ static void config_send_html() {
html += F(" dBm (with PA)</p>");
#endif
// ── Options Section ──
html += F(
"<h2>&#x2699; Options</h2>"
"<label>Display Blanking</label>"
"<select name='disp_blank'>"
);
// Read current blanking timeout from EEPROM (stored as minutes, 0 = never)
uint8_t cur_blank = 0;
if (EEPROM.read(eeprom_addr(ADDR_CONF_BSET)) == CONF_OK_BYTE) {
cur_blank = EEPROM.read(eeprom_addr(ADDR_CONF_DBLK));
}
static const uint8_t blank_vals[] = { 0, 1, 5, 10, 30, 60 };
static const char* blank_labels[] = { "Never", "1 minute", "5 minutes", "10 minutes", "30 minutes", "60 minutes" };
static const int blank_count = 6;
for (int i = 0; i < blank_count; i++) {
html += F("<option value='");
html += String(blank_vals[i]);
html += "'";
if (blank_vals[i] == cur_blank) html += F(" selected");
html += ">";
html += blank_labels[i];
html += F("</option>");
}
html += F("</select>");
html += F("<p class='note'>Turn off display after inactivity to save power</p>");
// ── Submit ──
html += F(
"<button type='submit'>Save &amp; Reboot</button>"
@@ -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;

View File

@@ -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

View File

@@ -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);