diff --git a/src/drivers/nuttx/lv_nuttx_entry.c b/src/drivers/nuttx/lv_nuttx_entry.c index cb5505e546..4a91666040 100644 --- a/src/drivers/nuttx/lv_nuttx_entry.c +++ b/src/drivers/nuttx/lv_nuttx_entry.c @@ -47,6 +47,10 @@ static uint32_t millis(void); #endif static void check_stack_size(void); +#ifdef CONFIG_LV_USE_NUTTX_LIBUV + static void lv_nuttx_uv_loop(lv_nuttx_result_t * result); +#endif + /********************** * STATIC VARIABLES **********************/ @@ -169,6 +173,22 @@ void lv_nuttx_init(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result) #endif } +void lv_nuttx_run(lv_nuttx_result_t * result) +{ +#ifdef CONFIG_LV_USE_NUTTX_LIBUV + lv_nuttx_uv_loop(&ui_loop, result); +#else + while(1) { + uint32_t idle; + idle = lv_timer_handler(); + + /* Minimum sleep of 1ms */ + idle = idle ? idle : 1; + usleep(idle * 1000); + } +#endif +} + #ifdef CONFIG_SCHED_CPULOAD uint32_t lv_nuttx_get_idle(void) @@ -246,6 +266,29 @@ static void syslog_print(lv_log_level_t level, const char * buf) } #endif +#ifdef CONFIG_LV_USE_NUTTX_LIBUV +static void lv_nuttx_uv_loop(lv_nuttx_result_t * result) +{ + uv_loop_t loop; + lv_nuttx_uv_t uv_info; + void * data; + + uv_loop_init(&loop); + + lv_memzero(&uv_info, sizeof(uv_info)); + uv_info.loop = &loop; + uv_info.disp = result->disp; + uv_info.indev = result->indev; +#ifdef CONFIG_UINPUT_TOUCH + uv_info.uindev = result->utouch_indev; +#endif + + data = lv_nuttx_uv_init(&uv_info); + uv_run(loop, UV_RUN_DEFAULT); + lv_nuttx_uv_deinit(&data); +} +#endif + static void check_stack_size(void) { pthread_t tid = pthread_self(); @@ -259,3 +302,4 @@ static void check_stack_size(void) } #endif /*LV_USE_NUTTX*/ + diff --git a/src/drivers/nuttx/lv_nuttx_entry.h b/src/drivers/nuttx/lv_nuttx_entry.h index 40aefad44c..049e741e5f 100644 --- a/src/drivers/nuttx/lv_nuttx_entry.h +++ b/src/drivers/nuttx/lv_nuttx_entry.h @@ -85,6 +85,14 @@ void lv_nuttx_init_custom(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result void lv_nuttx_deinit_custom(lv_nuttx_result_t * result); #endif /* LV_USE_NUTTX_CUSTOM_INIT */ +/** + * Call `lv_timer_handler()` (LVGL's super loop) in an endless loop. + * If LV_USE_NUTTX_LIBUV is enabled an UV timer will be created, + * else `lv_timer_handler()` will be called in a loop with some sleep. + * @param result pointer to a variable initialized by `lv_nuttx_init()` or `lv_nuttx_init_custom()` + */ +void lv_nuttx_run(lv_nuttx_result_t * result); + /** * Get the idle percentage of the system. * @return The idle percentage of the system.