How to structure a complex application

Hello!

Description

I’m using LVGL 8.3 in a Linux embedded device. The LVGL port for this device was done by the manufacturer and we just get a library and link to it.

I’m having the following problem: this is a large application (~1MB binary) and there are lots of “screens” I have to handle (the code was already written when I came and I’m just updating it). By screen, I mean the same thing as an old Delphi or VB6 form. Well, I added some new screens and when I just enter these new screens the application crashes. It does not crash when I enter the other screens (the ones that were already there)

Important info

  • I have only one display which is properly setup and run;

What MCU/Processor/Board and compiler are you using?

Custom LLVM-based toolchain. The manufacturer provides the toolchain.

What LVGL version are you using?

8.3

What do you want to achieve?

I need to be able to load/unload screens without crashing the application.

Here is what I think it would be a better approach: every time I need to show a new form, I will have a static C variable which will hold the screen object. In the first time I call the form show function I will create all widgets, GUI objects and setup event handlers. In the subsequent calls, I will just call `lv_scr_load with my screen object and that’s it. Is this a good approach?

What have you tried so far?

The way they are implemented in this application is the following: everything is a child of the mainScreen, including the displayScreen which is cleaned, and objects are added to it everytime I have to show a different form. I’m not sure why this is done the way it is. displayScreen is deleted and recreated everytime I need to show a new form.

So the question is: what is the proper way to handle screens?

yeah you can create multiple screens and keep them resident but not displaying. you can also take chunks of a GUI and do the same thing by setting the parent to None for the bits you want to remove and then add later. This way you want have the constant creation and deletion which causes memory fragmentation. That could be what is causing your crashes.

I always try to set everything up at startup so there is less memory being used in a dynamic fashion. So If I know something is going to be used pretty often it gets created at startup and not on demand.