How to add a custom Screen to a existing project?

What do you want to achieve?

I want to implement a custom lvgl screens into my already existing project. I added the relevant code to the files, the custom screens do show, however some of my buttons and some of the original screens don’t work anymore. What docs do i have to adapt to add screens manually?

What have you tried so far?

I added the new screen to the CMakeLists.txt, ui.c, ui_event.c, ui.h and ui_events file. Also i added the custom screens like ui_customscreenfile1.c to the screen folder.

Screenshot or video


  • SquareLine Studio version:
  • Operating system:
  • Target hardware:
    esp32 wroom

Why this complcated way. Add empty screen in designer and place code to fill it in events…

I have already implemented a lot of custom changes to my existing squareline code and its screens. Also i never used the implement feature you mentioned and i feel like there is only some small issue in the event handling that i didn’t think about.

Squareline generated code is designed to NO EDIT , except ui_events file .

Some functionalities, like constantly updating Values on Screens or implementing other code dependable stuff, can’t be realized without modification. While I understand that it’s not considered best practice, it’s also not really the question I was asking.

Creating custom screens shouldn’t render your original screens/widgets useless by default. If you use temporary screens this can complicate that. Essentially you need to check LVGL docs for your custom code but you can check the patterns of SquareLine Studio exported code as well for help. For a screen to work, yes, you need to create a .c file in screens folder, and roughly the steps you described. In ui.c you need to initialize those screens just like the others, and you can change screens either by direct LVGL function or by the ui_helpers function for more safety (especially for temporary screens). You should check if there aren’t any widget-name/pointer clashes with the original export. Not sure, but maybe you need to check the memory settings (LV_MEM_CUSTOM, LV_MEM_SIZE in lv_conf.h), because adding new screens needs more memory and maybe that is the source of your problem.