How can I specify the first screen programmatically?

What do you want to achieve?

On the first boot of my product, I’d like to send the user to a “language selection screen”, without loading my usual “home screen”. After the user has chosen a language, I want to send them to the “home screen”

What have you tried so far?

My current workaround is:

ui_init();
if(no language set){
    _ui_screen_change(&ui_SystemLanguageChooser, LV_SCR_LOAD_ANIM_NONE, 0, 0, &ui_SystemLanguageChooser_screen_init);
}

…but this still triggers all of my “home screen” on-load processing, which I would prefer to defer until the language selection is completed.

Others

  • SquareLine Studio version: 1.4.1
  • Operating system: Windows 11
  • Target hardware: ESP32-S3 custom board

Select empty screen as start…

1 Like

I’d prefer to not have and load an unused screen either.

Hi Richard!

The reason is that the ui_init() function starts the home screen, and only afterward do you check the language_set variable.
Idea a.:
In Squareline Studio, the SystemLanguageChooser screen must be placed above the home screen, then the SystemLanguageChooser screen is loaded first by ui_init(), after selecting the language, you can request the screen switch to the home screen with one button press.
Idea b.:
You can find the ui_init() function in the bottom lines of ui/ui.c. You can see what’s going on there. If you paste these into your code except for 1 line (lv_disp_load_scr( ui_home )) , and then you call the SystemLanguageChooser screen as you did, your routine should work fine.
example:
ui_init() function in ui.c

void ui_init(void)
{
    lv_disp_t * dispp = lv_disp_get_default();
    lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
                                               false, LV_FONT_DEFAULT);
    lv_disp_set_theme(dispp, theme);
    ui_home_screen_init();
    ui_second_screen_init();
    ui_SystemLanguageChooser_screen_init();
    ui____initial_actions0 = lv_obj_create(NULL);
    lv_disp_load_scr(ui_home);
}

your code in this case:

    lv_disp_t * dispp = lv_disp_get_default();
    lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
                                               false, LV_FONT_DEFAULT);
    lv_disp_set_theme(dispp, theme);
    ui_home_screen_init();
    ui_second_screen_init();
    ui_SystemLanguageChooser_screen_init();
    ui____initial_actions0 = lv_obj_create(NULL);
    //lv_disp_load_scr(ui_home);
    if(no language set){
        _ui_screen_change(&ui_SystemLanguageChooser, LV_SCR_LOAD_ANIM_NONE, 0, 0, &ui_SystemLanguageChooser_screen_init);
    //instead of the previous line, you can also use this one without the animation option:
    //lv_disp_load_scr(ui_SystemLanguageChooser);
    }

Don’t forget to request a screen change to the home screen in the SystemLanguageChooser screen when the selection is done.You can set this in Squarline Studio as a clicked button event.
the program is in LVGL version 8.3.11

Have a nice job
Viti

Thanks Viti, that works, but it creates a maintenance dependency - anytime my UI designer updates SquareLine, I may have to synchronize the content of ui_init with my copy of what it does.

I think what I’d like to request is for SquareLine to allow the caller to specify a specific screen to ui_init().

Or maybe ui_init() could stop calling lv_disp_load_scr(), but this would be more work for anyone not needing to specify the first screen.

Yes, this is a possibility for error and it is not convenient

The ui_init() function always starts the screen that is directly below the “Initial actions” screen in the “Screens” field of Squareline Studio
You can perform a “drag & drop” operation with the screen names. You have to drag the one you want to start first directly under the “Initial actions” screen.
an example:


In this case on the left, the “Home” screen is loaded first, and on the right, the “SystemLanguageChooser” screen. Your UI designer can set this

Cheers,
Viti