Skip to content

Commit 39d9fc2

Browse files
committed
Fix bug in animation management for lv_label
1 parent 50ae0ae commit 39d9fc2

3 files changed

Lines changed: 56 additions & 5 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Index: src/libs/lvgl/src/lv_misc/lv_anim.c
2+
IDEA additional info:
3+
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
4+
<+>UTF-8
5+
===================================================================
6+
diff --git a/src/libs/lvgl/src/lv_misc/lv_anim.c b/src/libs/lvgl/src/lv_misc/lv_anim.c
7+
--- a/src/libs/lvgl/src/lv_misc/lv_anim.c (revision 12a3b6cc8ec1fd6b951c353ab3a5fbbb9934fdd4)
8+
+++ b/src/libs/lvgl/src/lv_misc/lv_anim.c (date 1610901672072)
9+
@@ -158,12 +158,12 @@
10+
* @param end end value of the animation
11+
* @return the required time [ms] for the animation with the given parameters
12+
*/
13+
-uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end)
14+
+uint32_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end)
15+
{
16+
int32_t d = LV_MATH_ABS((int32_t)start - end);
17+
uint32_t time = (int32_t)((int32_t)(d * 1000) / speed);
18+
19+
- if(time > UINT16_MAX) time = UINT16_MAX;
20+
+ if(time > UINT32_MAX) time = UINT32_MAX;
21+
22+
if(time == 0) {
23+
time++;
24+
Index: src/libs/lvgl/src/lv_misc/lv_anim.h
25+
IDEA additional info:
26+
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
27+
<+>UTF-8
28+
===================================================================
29+
diff --git a/src/libs/lvgl/src/lv_misc/lv_anim.h b/src/libs/lvgl/src/lv_misc/lv_anim.h
30+
--- a/src/libs/lvgl/src/lv_misc/lv_anim.h (revision 12a3b6cc8ec1fd6b951c353ab3a5fbbb9934fdd4)
31+
+++ b/src/libs/lvgl/src/lv_misc/lv_anim.h (date 1610901672076)
32+
@@ -73,8 +73,8 @@
33+
lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
34+
int32_t start; /**< Start value*/
35+
int32_t end; /**< End value*/
36+
- uint16_t time; /**< Animation time in ms*/
37+
- int16_t act_time; /**< Current time in animation. Set to negative to make delay.*/
38+
+ uint32_t time; /**< Animation time in ms*/
39+
+ int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/
40+
uint16_t playback_pause; /**< Wait before play back*/
41+
uint16_t repeat_pause; /**< Wait before repeat*/
42+
#if LV_USE_USER_DATA
43+
@@ -266,7 +266,7 @@
44+
* @param end end value of the animation
45+
* @return the required time [ms] for the animation with the given parameters
46+
*/
47+
-uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end);
48+
+uint32_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end);
49+
50+
/**
51+
* Calculate the current value of an animation applying linear characteristic

src/libs/lvgl/src/lv_misc/lv_anim.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ uint16_t lv_anim_count_running(void)
158158
* @param end end value of the animation
159159
* @return the required time [ms] for the animation with the given parameters
160160
*/
161-
uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end)
161+
uint32_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end)
162162
{
163163
int32_t d = LV_MATH_ABS((int32_t)start - end);
164164
uint32_t time = (int32_t)((int32_t)(d * 1000) / speed);
165165

166-
if(time > UINT16_MAX) time = UINT16_MAX;
166+
if(time > UINT32_MAX) time = UINT32_MAX;
167167

168168
if(time == 0) {
169169
time++;

src/libs/lvgl/src/lv_misc/lv_anim.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ typedef struct _lv_anim_t
7373
lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
7474
int32_t start; /**< Start value*/
7575
int32_t end; /**< End value*/
76-
uint16_t time; /**< Animation time in ms*/
77-
int16_t act_time; /**< Current time in animation. Set to negative to make delay.*/
76+
uint32_t time; /**< Animation time in ms*/
77+
int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/
7878
uint16_t playback_pause; /**< Wait before play back*/
7979
uint16_t repeat_pause; /**< Wait before repeat*/
8080
#if LV_USE_USER_DATA
@@ -266,7 +266,7 @@ uint16_t lv_anim_count_running(void);
266266
* @param end end value of the animation
267267
* @return the required time [ms] for the animation with the given parameters
268268
*/
269-
uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end);
269+
uint32_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end);
270270

271271
/**
272272
* Calculate the current value of an animation applying linear characteristic

0 commit comments

Comments
 (0)