From ab6ee94aee91db6bc6aea21bce3ca9160c431904 Mon Sep 17 00:00:00 2001 From: jiangxiaobaiyuenyxx <164881865+jiangxiaobaiyuenyxx@users.noreply.github.com> Date: Thu, 28 Mar 2024 09:49:31 +0800 Subject: [PATCH] fix(anim): optimize repeat_count type (#5975) Signed-off-by: bailinjiang <915290475@qq.com> --- src/misc/lv_anim.h | 8 ++++---- src/widgets/animimage/lv_animimage.c | 4 ++-- src/widgets/animimage/lv_animimage.h | 4 ++-- tests/src/test_cases/widgets/test_animimg.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/misc/lv_anim.h b/src/misc/lv_anim.h index 2adeb8e3b..6369115e5 100644 --- a/src/misc/lv_anim.h +++ b/src/misc/lv_anim.h @@ -23,7 +23,7 @@ extern "C" { * DEFINES *********************/ -#define LV_ANIM_REPEAT_INFINITE 0xFFFF +#define LV_ANIM_REPEAT_INFINITE 0xFFFFFFFF #define LV_ANIM_PLAYTIME_INFINITE 0xFFFFFFFF /* @@ -146,7 +146,7 @@ struct _lv_anim_t { uint32_t playback_delay; /**< Wait before play back*/ uint32_t playback_duration; /**< Duration of playback animation*/ uint32_t repeat_delay; /**< Wait before repeat*/ - uint16_t repeat_cnt; /**< Repeat count for the animation*/ + uint32_t repeat_cnt; /**< Repeat count for the animation*/ union _lv_anim_path_para_t { lv_anim_bezier3_para_t bezier3; /**< Parameter used when path is custom_bezier*/ } parameter; @@ -344,7 +344,7 @@ static inline void lv_anim_set_playback_delay(lv_anim_t * a, uint32_t delay) * @param a pointer to an initialized `lv_anim_t` variable * @param cnt repeat count or `LV_ANIM_REPEAT_INFINITE` for infinite repetition. 0: to disable repetition. */ -static inline void lv_anim_set_repeat_count(lv_anim_t * a, uint16_t cnt) +static inline void lv_anim_set_repeat_count(lv_anim_t * a, uint32_t cnt) { a->repeat_cnt = cnt; } @@ -436,7 +436,7 @@ static inline uint32_t lv_anim_get_time(const lv_anim_t * a) * @param a pointer to an initialized `lv_anim_t` variable * @return the repeat count or `LV_ANIM_REPEAT_INFINITE` for infinite repetition. 0: disabled repetition. */ -static inline uint16_t lv_anim_get_repeat_count(const lv_anim_t * a) +static inline uint32_t lv_anim_get_repeat_count(const lv_anim_t * a) { return a->repeat_cnt; } diff --git a/src/widgets/animimage/lv_animimage.c b/src/widgets/animimage/lv_animimage.c index abbc20fee..d26a848d7 100644 --- a/src/widgets/animimage/lv_animimage.c +++ b/src/widgets/animimage/lv_animimage.c @@ -94,7 +94,7 @@ void lv_animimg_set_duration(lv_obj_t * obj, uint32_t duration) lv_anim_set_playback_delay(&animimg->anim, duration); } -void lv_animimg_set_repeat_count(lv_obj_t * obj, uint16_t count) +void lv_animimg_set_repeat_count(lv_obj_t * obj, uint32_t count) { LV_ASSERT_OBJ(obj, MY_CLASS); lv_animimg_t * animimg = (lv_animimg_t *)obj; @@ -126,7 +126,7 @@ uint32_t lv_animimg_get_duration(lv_obj_t * obj) return lv_anim_get_time(&animimg->anim); } -uint16_t lv_animimg_get_repeat_count(lv_obj_t * obj) +uint32_t lv_animimg_get_repeat_count(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); lv_animimg_t * animimg = (lv_animimg_t *)obj; diff --git a/src/widgets/animimage/lv_animimage.h b/src/widgets/animimage/lv_animimage.h index 34cc341e4..87df81540 100644 --- a/src/widgets/animimage/lv_animimage.h +++ b/src/widgets/animimage/lv_animimage.h @@ -93,7 +93,7 @@ void lv_animimg_set_duration(lv_obj_t * img, uint32_t duration); * @param img pointer to an animation image object * @param count the number of times to repeat the animation */ -void lv_animimg_set_repeat_count(lv_obj_t * img, uint16_t count); +void lv_animimg_set_repeat_count(lv_obj_t * img, uint32_t count); /*===================== * Getter functions @@ -125,7 +125,7 @@ uint32_t lv_animimg_get_duration(lv_obj_t * img); * @param img pointer to an animation image object * @return the repeat count */ -uint16_t lv_animimg_get_repeat_count(lv_obj_t * img); +uint32_t lv_animimg_get_repeat_count(lv_obj_t * img); #endif /*LV_USE_ANIMIMG*/ diff --git a/tests/src/test_cases/widgets/test_animimg.c b/tests/src/test_cases/widgets/test_animimg.c index 10fdd9c8a..e58a6ac77 100644 --- a/tests/src/test_cases/widgets/test_animimg.c +++ b/tests/src/test_cases/widgets/test_animimg.c @@ -85,9 +85,9 @@ void test_animimg_set_repeat_count_infinite(void) { lv_animimg_set_repeat_count(animimg, LV_ANIM_REPEAT_INFINITE); - uint16_t actual_count = lv_animimg_get_repeat_count(animimg); + uint32_t actual_count = lv_animimg_get_repeat_count(animimg); - TEST_ASSERT_EQUAL_UINT16(actual_count, LV_ANIM_REPEAT_INFINITE); + TEST_ASSERT_EQUAL_UINT32(actual_count, LV_ANIM_REPEAT_INFINITE); } void test_animimg_start(void)