Reuse Animation

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Reuse Animation

      Hello,

      I have an animation that starts when a button is released in emWin. The animation expands the button's lower Y boundary. When it finishes, the delete callback re-creates the animation for re-use. It animates the inverse motion to go back to the former position.

      It is started using

      Source Code

      1. GUI_ANIM_StartEx(hAnim, 1, _OnDelete);
      _OnDelete callback using


      Source Code

      1. static void _OnDelete(void* pVoid) {
      2. ...
      3. [invert aData motion spec];
      4. hAnim = GUI_ANIM_Create(1000, 10, &aData, NULL);
      5. GUI_ANIM_AddItem(hAnim, 0, 1000, ANIM_ACCELDECEL, &aData, _AnimShiftRows);
      6. }

      I can only run it 4 times before exception occurs. The inverse motion does not appear to get animated, but "jumped" to.

      How should I be solving this?

      Cheers,
      Joe
    • Hi,

      The delete callback can be used to e.g. free memory, but its purpose is not to restart the same animation.

      This can be done with the second parameter of GUI_ANIM_StartEx() which is the number of times the animation should be run. If you pass -1, the animation will run endlessly.

      In your case it would make sense to toggle a direction flag in the delete callback and make use of the flag in the item callback _AnimShiftRows().

      Best regards,
      Florian