Call-back after screen transition animation has finished


How do I register a callback to execute once a transition between two screens has completed?

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

SDL2 simulator via CMake Xcode project generator.

What LVGL version are you using?

Github master branch, retrieved yesterday.

What do you want to achieve?

I am executing an animated transition between two screens, using:

lv_scr_load_anim(someScreen, LV_SCR_LOAD_ANIM_FADE_ON, someDuration, 0, false);

How do I register a callback function to be executed when this kind of animation completes? The documentation refers to void lv_anim_set_ready_cb(lv_anim_t *a, lv_anim_ready_cb_tready_cb) but I’m unsure how I would use that in this context. Do I have to set up an lv_anim_t directly and somehow connect it to the two screens and manually execute the animation?

What have you tried so far?

Reading the documentation

Code to reproduce

See above

Screenshot and/or video


Thanks! - Josh

I think it’s not possible with lv_scr_load_anim.

The best workaround is probably to create a one-shot task that executes after someDuration. As long as you set its priority to LV_TASK_PRIO_LOWEST, the animation should finish before the task gets called.

OK thanks @embeddedt, that’s helpful. I guess I’ll learn about Tasks next! :slight_smile:

Only 2 days into learning LVGL and really liking it, and getting lots done. Bravo on a great library!