Sure, it is possible to do in the exported code. One way is using the ESP32/Arduino IO-library to request the state of the input (e.g. a button/switch on GPIO) and you update the image/icon with lv_img_set_src() directly based on the input-value, in the main loop beside lv_task_handler()/lv_timer_handler(). Not always, just update it at startup and when the input-state/value changes. (An alternative way to change the image, is preparing more images in the UI hidden by default and unhiding the selected one only.)
Thank you very much for your answer, @Hermit, but I still have some doubts.
I’ve generated a UI using squareline and set some images to be shown. They appear on the code as image_name.c included on ui_Screen1.c
Considering the first sugestion you made about using the loop function, how could I do that? Must I desconsider or delete the info at ui_Screen1.c and call function (lv_img_set_scr()) on loop function?
For the 1st solution you need to have the .c files for all the images. They can be created by SquareLine Studio automatically in the exported ui folder if you place them on an unused screen or hidden on the used screen, or you check ‘Force export all images’ in Project Settings, so they’re not readily shown but still are used/referenced in the design-project. (LVGL online image converter might be another option. You can even use binary/png ‘asset’ versions of the images without the hassles of conversion to C if you like.)
(Yet another option could be placing the images side-by-side as parts of a single main image bigger than its display-size on the screen, and using lv_img_set_offset_x(img, x_ofs) to ‘scroll’ to a sub-image to be shown.)
With either 1st or 2nd (or 3rd) option, the change of image can simply be done in the main loop beside the lv_timer_handler() function by something like: if ( GPIOxx_changed() || first_screen_update() ) lv_img_set_src( ui_Image1, GPIOxx_state()? &ui_img_xxxxx_png : &ui_img_xxxxx_png )
Or if you have a complete system of inputs and images it might be better to put them in a separate updater function and call that instead periodically beside lv_timer_handler(), and get the image-pointers from arrays instead of using conditional statements to decide which one to show.
In case you don’t like the idea of editing the main loop or you’d like different update-period, you can put your image-updater code in an LVGL timer’s callback function, set up by something like lv_timer_create( update_images, IMAGE_CHANGE_TIMER_PERIOD, NULL). Then in this example update_images() callback-function you can do the IO-change checking and image-udating tasks.
(Hardware inputs could even be coded and registered as ‘indev’ in the HAL-init for LVGL and in that case you could assign LVGL callback-functions to them but that’s another story I won’t go into details about here, as that’s probably not what you want. Its callbacks would do something similar in the background what’s proposed above, but could add LVGL navigation capabilities on top.)