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.

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_del is true the previous screen is automatically deleted when any transition animation finishes.

The following transition types exist:

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

lv_display.h