From 7b04ad6faf3bb70a0c3783e8446275f6f152b61e Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Sun, 14 Jun 2026 21:13:01 -0500 Subject: state_machine: wait one panel-refresh after paint before lighting backlight (33 ms) --- main/state_machine.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'main') diff --git a/main/state_machine.c b/main/state_machine.c index c2b43c8..5e688bc 100644 --- a/main/state_machine.c +++ b/main/state_machine.c @@ -3,6 +3,8 @@ #include "esp_check.h" #include "esp_log.h" #include "esp_timer.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" #include "display.h" #include "local_screens.h" @@ -55,13 +57,15 @@ esp_err_t state_machine_set(viewport_run_state_t target) if (target == VIEWPORT_STATE_AWAKE) { if (display_is_up()) { - // Paint the placeholder BEFORE turning the backlight on so the - // user never glimpses the stale /frame contents from the - // previous wake cycle. Configured devices show "Loading…" until - // Scrypted pushes a /frame; a device with no scrypted URL - // shows the info screen since there's no Scrypted to push. + // Paint the placeholder BEFORE turning the backlight on, then + // wait ~33 ms (two 60 Hz refresh cycles) so the DSI engine + // actually pushes the new framebuffer to the panel before the + // backlight comes up. Without the delay, esp_lcd_panel_draw_bitmap + // returns before the panel has been refreshed and the user sees + // a flash of the previous /frame's contents. if (configured) local_screens_show_loading(); else local_screens_show_info(); + vTaskDelay(pdMS_TO_TICKS(33)); display_wake(); } arm_idle_timer(idle_ms); -- cgit v1.2.3