fixes #3572 Signed-off-by: qinshijing <qinshijing@xiaomi.com> Co-authored-by: qinshijing <qinshijing@xiaomi.com>
This commit is contained in:
@@ -36,7 +36,6 @@ static void anim_ready_handler(lv_anim_t * a);
|
|||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
**********************/
|
**********************/
|
||||||
static uint32_t last_timer_run;
|
|
||||||
static bool anim_list_changed;
|
static bool anim_list_changed;
|
||||||
static bool anim_run_round;
|
static bool anim_run_round;
|
||||||
static lv_timer_t * _lv_anim_tmr;
|
static lv_timer_t * _lv_anim_tmr;
|
||||||
@@ -81,11 +80,6 @@ lv_anim_t * lv_anim_start(const lv_anim_t * a)
|
|||||||
/*Do not let two animations for the same 'var' with the same 'exec_cb'*/
|
/*Do not let two animations for the same 'var' with the same 'exec_cb'*/
|
||||||
if(a->exec_cb != NULL) lv_anim_del(a->var, a->exec_cb); /*exec_cb == NULL would delete all animations of var*/
|
if(a->exec_cb != NULL) lv_anim_del(a->var, a->exec_cb); /*exec_cb == NULL would delete all animations of var*/
|
||||||
|
|
||||||
/*If the list is empty the anim timer was suspended and it's last run measure is invalid*/
|
|
||||||
if(_lv_ll_is_empty(&LV_GC_ROOT(_lv_anim_ll))) {
|
|
||||||
last_timer_run = lv_tick_get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Add the new animation to the animation linked list*/
|
/*Add the new animation to the animation linked list*/
|
||||||
lv_anim_t * new_anim = _lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll));
|
lv_anim_t * new_anim = _lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll));
|
||||||
LV_ASSERT_MALLOC(new_anim);
|
LV_ASSERT_MALLOC(new_anim);
|
||||||
@@ -95,6 +89,7 @@ lv_anim_t * lv_anim_start(const lv_anim_t * a)
|
|||||||
lv_memcpy(new_anim, a, sizeof(lv_anim_t));
|
lv_memcpy(new_anim, a, sizeof(lv_anim_t));
|
||||||
if(a->var == a) new_anim->var = new_anim;
|
if(a->var == a) new_anim->var = new_anim;
|
||||||
new_anim->run_round = anim_run_round;
|
new_anim->run_round = anim_run_round;
|
||||||
|
new_anim->last_timer_run = lv_tick_get();
|
||||||
|
|
||||||
/*Set the start value*/
|
/*Set the start value*/
|
||||||
if(new_anim->early_apply) {
|
if(new_anim->early_apply) {
|
||||||
@@ -352,7 +347,6 @@ static void anim_timer(lv_timer_t * param)
|
|||||||
{
|
{
|
||||||
LV_UNUSED(param);
|
LV_UNUSED(param);
|
||||||
|
|
||||||
uint32_t elaps = lv_tick_elaps(last_timer_run);
|
|
||||||
|
|
||||||
/*Flip the run round*/
|
/*Flip the run round*/
|
||||||
anim_run_round = anim_run_round ? false : true;
|
anim_run_round = anim_run_round ? false : true;
|
||||||
@@ -360,6 +354,8 @@ static void anim_timer(lv_timer_t * param)
|
|||||||
lv_anim_t * a = _lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll));
|
lv_anim_t * a = _lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll));
|
||||||
|
|
||||||
while(a != NULL) {
|
while(a != NULL) {
|
||||||
|
uint32_t elaps = lv_tick_elaps(a->last_timer_run);
|
||||||
|
a->last_timer_run = lv_tick_get();
|
||||||
/*It can be set by `lv_anim_del()` typically in `end_cb`. If set then an animation delete
|
/*It can be set by `lv_anim_del()` typically in `end_cb`. If set then an animation delete
|
||||||
* happened in `anim_ready_handler` which could make this linked list reading corrupt
|
* happened in `anim_ready_handler` which could make this linked list reading corrupt
|
||||||
* because the list is changed meanwhile
|
* because the list is changed meanwhile
|
||||||
@@ -408,7 +404,6 @@ static void anim_timer(lv_timer_t * param)
|
|||||||
a = _lv_ll_get_next(&LV_GC_ROOT(_lv_anim_ll), a);
|
a = _lv_ll_get_next(&LV_GC_ROOT(_lv_anim_ll), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
last_timer_run = lv_tick_get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ typedef struct _lv_anim_t {
|
|||||||
uint8_t early_apply : 1; /**< 1: Apply start value immediately even is there is `delay`*/
|
uint8_t early_apply : 1; /**< 1: Apply start value immediately even is there is `delay`*/
|
||||||
|
|
||||||
/*Animation system use these - user shouldn't set*/
|
/*Animation system use these - user shouldn't set*/
|
||||||
|
uint32_t last_timer_run;
|
||||||
uint8_t playback_now : 1; /**< Play back is in progress*/
|
uint8_t playback_now : 1; /**< Play back is in progress*/
|
||||||
uint8_t run_round : 1; /**< Indicates the animation has run in this round*/
|
uint8_t run_round : 1; /**< Indicates the animation has run in this round*/
|
||||||
uint8_t start_cb_called : 1; /**< Indicates that the `start_cb` was already called*/
|
uint8_t start_cb_called : 1; /**< Indicates that the `start_cb` was already called*/
|
||||||
|
|||||||
Reference in New Issue
Block a user