2024-04-23 01:38 AM - edited 2024-04-23 01:40 AM
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);
2024-04-25 03:06 AM
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,
2024-04-25 06:03 AM - edited 2024-04-25 07:46 AM
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:
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.
2024-04-29 03:22 AM
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,