From ee54632140538f7e9b04a02c849ee6b664290a77 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Thu, 22 Sep 2022 19:37:56 +0000 Subject: [PATCH] fix(display): Tweak init state to avoid race. * Move "initialized" state early, to avoid race condition causing listener events to get lost during startup sequence. --- app/src/display/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/display/main.c b/app/src/display/main.c index 9de0ad7f..8a70cef2 100644 --- a/app/src/display/main.c +++ b/app/src/display/main.c @@ -73,6 +73,8 @@ static void start_display_updates() { k_timer_start(&display_timer, K_MSEC(TICK_MS), K_MSEC(TICK_MS)); } +#if IS_ENABLED(CONFIG_ZMK_DISPLAY_BLANK_ON_IDLE) + static void stop_display_updates() { if (display == NULL) { return; @@ -83,6 +85,8 @@ static void stop_display_updates() { k_timer_stop(&display_timer); } +#endif + int zmk_display_is_initialized() { return initialized; } void initialize_display(struct k_work *work) { @@ -94,6 +98,8 @@ void initialize_display(struct k_work *work) { return; } + initialized = true; + screen = zmk_display_status_screen(); if (screen == NULL) { @@ -104,8 +110,6 @@ void initialize_display(struct k_work *work) { lv_scr_load(screen); start_display_updates(); - - initialized = true; } K_WORK_DEFINE(init_work, initialize_display);