Cascaded animations

Description

Have a set of cascaded animations that are consistent (1 > 2 > 3)

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

ESP32 / Platform IO

What LVGL version are you using?

v7.7 with tft_eSPI

What do you want to achieve?

I have to sets of three chevrons ("< < < > > >") that I want to animate. I want them to “flash” in an outward direction, so the inner ones first, then the middle, then the outer. This requires a pair of identical, syncronised starts and then cascaded animation.

What have you tried so far?

Different timings, but they never seem to start/end at the same time, the flashing always ends up fairly random.

Code to reproduce

      //location on the screen
      int x = -100;

      int d = 250;
      for (int i = 0; i < 6; i++) {
        //select correct arrow
        const char* text = "<";
        if (i > 2) { text = ">"; }

        //create the arrow
        hp.chevrons[i] = lv_label_create(scr, NULL);
        lv_obj_set_style_local_opa_scale(hp.chevrons[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0);
        lv_label_set_text(hp.chevrons[i], text);
        lv_obj_align(hp.chevrons[i], scr, LV_ALIGN_CENTER, x, -30);

        //select the next "x" coordinate
        x = x + 20;
        if (x < 0) {
          d = d - 125;
        } else {
          d = d + 125;
        }
        if (x == -40) { x = 60; }
        
        lv_anim_t a;
        lv_anim_init(&a);
        lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t) anim_opacity_cb);
        lv_anim_set_var(&a, hp.chevrons[i]);
        lv_anim_set_time(&a, 125);
        lv_anim_set_values(&a, LV_OPA_COVER, LV_OPA_TRANSP);
        lv_anim_set_playback_time(&a, 125);
        lv_anim_set_playback_delay(&a, d);
        lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
        lv_anim_set_repeat_delay(&a, 500);
        lv_anim_start(&a);
      }

Screenshot and/or video

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

Can you make a video about the issue?

You know, I had forgotten I posted this - I worked out how to do this days ago. The above code will work just fine (I had another part of my code that was breaking things just under… teach me to work on things at 1am).

No problem :slight_smile: