diff --git a/app/src/display/Kconfig b/app/src/display/Kconfig index c0753358..97a6030e 100644 --- a/app/src/display/Kconfig +++ b/app/src/display/Kconfig @@ -75,6 +75,13 @@ endchoice endif # ZMK_DISPLAY_STATUS_SCREEN_BUILT_IN +config ZMK_DISPLAY_FULL_REFRESH_PERIOD + int "(Optional) Period to issue a full refresh to the display (in seconds)" + default 0 + help + Period in seconds for how often to completely refresh/redraw the whole screen. + Most useful for e-ink/EPD displays that require occasional full redraws. + rsource "widgets/Kconfig" endif diff --git a/app/src/display/main.c b/app/src/display/main.c index 8a70cef2..2339c600 100644 --- a/app/src/display/main.c +++ b/app/src/display/main.c @@ -50,6 +50,17 @@ struct k_work_q *zmk_display_work_q() { #endif } +#if CONFIG_ZMK_DISPLAY_FULL_REFRESH_PERIOD > 0 +void full_refresh_work_cb(struct k_work *work) { lv_obj_invalidate(lv_scr_act()); } + +K_WORK_DEFINE(full_refresh_work, full_refresh_work_cb); + +void full_refresh_timer_cb() { k_work_submit_to_queue(zmk_display_work_q(), &full_refresh_work); } + +K_TIMER_DEFINE(full_refresh_timer, full_refresh_timer_cb, NULL); + +#endif + void display_timer_cb() { lv_tick_inc(TICK_MS); k_work_submit_to_queue(zmk_display_work_q(), &display_tick_work); @@ -71,6 +82,10 @@ static void start_display_updates() { k_work_submit_to_queue(zmk_display_work_q(), &unblank_display_work); k_timer_start(&display_timer, K_MSEC(TICK_MS), K_MSEC(TICK_MS)); +#if CONFIG_ZMK_DISPLAY_FULL_REFRESH_PERIOD > 0 + k_timer_start(&full_refresh_timer, K_SECONDS(CONFIG_ZMK_DISPLAY_FULL_REFRESH_PERIOD), + K_SECONDS(CONFIG_ZMK_DISPLAY_FULL_REFRESH_PERIOD)); +#endif } #if IS_ENABLED(CONFIG_ZMK_DISPLAY_BLANK_ON_IDLE) @@ -83,6 +98,9 @@ static void stop_display_updates() { k_work_submit_to_queue(zmk_display_work_q(), &blank_display_work); k_timer_stop(&display_timer); +#if CONFIG_ZMK_DISPLAY_FULL_REFRESH_PERIOD > 0 + k_timer_stop(&full_refresh_timer); +#endif } #endif