fix(anim) fix calling start_cb twice

This commit is contained in:
Gabor Kiss-Vamosi
2021-05-10 09:58:38 +02:00
parent f73e813562
commit 3b8480b605
2 changed files with 3 additions and 1 deletions

View File

@@ -429,13 +429,14 @@ static void anim_timer(lv_timer_t * param)
/*The animation will run now for the first time. Call `start_cb`*/
int32_t new_act_time = a->act_time + elaps;
if(a->act_time <= 0 && new_act_time >= 0) {
if(!a->start_cb_called && a->act_time <= 0 && new_act_time >= 0) {
if(a->early_apply == 0 && a->get_value_cb) {
int32_t v_ofs = a->get_value_cb(a);
a->start_value += v_ofs;
a->end_value += v_ofs;
}
if(a->start_cb) a->start_cb(a);
a->start_cb_called = 1;
}
a->act_time += elaps;
if(a->act_time >= 0) {

View File

@@ -86,6 +86,7 @@ typedef struct _lv_anim_t {
/*Animation system use these - user shouldn't set*/
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 start_cb_called : 1; /**< Indicates that the `start_cb` was already called*/
uint32_t time_orig;
} lv_anim_t;