diff --git a/pkg/lvgl/contrib/lvgl.c b/pkg/lvgl/contrib/lvgl.c index 2245b7f9b3..90e1a2f454 100644 --- a/pkg/lvgl/contrib/lvgl.c +++ b/pkg/lvgl/contrib/lvgl.c @@ -30,10 +30,6 @@ #include "screen_dev.h" -#ifndef LVGL_TASK_THREAD_PRIO -#define LVGL_TASK_THREAD_PRIO (THREAD_PRIORITY_MAIN + 1) -#endif - #ifndef LVGL_COLOR_BUF_SIZE #define LVGL_COLOR_BUF_SIZE (LV_HOR_RES_MAX * 5) #endif @@ -50,7 +46,6 @@ #define LVGL_THREAD_FLAG (1 << 7) #endif -static char _task_thread_stack[THREAD_STACKSIZE_LARGE]; static kernel_pid_t _task_thread_pid; static lv_disp_buf_t disp_buf; @@ -59,30 +54,6 @@ static lv_color_t buf[LVGL_COLOR_BUF_SIZE]; static screen_dev_t *_screen_dev = NULL; -static void *_task_thread(void *arg) -{ - (void)arg; - - while (1) { - /* Normal operation (no sleep) in < CONFIG_LVGL_INACTIVITY_PERIOD_MS msec - inactivity */ - if (lv_disp_get_inactive_time(NULL) < CONFIG_LVGL_INACTIVITY_PERIOD_MS) { - lv_task_handler(); - } - else { - /* Block after LVGL_ACTIVITY_PERIOD msec inactivity */ - thread_flags_wait_one(LVGL_THREAD_FLAG); - - /* trigger an activity so the task handler is called on the next loop */ - lv_disp_trig_activity(NULL); - } - - xtimer_usleep(CONFIG_LVGL_TASK_HANDLER_DELAY_US); - } - - return NULL; -} - static void _disp_map(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) { if (!_screen_dev->display) { @@ -154,15 +125,30 @@ void lvgl_init(screen_dev_t *screen_dev) lv_indev_drv_register(&indev_drv); } #endif - - lv_task_handler(); } -void lvgl_start(void) +void lvgl_run(void) { - _task_thread_pid = thread_create(_task_thread_stack, sizeof(_task_thread_stack), - LVGL_TASK_THREAD_PRIO, THREAD_CREATE_STACKTEST, - _task_thread, NULL, "_task_thread"); + _task_thread_pid = thread_getpid(); + + lv_task_handler(); + + while (1) { + /* Normal operation (no sleep) in < CONFIG_LVGL_INACTIVITY_PERIOD_MS msec + inactivity */ + if (lv_disp_get_inactive_time(NULL) < CONFIG_LVGL_INACTIVITY_PERIOD_MS) { + lv_task_handler(); + } + else { + /* Block after LVGL_ACTIVITY_PERIOD msec inactivity */ + thread_flags_wait_one(LVGL_THREAD_FLAG); + + /* trigger an activity so the task handler is called on the next loop */ + lv_disp_trig_activity(NULL); + } + + xtimer_usleep(CONFIG_LVGL_TASK_HANDLER_DELAY_US); + } } void lvgl_wakeup(void) diff --git a/pkg/lvgl/include/lvgl_riot.h b/pkg/lvgl/include/lvgl_riot.h index 7c16cb7879..21203d9a3e 100644 --- a/pkg/lvgl/include/lvgl_riot.h +++ b/pkg/lvgl/include/lvgl_riot.h @@ -33,9 +33,9 @@ extern "C" { void lvgl_init(screen_dev_t *screen_dev); /** - * Start the lvgl task handler background thread + * Run the lvgl task handler */ -void lvgl_start(void); +void lvgl_run(void); /** * @brief Wakeup lvgl when inactive