First of all congratulations to the people behind this awesome piece of software. The more I get into it, the more I admire the elegance of the code.
I am creating a project with more than 25 screens. I am not allowed to share code of details because of a NDA. What I want to achieve is build upon the fragment ability provided by lvgl. My goal is to have an infobar (wifi icon, battery icon, gps icon) across all screens. The screens are exported by Squeareline Studio 1.4 so the files follow SLS’ code organization.
What MCU/Processor/Board and compiler are you using?
ESP32S3 using Arduino framework with PlatformIO
What LVGL version are you using?
8.3.11
What do you want to achieve?
Use Fragment to have an infobar at the top across all screens
What have you tried so far?
Tried to build upon the examples provided in the documentation but I didn’t make it.
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
/*You code here*/
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.
Thank you Marian_M. I have being reading the forum a lot and I see that you contribute to many of the solutions that come up.
Now, to your reply, I don’t get it how to organize the screens so to fit in the fragment. Can you please provide some more info? As I wrote in my initial post, my code is exported from SLS, but I don’t have a problem to change the file hierarchy in order to achieve my goal.
For SLS is better use SLS forum , but for your idea is SLS ok. Place bar objects inside one panel. For exampe ui_PanelTop.
Create event on screen load start and place
lv_obj_set_parent(ui_PanelTop, Screenx);
thats all folks. One object jump over any screen on same place.
I see. So your suggestion is have a global object (ui_PanelTop) that is simply applied to the screen that get’s loaded. I never thought it like that… Thank you, I will try it and report back.
I am using temporary screens because there are many of them (more than 20)… It seems I will have to create a lot of boilerplate code but I will give a try.
Another option is to create an object on the top layer.
Something like
lv_obj_t* header = lv_obj_create(lv_layer_top());
This object will not be deleted when calling lv_screen_load() for example, because it is a child of the top layer which is basically just another screen.
Thank you very much. I wasn’t aware of this LVGL hierarchy… It’s an awesome piece of software! It sound’s very natural and straightforward. I will definitely try it and report back.
Tinus’ proposal worked like a charm without a lot of tweaking on my source files! To have the wifi icon displayed, I simply declared in ui.h an
lv_obj_t* ui_wifi_connected;
and in ui.c I went and created it inside ui_init() after the first screen is loaded, by using the lv_layer_top() as it’s parent.
To test it, I emulated the wifi connection and disconnection by firing the callback every 2 seconds passing false and true respectively as userdata. The result is consistent across all my screens (more than 20).
Many thanks Tinus!
Yes , but this is outside SLS and overwrited by next gen ui…
Maybe combination is best create panel in SLS and on first screen change parent to layertop…