2023-11-21 11:23 AM
I am creating a menu similar to TouchGFX Dem1 1 for an STM32F767. I have had succes expanding the menu options from the original size to varios menu size (6,7,9) menu options. For some reason when I try to add the 10th element the animation of only the 10th element is never started. Is there any limitation on the amount of concurrent animations? What could prevent the animation from being started or canceled?
void ScreenSelectorView::StartFadeOutAnimation()
{
int button_cont_duration = 30;
int i;
int button_cont_endX = 0;
int button_cont_endY = 0;
touchgfx_printf( "NUMBER_OF_BUTTONS = %u \n" , NUMBER_OF_BUTTONS);
for (i = 0; i < 10; i++) {
/* Start closing animation */
icons[i].setFadeAnimationDelay(FADE_OUT_ANIMATION_DURATION - i);
icons[i].startFadeAnimation(0, FADE_OUT_ANIMATION_DURATION);
texts[i].setFadeAnimationDelay(FADE_OUT_ANIMATION_DURATION - i);
texts[i].startFadeAnimation(0, FADE_OUT_ANIMATION_DURATION);
buttonContainers[i].setMoveAnimationDelay(FADE_OUT_ANIMATION_DURATION);
button_cont_endX = 400;
button_cont_endY = 200 ;
buttonContainers[i].startMoveAnimation(button_cont_endX,button_cont_endY , button_cont_duration,
EasingEquations::linearEaseNone, EasingEquations::backEaseOut);
touchgfx_printf( "i = %u endx = %u endy = %u \n", i, button_cont_endX , button_cont_endY);
buttonContainers[i].invalidate();
}
currentAnimationState = ANIMATE_BUTTONS_INTO_BOX;
}
class ScreenSelectorView : public ScreenSelectorViewBase
{
public:
... Same as in example ...
protected:
... Same as in example ...
MoveAnimator<Container> buttonContainers[NUMBER_OF_BUTTONS];
};
By using touchgfx_printf I can verify that the buttonContainers[i].startMoveAnimation is indeed called 10 times with the correct parameters. However, only the first 9 buttons will move to the center of the screen.
2023-11-28 06:14 AM
Hello @RMoli.3 ,
There are no limits for the number of concurrent animations, however, there is a limit for the number of animations that you called and didn't cancel. I don't think this is the main problem here but it worth trying to cancel the animations at the end of your loop just to see if it helps the 10th element.
Is it possible for you to add more elements for testing to see if all the elements added after the 9th one fail or not?
Thanks
2023-12-01 07:31 AM
First of all thank you for the reply and sorry for my delayed response. I have limited the number of animations by only animationg part of the the buttons. The line:
if ((i < 3) || (i> 6))
limits the buttons that need to be animated to 0,1,2,7,8,9, skipping the 3,4,5. Now the button with index=9 is correctly animated.
void ScreenSelectorView::StartFadeOutAnimation()
{
int button_cont_duration = 30;
int i;
int button_cont_endX = 0;
int button_cont_endY = 0;
touchgfx_printf( "NUMBER_OF_BUTTONS = %u \n" , NUMBER_OF_BUTTONS);
for (i = 0; i < 10; i++) {
if ((i < 3) || (i> 6)){
/* Start closing animation */
icons[i].setFadeAnimationDelay(FADE_OUT_ANIMATION_DURATION - i);
icons[i].startFadeAnimation(0, FADE_OUT_ANIMATION_DURATION);
texts[i].setFadeAnimationDelay(FADE_OUT_ANIMATION_DURATION - i);
texts[i].startFadeAnimation(0, FADE_OUT_ANIMATION_DURATION);
buttonContainers[i].setMoveAnimationDelay(FADE_OUT_ANIMATION_DURATION);
button_cont_endX = 400;
button_cont_endY = 200 ;
buttonContainers[i].startMoveAnimation(button_cont_endX,button_cont_endY , button_cont_duration,
EasingEquations::linearEaseNone, EasingEquations::backEaseOut);
}
touchgfx_printf( "i = %u endx = %u endy = %u \n", i, button_cont_endX , button_cont_endY);
buttonContainers[i].invalidate();
}
currentAnimationState = ANIMATE_BUTTONS_INTO_BOX;
}
There are currently 10 buttons, each one containing an icon, a text and the actual container which hold both of them. This means
Note that the icon and the texts are inside the containers.
Can this limitation be workarounded?
2023-12-05 07:20 AM
Hello again,
No worries, what I meant by canceling the animation was to call the cancelFadeAnimation function at the end of your for loop for the icons and texts. This helps to remove the unrequired widgets from the list of widgets that we keep track the timer for (for running the animations).
So your for loop should look like this:
for (i = 0; i < 10; i++) {
if ((i < 3) || (i> 6)){
/* Start closing animation */
icons[i].setFadeAnimationDelay(FADE_OUT_ANIMATION_DURATION - i);
icons[i].startFadeAnimation(0, FADE_OUT_ANIMATION_DURATION);
texts[i].setFadeAnimationDelay(FADE_OUT_ANIMATION_DURATION - i);
texts[i].startFadeAnimation(0, FADE_OUT_ANIMATION_DURATION);
buttonContainers[i].setMoveAnimationDelay(FADE_OUT_ANIMATION_DURATION);
button_cont_endX = 400;
button_cont_endY = 200 ;
buttonContainers[i].startMoveAnimation(button_cont_endX,button_cont_endY
, button_cont_duration, EasingEquations::linearEaseNone,
EasingEquations::backEaseOut);
}
icons[i].cancelFadeAnimation();
texts[i].cancelFadeAnimation();
buttonContainers[i].invalidate();
}
Please try this and see how it works out,
Good luck
2023-12-14 05:26 AM
Canceling the animations makes all the move animation work. However I need to have all the animation workings, The fade ones and the move ones. Is there any workaround (apart from making all the animation sequential) to have all animations working?