@ -4,6 +4,7 @@
* SPDX - License - Identifier : MIT
* SPDX - License - Identifier : MIT
*/
*/
# include <kernel.h>
# include <init.h>
# include <init.h>
# include <device.h>
# include <device.h>
# include <devicetree.h>
# include <devicetree.h>
@ -32,19 +33,41 @@ void display_tick_cb(struct k_work *work) { lv_task_handler(); }
K_WORK_DEFINE ( display_tick_work , display_tick_cb ) ;
K_WORK_DEFINE ( display_tick_work , display_tick_cb ) ;
# if IS_ENABLED(CONFIG_ZMK_DISPLAY_WORK_QUEUE_DEDICATED)
K_THREAD_STACK_DEFINE ( display_work_stack_area , CONFIG_ZMK_DISPLAY_DEDICATED_THREAD_STACK_SIZE ) ;
static struct k_work_q display_work_q ;
# endif
struct k_work_q * zmk_display_work_q ( ) {
# if IS_ENABLED(CONFIG_ZMK_DISPLAY_WORK_QUEUE_DEDICATED)
return & display_work_q ;
# else
return & k_sys_work_q ;
# endif
}
void display_timer_cb ( ) {
void display_timer_cb ( ) {
lv_tick_inc ( TICK_MS ) ;
lv_tick_inc ( TICK_MS ) ;
k_work_submit ( & display_tick_work ) ;
k_work_submit_to_queue ( zmk_display_work_q ( ) , & display_tick_work ) ;
}
}
void blank_display_cb ( struct k_work * work ) { display_blanking_on ( display ) ; }
void unblank_display_cb ( struct k_work * work ) { display_blanking_off ( display ) ; }
K_TIMER_DEFINE ( display_timer , display_timer_cb , NULL ) ;
K_TIMER_DEFINE ( display_timer , display_timer_cb , NULL ) ;
K_WORK_DEFINE ( blank_display_work , blank_display_cb ) ;
K_WORK_DEFINE ( unblank_display_work , unblank_display_cb ) ;
static void start_display_updates ( ) {
static void start_display_updates ( ) {
if ( display = = NULL ) {
if ( display = = NULL ) {
return ;
return ;
}
}
display_blanking_off ( display ) ;
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 ) ) ;
k_timer_start ( & display_timer , K_MSEC ( TICK_MS ) , K_MSEC ( TICK_MS ) ) ;
}
}
@ -54,7 +77,7 @@ static void stop_display_updates() {
return ;
return ;
}
}
display_blanking_on ( display ) ;
k_work_submit_to_queue ( zmk_display_work_q ( ) , & blank_display_work ) ;
k_timer_stop ( & display_timer ) ;
k_timer_stop ( & display_timer ) ;
}
}
@ -68,6 +91,12 @@ int zmk_display_init() {
return - EINVAL ;
return - EINVAL ;
}
}
# if IS_ENABLED(CONFIG_ZMK_DISPLAY_WORK_QUEUE_DEDICATED)
k_work_q_start ( & display_work_q , display_work_stack_area ,
K_THREAD_STACK_SIZEOF ( display_work_stack_area ) ,
CONFIG_ZMK_DISPLAY_DEDICATED_THREAD_PRIORITY ) ;
# endif
screen = zmk_display_status_screen ( ) ;
screen = zmk_display_status_screen ( ) ;
if ( screen = = NULL ) {
if ( screen = = NULL ) {