Screens
Screens are simply any Widgets created with NULL passed as parent in the create function. As such, they form the "root" of a Widget Tree.
Screens are simply any Widgets created with NULL passed as parent in the create
function. As such, they form the "root" of a Widget Tree.
Typically the Base Widget is used for this purpose since it has all the features most Screens need. But an Image (lv_image) Widget can also be used to create a image as a wallpaper background for the Widget Tree.
Creating Screens
Screens are created like this:
lv_obj_t * scr1 = lv_obj_create(NULL);Screens are created on the Default display. As typically there is only one displays the screen are created on them automatically.
The resolution of the screen always matches the resolution of the display. Functions
such as lv_obj_set_pos and lv_obj_set_size cannot be used
on screens.
The created Screens can be deleted with lv_obj_delete(scr), but be sure
you do not delete the Active Screen.
Active Screen
While each Display (lv_display) object can have any number of Screen Widgets associated with it, only one of those Screens is considered "Active" at any given time. That Screen is referred to as the Display's "Active Screen". For this reason, only one Screen and its child Widgets will ever be shown on a display at one time.
When each Display (lv_display) object was created, a default screen was created with it and set as its "Active Screen".
To get a pointer to the "Active Screen", call lv_screen_active.
To set a Screen to be the "Active Screen", call lv_screen_load or
lv_screen_load_anim.
Loading Screens
To make a screen visible, it needs to be "loaded".
The simplest way to load a screen is using lv_screen_load(scr1). This
sets scr1 as the Active Screen.
By using lv_screen_load_anim(scr, transition_type, time, delay, auto_del)
screen loading can be performed
- with an optional transition
- if
auto_delistruethe previous screen is automatically deleted when any transition animation finishes.
The following transition types exist:
LV_SCREEN_LOAD_ANIM_NONE: Switch immediately afterdelaymillisecondsLV_SCREEN_LOAD_ANIM_OVER_LEFT,LV_SCREEN_LOAD_ANIM_OVER_RIGHT,LV_SCREEN_LOAD_ANIM_OVER_TOPandLV_SCREEN_LOAD_ANIM_OVER_BOTTOM: Move the new screen over the current towards the given directionLV_SCREEN_LOAD_ANIM_OUT_LEFT,LV_SCREEN_LOAD_ANIM_OUT_RIGHT,LV_SCREEN_LOAD_ANIM_OUT_TOPandLV_SCREEN_LOAD_ANIM_OUT_BOTTOM: Move out the old screen over the current towards the given directionLV_SCREEN_LOAD_ANIM_MOVE_LEFT,LV_SCREEN_LOAD_ANIM_MOVE_RIGHT,LV_SCREEN_LOAD_ANIM_MOVE_TOPandLV_SCREEN_LOAD_ANIM_MOVE_BOTTOM: Move both the current and new screens towards the given directionLV_SCREEN_LOAD_ANIM_FADE_INandLV_SCREEN_LOAD_ANIM_FADE_OUT: Fade the new screen over the old screen, or vice versa
The new Screen will become active (returned by lv_screen_active) when the
animation starts after delay time.
All input device events (e.g. touch, keys, etc) are disabled during the Screen's animation.
API
How is this guide?
Last updated on
Widget Tree
LVGL stores Widgets in a parent-child structure (tree). The root element is the Screen, which has no parent.
Position and Size
Similar to many other parts of LVGL, the concept of setting coordinates is inspired by CSS. LVGL does not implement CSS completely, but a comparable subset is provided (sometimes with minor adjustm...