From cfbab84f97309251e1f63596ca30cf83b48ed9d1 Mon Sep 17 00:00:00 2001 From: acidburns Date: Tue, 20 Jan 2026 21:43:23 +0100 Subject: [PATCH] fix(oled): stop refreshing and blank on power off --- src/display_ui.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/display_ui.cpp b/src/display_ui.cpp index d88fe09..bc98995 100644 --- a/src/display_ui.cpp +++ b/src/display_ui.cpp @@ -35,6 +35,7 @@ static uint8_t g_page = 0; static uint32_t g_boot_ms = 0; static bool g_display_ready = false; static uint32_t g_last_init_attempt_ms = 0; +static bool g_last_oled_on = true; #ifdef ENABLE_TEST_MODE static char g_test_code[8] = ""; @@ -270,7 +271,6 @@ void display_tick() { bool in_boot_window = (millis() - g_boot_ms) < OLED_AUTO_OFF_MS; if (in_boot_window) { g_oled_on = true; - oled_set_power(true); } else { if (ctrl_high) { g_oled_on = true; @@ -285,15 +285,26 @@ void display_tick() { g_oled_on = false; } - if (g_oled_on) { - oled_set_power(true); - } else { - oled_set_power(false); - g_prev_ctrl_high = ctrl_high; - return; - } + // fall through to power gating below } + if (g_oled_on) { + if (!g_last_oled_on) { + oled_set_power(true); + g_last_page_ms = millis(); + } + } else { + if (g_last_oled_on) { + display.clearDisplay(); + display.display(); + oled_set_power(false); + } + g_last_oled_on = g_oled_on; + g_prev_ctrl_high = ctrl_high; + return; + } + g_last_oled_on = g_oled_on; + uint32_t now = millis(); uint8_t page_count = g_role == DeviceRole::Sender ? 2 : (1 + g_status_count); if (page_count == 0) {