mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
improve rt-thread initialization process (#3345)
This commit is contained in:
parent
cc18518e96
commit
a6cbf3146a
@ -5,40 +5,74 @@
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man The first version
|
||||
* 2021-10-18 Meco Man the first version
|
||||
* 2022-05-10 Meco Man improve rt-thread initialization process
|
||||
*/
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#define DBG_TAG "LVGL"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <lv_port_disp.h>
|
||||
#include <lv_port_indev.h>
|
||||
#ifndef LVGL_THREAD_STACK_SIZE
|
||||
#define LVGL_THREAD_STACK_SIZE 4096
|
||||
#endif /* LVGL_THREAD_STACK_SIZE */
|
||||
|
||||
#ifndef LVGL_THREAD_PRIO
|
||||
#define LVGL_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
|
||||
#endif /* LVGL_THREAD_PRIO */
|
||||
|
||||
extern void lv_port_disp_init(void);
|
||||
extern void lv_port_indev_init(void);
|
||||
extern void lv_user_gui_init(void);
|
||||
|
||||
static struct rt_thread lvgl_thread;
|
||||
static rt_uint8_t lvgl_thread_stack[LVGL_THREAD_STACK_SIZE];
|
||||
|
||||
#if LV_USE_LOG
|
||||
static void lv_rt_log(const char *buf)
|
||||
{
|
||||
LOG_I(buf);
|
||||
}
|
||||
#endif
|
||||
#endif /* LV_USE_LOG */
|
||||
|
||||
static int lv_port_init(void)
|
||||
static void lvgl_thread_entry(void *parameter)
|
||||
{
|
||||
#if LV_USE_LOG
|
||||
lv_log_register_print_cb(lv_rt_log);
|
||||
#endif
|
||||
|
||||
#endif /* LV_USE_LOG */
|
||||
lv_init();
|
||||
|
||||
lv_port_disp_init();
|
||||
lv_port_indev_init();
|
||||
lv_user_gui_init();
|
||||
|
||||
/* handle the tasks of LVGL */
|
||||
while(1)
|
||||
{
|
||||
lv_task_handler();
|
||||
rt_thread_mdelay(10);
|
||||
}
|
||||
}
|
||||
|
||||
static int lvgl_thread_init(void)
|
||||
{
|
||||
rt_err_t err;
|
||||
|
||||
err = rt_thread_init(&lvgl_thread, "LVGL", lvgl_thread_entry, RT_NULL,
|
||||
&lvgl_thread_stack[0], sizeof(lvgl_thread_stack), LVGL_THREAD_PRIO, 0);
|
||||
if(err != RT_EOK)
|
||||
{
|
||||
LOG_E("Failed to create LVGL thread");
|
||||
return -1;
|
||||
}
|
||||
rt_thread_startup(&lvgl_thread);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(lv_port_init);
|
||||
INIT_ENV_EXPORT(lvgl_thread_init);
|
||||
|
||||
#endif /*__RTTHREAD__*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user