# Roller with animation

**URL:** <http://forum.squareline.io/t/roller-with-animation/1006>\
**Category:** How to\
**Created:** [March 16, 2023, 6:11pm UTC](http://forum.squareline.io/t/roller-with-animation/1006 "2023-03-16T18:11:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deadeye](http://forum.squareline.io/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@Deadeye](http://forum.squareline.io/u/Deadeye)\
**Post date:** [March 16, 2023, 6:11pm UTC](http://forum.squareline.io/t/roller-with-animation/1006/1 "2023-03-16T18:11:26Z")

</div>

Hello,

I have a small roller that I want to set according to my selection.  
This works fine with the command

lv\_roller\_set\_selected(ui\_varRoller, value, LV\_ANIM\_OFF);

since there seems to be an option to have an animation I tried this as well. But in this case the roller isn’t responding anymore.

lv\_roller\_set\_selected(ui\_varRoller, value, LV\_ANIM\_ON);

After reading the lvgl documentation my guess would have been, that I have to set a time for the animation. But if it would be 0 by default, why would the roller not work anymore? Anyhow I tried the lvgl command

lv\_roller\_set\_anim\_time(ui\_varRoller, 500);

but this is not declared at it seems. I’ve searched the whole libarary but can’t find this expression at all.  
So any idea what I’m doing wrong?

BR Chris

---

<div class="post-metadata">

**Author:** ![kisvegabor](http://forum.squareline.io/user_avatar/forum.squareline.io/kisvegabor/32/537_2.png) [@kisvegabor](http://forum.squareline.io/u/kisvegabor)\
**Post date:** [March 21, 2023, 7:21am UTC](http://forum.squareline.io/t/roller-with-animation/1006/2 "2023-03-21T07:21:37Z")

</div>

Hi,

I don’t know why the roller is not responding. Could you send a code snippet to reproduce the issue?

Anyway, the animation time is a style property and you can set it with ` lv_obj_set_style_anim_time(roller, 500, 0);`

---

<div class="post-metadata">

**Author:** ![Deadeye](http://forum.squareline.io/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@Deadeye](http://forum.squareline.io/u/Deadeye)\
**Post date:** [March 23, 2023, 3:59pm UTC](http://forum.squareline.io/t/roller-with-animation/1006/3 "2023-03-23T15:59:37Z")

</div>

Well I have tried multiple things but non are working.

I have stripped down my display project to the bare minium. Only background and roller remain.  
I have added more selections in case 3 was not enough for a animation to happen.  
I have tried to set the animation style. Nothing works.

Since I can not upload files yet I have provided a link where you can download the code  
[https://42volt.net/Display/AmpDisplay.zip](https://42volt.net/Display/AmpDisplay.zip)

As board I’m using a Lilygo T-Display S3 wit an ESP32S3 controller.

---

<div class="post-metadata">

**Author:** ![kisvegabor](http://forum.squareline.io/user_avatar/forum.squareline.io/kisvegabor/32/537_2.png) [@kisvegabor](http://forum.squareline.io/u/kisvegabor)\
**Post date:** [March 28, 2023, 9:50am UTC](http://forum.squareline.io/t/roller-with-animation/1006/4 "2023-03-28T09:50:52Z")

</div>

> ```
> lv_obj_clear_flag(ui_varRoller, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE); /// Flags
> 
> ```

This line makes the roller not `CLICKABLE` probably you added this flag by accident.  
 ![image](http://forum.squareline.io/uploads/default/original/1X/b91fa18905600ed654e7cd648dde61a39baf9252.png)

---

<div class="post-metadata">

**Author:** ![Deadeye](http://forum.squareline.io/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@Deadeye](http://forum.squareline.io/u/Deadeye)\
**Post date:** [April 6, 2023, 7:17pm UTC](http://forum.squareline.io/t/roller-with-animation/1006/5 "2023-04-06T19:17:56Z")

</div>

Hmm, this is not the problem. Tested both variants, clickable and not. Or maybe I’m understanding the property animation wrong? Is animation supposed to only work at touchscreen displays?  
I don’t have a touchscreen but my educated guess would have been, that the animation is a smoth transistion between the values of the roller instead of a simple switch

---

<div class="post-metadata">

**Author:** ![Marian\_M](http://forum.squareline.io/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@Marian\_M](http://forum.squareline.io/u/Marian_M)\
**Post date:** [April 7, 2023, 11:30am UTC](http://forum.squareline.io/t/roller-with-animation/1006/6 "2023-04-07T11:30:52Z")

</div>

I see in my code

```auto
_ui_roller_set_property(ui_Screen3_Roller1, _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM, Preamp_Settings.lcd_input-1);

```

---

<div class="post-metadata">

**Author:** ![kisvegabor](http://forum.squareline.io/user_avatar/forum.squareline.io/kisvegabor/32/537_2.png) [@kisvegabor](http://forum.squareline.io/u/kisvegabor)\
**Post date:** [April 11, 2023, 7:37am UTC](http://forum.squareline.io/t/roller-with-animation/1006/7 "2023-04-11T07:37:48Z")

</div>

> [@Deadeye](#):
>
> Is animation supposed to only work at touchscreen displays?

Not at all.

Let summarize the current state:

- does the animation work after `lv_obj_set_style_anim_time`?
- what do exactly mean by “the roller not work anymore”?

---

<div class="post-metadata">

**Author:** ![Deadeye](http://forum.squareline.io/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@Deadeye](http://forum.squareline.io/u/Deadeye)\
**Post date:** [April 11, 2023, 8:39am UTC](http://forum.squareline.io/t/roller-with-animation/1006/8 "2023-04-11T08:39:47Z")

</div>

Ok., here is what I did so far. I have created a roller object in my Studio Project. The roller has 3 options, but I also tried a version with more options, just in case 3 was not enough.

My source code on my ESP32 controller cycles through the roller options

```auto
source++;
  if (source > 2){
    source = 0;
  }    

  lv_roller_set_selected(ui_varRoller, source, LV_ANIM_OFF);

```

every 500 ms.

If I use the roller like this, I can see it toggling between the 3 options on the display. It is a hard transition.

My guess would have been, that I can use the LV\_ANIM property to archive a smoother transistion effect between those cylcles.

Now if I enable the LV\_ANIM property the roller stops working. It will remain on the first option and is not cylcing anymore on the diplay.

As you has suggested I tried to set an animation time with lv\_obj\_set\_style\_anim\_time of 500 ms and increased my own cycle time to 2 seconds. The result was the same, the roller was not updated anymore and remained on the same options.

Maybe I can make a video of that in the next few days.

---

<div class="post-metadata">

**Author:** ![Deadeye](http://forum.squareline.io/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@Deadeye](http://forum.squareline.io/u/Deadeye)\
**Post date:** [April 11, 2023, 12:37pm UTC](http://forum.squareline.io/t/roller-with-animation/1006/9 "2023-04-11T12:37:17Z")

</div>

Oh, I just might have figured out what the root cause for this problem is. I went through the documentation. And stumbled upon the Tick requirement. Since I used an Arduino Example as template for my own application, it never occured to me, that there is an additional requirement for animations. Ok, I will give it a try later on and I’m pretty sure that this will resolve my issue.

---

<div class="post-metadata">

**Author:** ![Deadeye](http://forum.squareline.io/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@Deadeye](http://forum.squareline.io/u/Deadeye)\
**Post date:** [April 11, 2023, 6:22pm UTC](http://forum.squareline.io/t/roller-with-animation/1006/10 "2023-04-11T18:22:10Z")

</div>

Upon further review this seems not to be the whole explanation. Due to theuse of an example project my lv\_conf.h was already changed to a custom tick.

#define LV\_TICK\_CUSTOM 1  
#if LV\_TICK\_CUSTOM  
#define LV\_TICK\_CUSTOM\_INCLUDE “Arduino.h” /_Header for the system time function_/  
#define LV\_TICK\_CUSTOM\_SYS\_TIME\_EXPR (millis()) /_Expression evaluating to current system time in ms_/  
#endif /_LV\_TICK\_CUSTOM_

with this the display in gerneral works, except the roller animation part. If I change the declaration to 0 and try to implement the `lv_tick_inc` function call my project breaks and the display remains black. Need to figure out what I’m doing wrong. But per se I would expect the animation to work non then less, due to the custom tick configuration, right?

---

<div class="post-metadata">

**Author:** ![Deadeye](http://forum.squareline.io/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@Deadeye](http://forum.squareline.io/u/Deadeye)\
**Post date:** [April 11, 2023, 6:52pm UTC](http://forum.squareline.io/t/roller-with-animation/1006/11 "2023-04-11T18:52:49Z")

</div>

Ok, finally figured it out.  
The problem was the delay in my main loop. I had set it to 500 ms, so my test code would slowly switch trough the different roller options. So it seems that a blocking delay breaks the animation.

---

<div class="post-metadata">

**Author:** ![kisvegabor](http://forum.squareline.io/user_avatar/forum.squareline.io/kisvegabor/32/537_2.png) [@kisvegabor](http://forum.squareline.io/u/kisvegabor)\
**Post date:** [April 12, 2023, 12:59pm UTC](http://forum.squareline.io/t/roller-with-animation/1006/12 "2023-04-12T12:59:30Z")

</div>

Ahhh, yes, it’s a problem. This way LVGL thinks that 500 ms has elapsed in the animation too and will finish it immediately on the next call of `lv_timer_handler`.
