Description
How to load screens dynamically when the screen name is stored in a variable
What MCU/Processor/Board and compiler are you using?
ESP32-S3
What LVGL version are you using?
8
We know we can load screens like this with a fixed screen name (“screen1” or “clock” etc…)
lv_scr_load(screen1);
But can we replace the name of the screen, “screen1” with a variable that contains “screen1” or “screen2” or “lastScreen” that all match screens we’ve created?
Something like this:
screen0 = lv_obj_create(NULL); // Create a blank
screen1 = lv_obj_create(NULL); // Create a blank
screen2 = lv_obj_create(NULL); // Create a blank
//etc...
int currentScreenNumber = 0;
int nextScreenNumber = currentScreenNumber++;
char[] = "screen" + nextScreenNumber;
lv_scr_load( screen );