fix(oled): stop refreshing and blank on power off

This commit is contained in:
2026-01-20 21:43:23 +01:00
parent 6f308ad590
commit cfbab84f97

View File

@@ -35,6 +35,7 @@ static uint8_t g_page = 0;
static uint32_t g_boot_ms = 0; static uint32_t g_boot_ms = 0;
static bool g_display_ready = false; static bool g_display_ready = false;
static uint32_t g_last_init_attempt_ms = 0; static uint32_t g_last_init_attempt_ms = 0;
static bool g_last_oled_on = true;
#ifdef ENABLE_TEST_MODE #ifdef ENABLE_TEST_MODE
static char g_test_code[8] = ""; 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; bool in_boot_window = (millis() - g_boot_ms) < OLED_AUTO_OFF_MS;
if (in_boot_window) { if (in_boot_window) {
g_oled_on = true; g_oled_on = true;
oled_set_power(true);
} else { } else {
if (ctrl_high) { if (ctrl_high) {
g_oled_on = true; g_oled_on = true;
@@ -285,14 +285,25 @@ void display_tick() {
g_oled_on = false; g_oled_on = false;
} }
// fall through to power gating below
}
if (g_oled_on) { if (g_oled_on) {
if (!g_last_oled_on) {
oled_set_power(true); oled_set_power(true);
g_last_page_ms = millis();
}
} else { } else {
if (g_last_oled_on) {
display.clearDisplay();
display.display();
oled_set_power(false); oled_set_power(false);
}
g_last_oled_on = g_oled_on;
g_prev_ctrl_high = ctrl_high; g_prev_ctrl_high = ctrl_high;
return; return;
} }
} g_last_oled_on = g_oled_on;
uint32_t now = millis(); uint32_t now = millis();
uint8_t page_count = g_role == DeviceRole::Sender ? 2 : (1 + g_status_count); uint8_t page_count = g_role == DeviceRole::Sender ? 2 : (1 + g_status_count);