Hello, I want to execute a function after an animation has finished. I am using the Tileview Widget and want to change the color of a tile once I swipe it away. The problem is that once I release the current tile, the animation to show the next tile starts but the color of the “swiped” tile already changes. Is there any event I can receive regarding animations?
Best regards
What MCU/Processor/Board and compiler are you using?
VS-Simulator on Windows
What LVGL version are you using?
v7.9.1
What do you want to achieve?
Execute a function when an animation has finished.
Yeah, I can see that. Don’t know if there is an easy fix but I’ll be on the lookout. Else you would probably be better off asking @embeddedt, since I´m not well acquainted with all of LVGL, or someone else with more knowledge
Maybe something like this could be applicable?
Mind you i haven’t tested this:
lv_obj_t* tileview = lv_tileview_create(screen, NULL); //This is of course just a test object.
lv_anim_t* a = lv_anim_get(lv_page_get_scrollable(tileview), NULL);
if (a != NULL) {
lv_anim_set_ready_cb(&a, anim_ready_cb);
}
If you take a look at lv_tileview_set_tile_act in lv_tileview.c here: tileview.c the animation is applied to the object returned from lv_page_get_scrollable(tileview). So my thought was that we get that object (called lv_obj_t* scrl) like in lv_tileview.c and somehow figure out when its created, and call the aboce code which apllies a ready_cb. It´s a bit of a gamble, and there might be better solutions, but I wanted to share the thought
Yours look quite good as well, but my only concern regarding it could be that you would end up reacting on a whole other animation that might be running simultaneously, but that might be a bit unlikely i don’t know. Just a thought
Yes thats why I added the bool pageChanged so the task only reacts when exactly this animation executes. And for now I don’t think there willl be any other animations in my project.