Description
If I create a new screen, then it will have the size LV_HOR_RES_MAX*LV_VER_RES_MAX. I would assume it has the size of the particular display, which it is created for.
What MCU/Processor/Board and compiler are you using?
Linux Simulator (SDL)
What LVGL version are you using?
7.11
What do you want to achieve?
I would expect, when I create a new screen, that it has the dimensions of the used display initially. (Seems to be synchronisation error after setting the default display).
What have you tried so far?
Just create a screen after setting the default display, but the display is apparently NULL in lv_disp_get_hor_res(lv_disp_t * disp).
Is there a way to prevent it being NULL in lv_disp_get_hor_res ?
Code to reproduce
client code :
lv_disp_set_default(disp);
lv_obj_t* s = lv_obj_create(NULL,NULL);
lv_coord_t screen_width = lv_obj_get_width(s);
lv_coord_t screen_height = lv_obj_get_height(s);
cout << screen_width << endl;
cout << screen_height << endl;
lv_hal_disp.c
lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp)
{
if(disp == NULL) disp = lv_disp_get_default();
if(disp == NULL)
return LV_HOR_RES_MAX;
else {
switch(disp->driver.rotated) {
case LV_DISP_ROT_90:
case LV_DISP_ROT_270:
return disp->driver.ver_res;
default:
return disp->driver.hor_res;
}
}
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.