屏幕的初始化过程-LVGL
- 1、
lv_init
:初始化屏幕链表
_lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t));
- 2、
lv_win32_init
:注册显示器到链表
static lv_disp_drv_t display_driver;
lv_disp_drv_init(&display_driver);
display_driver.hor_res = hor_res;
display_driver.ver_res = ver_res;
display_driver.flush_cb = lv_win32_display_driver_flush_callback;
display_driver.draw_buf = &display_buffer;
display_driver.rounder_cb = lv_win32_display_driver_rounder_callback;
g_display = lv_disp_drv_register(&display_driver);
-
3、
lv_disp_drv_register
:创建屏幕创建具有三层结构的屏幕,分别为用户层、顶层和系统层。根据
lv_obj_create(NULL)
的参数NULL
可知,屏幕是没有父类的基础对象
disp->act_scr = lv_obj_create(NULL); /*Create a default screen on the display*/
disp->top_layer = lv_obj_create(NULL); /*Create top layer on the display*/
disp->sys_layer = lv_obj_create(NULL); /*Create sys layer on the display*/
- 4、
lv_obj_create
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
- 5、
lv_obj_class_create_obj
:创建屏幕的形状
/*Create a screen*/
if(parent == NULL) {
...
/*Set coordinates to full screen size*/
obj->coords.x1 = 0;
obj->coords.y1 = 0;
obj->coords.x2 = lv_disp_get_hor_res(NULL) - 1;
obj->coords.y2 = lv_disp_get_ver_res(NULL) - 1;
}