cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to create animation with images to be displayed in different update intervals?

KNara.2
Associate III

I'm in need of creating animation widget, with each image to be displayed for different time frames.

Example I have a set of 3 images to be displayed as animation.

I want to display image1 for 2000 ms

image2 for 800 ms

and image3 for 4000ms?

I tried doing it using custom container.

I tried doing code changes in view.cpp but the results are not satisfactory.

Has anyone tried animation of images manually?

3 REPLIES 3
Osman SOYKURT
ST Employee

Hello KNara.2,

I think this could be doable using the handleTickEvent() and the setUpdateTicksInterval() function. First, you create your animated image with your 3 different images. In TouchGFX Designer, you'll set the default interval to 2000. Then, in code, in the handleTickEvent function you call the setUpdateTicksInterval 2 times : at 2000 ticks and 2800. Something like this :

void Screen1View::handleTickEvent()
{
    tickCount++ ;
    if (tickCount % 2000 == 0)
        animatedImage1.setUpdateTicksInterval(800);
    if (tickCount % 2800 == 0)
        animatedImage1.setUpdateTicksInterval(4000);
}

Hope it helps.

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX
KNara.2
Associate III

Thank you Osman,

If I'm not wrong my code should look like

if (tickCount % 120 == 0)

   AnimatedReady.setUpdateTicksInterval(48);

 if (tickCount % 170 == 0)

   AnimatedReady.setUpdateTicksInterval(240);

This is because I saw that ticks for every frame is typically 16.67ms.

This was mentioned as a comment above the function declaration

 void unregisterTimerWidget(const Drawable* w);

Also in Screen1ViewBase I could see the call

setUpdateTicksInterval(120); which is setUpdateTicksInterval(updateinterval in ms specified in Touchgfx designer divided by 16.67)

So ideally I should be using (update interval in ms divide by 16.67) always.

Right?

Hello KNara.2,

Absolutely, you're right :)

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX