feat(nuttx): add lv_nuttx_run (#6371)

Co-authored-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
Gabor Kiss-Vamosi
2024-07-04 06:09:43 +02:00
committed by GitHub
parent e1cc1cb2d7
commit c3d4510f84
2 changed files with 52 additions and 0 deletions
+44
View File
@@ -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*/
+8
View File
@@ -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.