Skip to content

[LVGL] Add a way to control when screen is created #706

@mvladic

Description

@mvladic

By default, all screens (i.e. pages) are created at startup (during ui_init() call) and kept in memory at all times. In case there is not enough memory for this mode of operation, it is possible to manually set when a screen is created and when it is deleted during execution. First, the following setting should be enabled:

Image

When this setting is enabled, it is possible to decide for each screen whether it will be created at the startup, and also whether it will be deleted on screen unload event:

Image

Change screen will always automatically create a screen if not already created.

Also, there are additional LVGL actions to manually create and delete screen, and also find out whether is screen created:

Image

This is also available from the code:

void create_screen_by_id(enum ScreensEnum screenId);
void delete_screen_by_id(enum ScreensEnum screenId);

To find out whether is screen created from the code, you can check objects.<screen_name> - it should be non zero.

Some caveats:

  • When screen is deleted then its flow state is also deleted, for example all local variables and all Watch actions. So, if you need to remember the state of some variable then you should use global instead of local variable. If you need to have some Watch action that runs all the time then you can create a page without any widget but with the Watch action and this page should be created at the start.
  • If, in your flow, widget in one screen is changed with the LVGL action from another screen then care must be taken to only do that if screen has been created.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions