[v9] request "lv_anim" support pause and continue

Sometimes, when lv_anim is operating, continuously repeating or playing back, and then in some cases, the animation is canceled with lv_anim_del(..).

If later it is desired to resume the repetition, the value will not continue from the previous value.

I would like to request the capability for lv_anim to be able to temporarily pause and then continue from the previous value.

Hey,

Take a look at this issue: Improve the animation API · Issue #5350 · lvgl/lvgl · GitHub

I think it solves your request too.

Thank you very much.
anim_timeline is a great efficient tool.

If I would like to add many anims to the timeline,
while an anim is called to start by the timeline until completion
how can I activate the completed_cb(...) of the anim ?

Sorry, I don’t understand

It’s clear.

I don’t get it. Could you describe it differently?

Clear too.

Sorry about my poor english.

As the following sample scenario code.

After anim1 , anim2 , and anim3
have been called and completed according to the timeline’s start,
I expect the completed_cb callback function to also be triggered.
However, it seems that the callback function is not being invoked
by the timeline as expected.

Ah, I see now!

The complete_cb is not called because you can do a lot of funky things with the timeline:

  • play it in reverse
  • seek to any position
  • play it in a special way by seeking manually on each step

So it is hard to interpret when the animation is really completed.

If the timeline runs forward,
interpret that complete_cb is triggered
when the animation reaches the end of the duration.

And if the timeline runs backward in reverse,
interpret that complete_cb is triggered
when the animation reaches the start point of the duration.

How can we control this scenario using the timeline?

Playing the animations with lv_anim_timeline_start() is just one specific case (might be the most common one though) in which complete_cb makes sense, hence I don’t feel we can add support for complete_cb in this case.

What is your exact use case? Maybe we can approach the problem differently.

Thanks to lv_anim’s high efficiency in lvgl.

Sometimes I prefer it over a standard C/C++ for/while loop
for asynchronous operation.
This provides precise control over task duration timing
and the flexibility to define various animation paths
for value increments, not limited to linear paths,
such as lv_anim_path_ease_in.

Moreover, when a specific animation completes,
a regular animation has a completed_cb
which allows triggering additional actions as necessary.

I’ve attempted to address the issue where lv_anim_timeline
can call completed_cb for each animation
by adding a boolean flag to each animation,
as illustrated in the following code.

Thank you for tools like anim and anim_timeline in lvgl.

1 Like

So do you use the LVGL animations for non-UI tasks too? It’s interesting.

Could you send a Pull request with your changes in LVGL? It’s would be easier to see what has been changed.

I have already added a pull request.

Update lv_anim_timeline.c can call anim's completed_cb by TridentTD · Pull Request #6085 · lvgl/lvgl (github.com)

1 Like

Cool, I’ll review it today.