diff --git a/lv_misc/lv_anim.c b/lv_misc/lv_anim.c index ca0d4b63db..fd7aa68786 100644 --- a/lv_misc/lv_anim.c +++ b/lv_misc/lv_anim.c @@ -196,6 +196,30 @@ int32_t lv_anim_path_ease_in_out(const lv_anim_t * a) return new_value; } +/** + * Calculate the current value of an animation with overshoot at the end + * @param a pointer to an animation + * @return the current value to set + */ +int32_t lv_anim_path_overshoot(const lv_anim_t * a) +{ + /*Calculate the current step*/ + + uint32_t t; + if(a->time == a->act_time) t = 1024; + else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; + + int32_t step = lv_bezier3(t, 0, 600, 1300, 1024); + + int32_t new_value; + new_value = (int32_t) step * (a->end - a->start); + new_value = new_value >> 10; + new_value += a->start; + + + return new_value; +} + /** * Calculate the current value of an animation applying step characteristic. * (Set end value on the end of the animation) diff --git a/lv_misc/lv_anim.h b/lv_misc/lv_anim.h index aaf1c6bff9..71ffa930f2 100644 --- a/lv_misc/lv_anim.h +++ b/lv_misc/lv_anim.h @@ -129,6 +129,13 @@ int32_t lv_anim_path_linear(const lv_anim_t *a); */ int32_t lv_anim_path_ease_in_out(const lv_anim_t *a); +/** + * Calculate the current value of an animation with overshoot at the end + * @param a pointer to an animation + * @return the current value to set + */ +int32_t lv_anim_path_overshoot(const lv_anim_t * a); + /** * Calculate the current value of an animation applying step characteristic. * (Set end value on the end of the animation)