cancel
Showing results for 
Search instead for 
Did you mean: 

Where to configure target tick rate?

unsigned_char_array
Senior III

Delays in TouchGFX Designer such as for animation assume 60Hz tickrate. Example:

 

//Fade homeIcon to alpha:0 with LinearIn easing in 1000 ms (60 Ticks)
homeIcon.clearFadeAnimationEndedAction();
homeIcon.startFadeAnimation(0, 60, touchgfx::EasingEquations::linearEaseIn);

 

For the simulator this is fine. But for the target this isn't always correct. I use LTDC as a tick source and this gets me about 40Hz.

So animations run too slow on my target. I had to resort to calling custom C++ code instead of having TouchGFX generate it. But doing this every time is annoying. Is there a way to configure this?

 

 

#ifdef SIMULATOR
constexpr uint16_t ticks = 60 * 1.000; 
#else
constexpr uint16_t ticks = 40* 1.000; 
#endif
 
//Fade homeIcon to alpha:0 with LinearIn easing in 1000 ms
homeIcon.clearFadeAnimationEndedAction();
homeIcon.startFadeAnimation(0, ticks , touchgfx::EasingEquations::linearEaseIn);   

 

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
3 REPLIES 3
LouisB
ST Employee

Hello @unsigned_char_array ,

If you want the framerate in the simulator to match the one in your target, you can call  ((touchgfx::HALSDL2*)&hal)->setVsyncInterval(25) in TouchGFXProject/TouchGFX/simulator/main.cpp

...
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    ...
    setupSimulator(argc, argv, hal);
    ((touchgfx::HALSDL2*)&hal)->setVsyncInterval(25);

    ...
}

setVsyncInterval( interval ) will change the interval between 2 frames, to find the right value :

=> 1000/YOUR_FRAME_RATE =  interval 

For 40fps => (1000/40) = 25ms

By default it's 60fps => (1000/60) ~16,66 ms

 

I hope it helps,

Regards,

Louis BOUDO
ST Software Developer | TouchGFX

Thank you. But this solves only half the problem.

With it the timing is now consistent, but it is also incorrect for BOTH simulator and target. The generated code still assumes 60 Hz and both simulator and target run too slow. In my opinion this is a serious bug. If I configure a delay in TouchGFX of x ms it should be x ms and not 2x ms if a board has 30Hz framerate. I see two ways of solving it:

  1. Make the fixed framerate of 60Hz used by the code generator a configuration option in the same menu where you set bitdepth, resolution and orientation of the display. This parameter will then set the correct tickrate for the simulator(with the code you shared) and also set the correct number of ticks for both the simulator and the target animation. When migrating to a new version of TouchGFX you can just set this value to 60 so nothing will change for existing projects unless a different tickrate is specified.
  2. Use time instead of ticks everywhere, but this would be a breaking API change and a lot of work to change. It will also give the false impression of accuracy since tickrate may not be precise (frame drops, frequency dither, etc.).

Also it would be nice if there also was a getVsyncInterval() function in addition to setVsyncInterval(). Seems useful if the user wants to use a tick count for (rough) timing in custom code.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
LouisB
ST Employee

Hello @unsigned_char_array ,

Yes I understand the issue that it causes. I will have a discussion with the team to see if this can be a feature in a future release.
Thanks for your feedback !

Regards,

Louis BOUDO
ST Software Developer | TouchGFX