Skip to content

Commit b34bf4d

Browse files
committed
modules: lvgl: expose the lvgl workqueue to the user application
allowing to schedule a delayed LVGL work for an amount of miliseconds Signed-off-by: Felipe Neves <[email protected]>
1 parent bacbb3a commit b34bf4d

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

modules/lvgl/include/lvgl_zephyr.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ extern "C" {
3232
*/
3333
int lvgl_init(void);
3434

35+
#ifdef CONFIG_LV_Z_RUN_LVGL_ON_WORKQUEUE
36+
/**
37+
* @brief Schedule an LVGL delayed by amount of miliseconds
38+
*
39+
* This function submit a delayed job to the LVGL internal's
40+
* workqueue, the job will be delayed by an amount of miliseconds
41+
* selected by the user
42+
*
43+
* @return 0 on success, negative errno code on failure
44+
*/
45+
int lvgl_schedule_job(int32_t ms);
46+
47+
#endif /* CONFIG_LV_Z_RUN_LVGL_ON_WORKQUEUE */
48+
3549
#ifdef __cplusplus
3650
}
3751
#endif

modules/lvgl/lvgl.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static int lvgl_allocate_rendering_buffers(lv_display_t *display)
221221

222222
#ifdef CONFIG_LV_Z_RUN_LVGL_ON_WORKQUEUE
223223

224-
K_THREAD_STACK_DEFINE(lvgl_workqueue_stack, CONFIG_LV_Z_LVGL_WORKQUEUE_STACK_SIZE);
224+
static K_THREAD_STACK_DEFINE(lvgl_workqueue_stack, CONFIG_LV_Z_LVGL_WORKQUEUE_STACK_SIZE);
225225
static struct k_work_q lvgl_workqueue;
226226

227227
static void lvgl_timer_handler_work(struct k_work *work)
@@ -236,7 +236,7 @@ static void lvgl_timer_handler_work(struct k_work *work)
236236

237237
k_work_schedule_for_queue(&lvgl_workqueue, dwork, K_MSEC(wait_time));
238238
}
239-
K_WORK_DEFINE(lvgl_work, lvgl_timer_handler_work);
239+
static K_WORK_DEFINE(lvgl_work, lvgl_timer_handler_work);
240240

241241
#endif /* CONFIG_LV_Z_RUN_LVGL_ON_WORKQUEUE */
242242

@@ -359,6 +359,16 @@ int lvgl_init(void)
359359
return 0;
360360
}
361361

362+
#ifdef CONFIG_LV_Z_RUN_LVGL_ON_WORKQUEUE
363+
int lvgl_schedule_job(int32_t ms)
364+
{
365+
struct k_work_delayable *dwork = k_work_delayable_from_work(&lvgl_work);
366+
367+
return k_work_schedule_for_queue(&lvgl_workqueue, dwork, K_MSEC(ms));
368+
}
369+
370+
#endif
371+
362372
#ifdef CONFIG_LV_Z_AUTO_INIT
363373
SYS_INIT(lvgl_init, APPLICATION, CONFIG_LV_Z_INIT_PRIORITY);
364374
#endif /* CONFIG_LV_Z_AUTO_INIT */

0 commit comments

Comments
 (0)