Search code examples
arduinoarduino-esp32lvgl

Using LVGL how to get the name of the active screen?


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?


Solution

  • 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);