mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-01 16:58:33 +08:00
feat(nuttx): add lv_nuttx_run (#6371)
Co-authored-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e1cc1cb2d7
commit
c3d4510f84
@@ -47,6 +47,10 @@ static uint32_t millis(void);
|
|||||||
#endif
|
#endif
|
||||||
static void check_stack_size(void);
|
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
|
* STATIC VARIABLES
|
||||||
**********************/
|
**********************/
|
||||||
@@ -169,6 +173,22 @@ void lv_nuttx_init(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result)
|
|||||||
#endif
|
#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
|
#ifdef CONFIG_SCHED_CPULOAD
|
||||||
|
|
||||||
uint32_t lv_nuttx_get_idle(void)
|
uint32_t lv_nuttx_get_idle(void)
|
||||||
@@ -246,6 +266,29 @@ static void syslog_print(lv_log_level_t level, const char * buf)
|
|||||||
}
|
}
|
||||||
#endif
|
#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)
|
static void check_stack_size(void)
|
||||||
{
|
{
|
||||||
pthread_t tid = pthread_self();
|
pthread_t tid = pthread_self();
|
||||||
@@ -259,3 +302,4 @@ static void check_stack_size(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /*LV_USE_NUTTX*/
|
#endif /*LV_USE_NUTTX*/
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
void lv_nuttx_deinit_custom(lv_nuttx_result_t * result);
|
||||||
#endif /* LV_USE_NUTTX_CUSTOM_INIT */
|
#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.
|
* Get the idle percentage of the system.
|
||||||
* @return The idle percentage of the system.
|
* @return The idle percentage of the system.
|
||||||
|
|||||||
Reference in New Issue
Block a user