Simulator - change screen after delay


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

Codeblocks simulator

What LVGL version are you using?


What do you want to achieve?

I want to change screens after some period of time.

What have you tried so far?

I tried use delay function, usleep.

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.

Hi, probably really stupid question, but does anybody know how to change screens after some time in simulator?

I would use delay function or custom function with millis(), but I can not figure out what I have to use in simulator. I searched forum, but did not find solution similar to what I want to do.

I would like to achieve something like this:

startScreen(); // first screen after boot
delay(2000); // show this screen for 2 seconds
mainScreen(); //second screen

Many thanks for help.

You should create a oneshot lv_task and switch screens inside it. Using a delay function generally doesn’t work with LVGL because it expects that all functions are nonblocking.

1 Like

Disregard my comment just seen embeddedts response.

I’ve had this issue as well. When using lvgl platform io simulator, vscode(using windows.) I didn’t solve the in a simulator however I had the same issue when running my simulation on the raspberry pi and solved this issue.

Ill explain what I think is going on. This may help.
So for platform io the main loop consists of:





My demo_create() is the gui.
When you inspect the definition hal loop(); there is a while loop which consists of a timer.
A suggestion maybe try to reconfigure the hal loop function and place your screen with the timer code in there.

I’ll try to provide a more detailed post when I’m free. Hope this helps a little bit. If you have already solved the issue please can you let me know how you did it.

ONCE TASK Should be an excellent solution, for example:

lv_task_t * load_screen2_task_handle;
void load_screen2_task_cb(lv_obj_t* obj, lv_event_t event)
void screen1_create(void)

I often use this method to close the prompt window automatically.

1 Like