Reputation: 33
I am using LVGL to run a basic UI on an Arduino ESP32. There are multiple screens built. When the user changes screens, I want to get the name of the screen and store that in the EEPROM so after a power cycle, I can load the last screen by reading the EEPROM. I am confident that I can program that aspect, but I can't seem to figure out how to set a variable to the name of the active screen using lv_scr_act(). Can anyone help?
Upvotes: 0
Views: 1070
Reputation: 229
You can compare the return value from lv_scr_act() to the handle you use for that screen. Presumably have that defined somewhere.
If you are using squareline studio these are defined automatically with the format ui_<screen name>
For example in my code:
lv_obj_t * s = lv_scr_act(); //get active screen
if(s == ui_HOME) do_stuff(); //ui_HOME is the handle of the home screen
Upvotes: 0
Reputation: 74
I don't think you can print/save/get the name of the screen, but maybe you can try to set a custom user_data to the screen e.g the name of the screen:
lv_obj_set_user_data(screen1, "Screen_1");
and get it back with:
lv_obj_get_user_data(screen1);
Upvotes: 2