diff --git a/src/lv_misc/lv_anim.c b/src/lv_misc/lv_anim.c index dbe1b970b..ed3fd7929 100644 --- a/src/lv_misc/lv_anim.c +++ b/src/lv_misc/lv_anim.c @@ -475,8 +475,11 @@ static void anim_task(lv_task_t * param) if(a->path.cb) new_value = a->path.cb(&a->path, a); else new_value = lv_anim_path_linear(&a->path, a); - /*Apply the calculated value*/ - if(a->exec_cb) a->exec_cb(a->var, new_value); + if(new_value != a->current) { + a->current = new_value; + /*Apply the calculated value*/ + if(a->exec_cb) a->exec_cb(a->var, new_value); + } /*If the time is elapsed the animation is ready*/ if(a->act_time >= a->time) { diff --git a/src/lv_misc/lv_anim.h b/src/lv_misc/lv_anim.h index 1a84087b7..e48dae50f 100644 --- a/src/lv_misc/lv_anim.h +++ b/src/lv_misc/lv_anim.h @@ -82,6 +82,7 @@ typedef struct _lv_anim_t { lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/ lv_anim_path_t path; /**< Describe the path (curve) of animations*/ int32_t start; /**< Start value*/ + int32_t current; /**< Current value */ int32_t end; /**< End value*/ int32_t time; /**< Animation time in ms*/ int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/ @@ -171,6 +172,7 @@ static inline void lv_anim_set_delay(lv_anim_t * a, uint32_t delay) static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_anim_value_t end) { a->start = start; + a->current = start; a->end = end; }