Syncing animations

Description

I have a series of labels that flash when certain thresholds are passed.
I would like them to flash in sync, as now they flash at random intervals based on when the function that checks the thresholds runs (every 0.5s)
See GIF for example

What MCU/Processor/Board and compiler are you using?

Teensy 4.1

What LVGL version are you using?

V8.3

What do you want to achieve?

Have all my animations synced.

What have you tried so far?

Use a global function to animate with a single animation var

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.
image

Anyone out there with an idea?

@kisvegabor do you have any lead for this?
I would have used animation timelines, but there is no way to remove individual animations from the timeline, only delete the whole timeline

You can sync them only if you use a single function for all animations. As the UI is quite static (object are not added dynamically) you can have an animation with a custom exec_cb in which you check all the object that can be blinked and if some conditions met you can hide/unhide that object. E.g.

void my_anim_cb(void * var, iint32_t v)
{
   //var is not used
  if(shall_we_blink_icon1()) {
     if(v) lv_obj_clear_flag(icon1, LV_OBJ_FLAG_HIDDEN);
     else lv_obj_add_flag(icon1, LV_OBJ_FLAG_HIDDEN);  
  } else {
    lv_obj_clear_flag(icon1, LV_OBJ_FLAG_HIDDEN); ///Be sure it's visible
  }

  if(shall_we_blink_icon2()) {
     if(v) lv_obj_clear_flag(icon2, LV_OBJ_FLAG_HIDDEN);
     else lv_obj_add_flag(icon2, LV_OBJ_FLAG_HIDDEN);  
  } else {
    lv_obj_clear_flag(icon2, LV_OBJ_FLAG_HIDDEN); ///Be sure it's visible
  }

  ...
}
1 Like