2021-05-14 08:58 PM
When I want to understand how touchgfx platform works, especially the operation on the framebuffer, I realize there are some functions I could not get the source code e.g. the functions swapFrameBuffers() and tick() below which seems to be defined in a library code. Does ST provide source code for this?
/**
* Has to be called from within the LCD IRQ rutine when the Back Porch Exit is reached.
*
* Has to be called from within the LCD IRQ rutine when the Back Porch Exit is reached.
*/
virtual void backPorchExited()
{
swapFrameBuffers();
tick();
}
Solved! Go to Solution.
2021-05-17 12:01 AM
Hi,
The swapFrameBuffers() function is implemented when using the "Double Framebuffer" strategy. As explained in the "Main Loop" and the "Performance" article in the online documentation the graphic engine renders the updated graphics/frame to the framebuffer. It alternates between the two framebuffers where it draws the frame into a framebuffer while the other one is transferred and shown on the display.
The tick() function will be executed once every frame. The tick source used by TouchGFX can be set in the Driver setup in the TouchGFX Generator configuration within STM32CubeMX. It depends on the platform implementation but in the application templates for ST development boards available in TouchGFX Designer the period is 16ms (so 60 ticks is around 1s). The handleTick() function is then used in animated widgets or in demos that require a timer of sort.
/Romain
2021-05-16 08:07 PM
Hello BParh.1,
Unfortunately, the source code of the core TouchGFX library is private and cannot be provided.
Sorry for the inconvenience.
When your question is answered, please close this topic by choosing Select as Best.
/Alexandre
2021-05-16 09:48 PM
Thank you @Alexandre RENOUX for the response,
In that case do yo mind just to brief what does swapFrameBuffers() and tick() do?
Also, I want to understand how those functions can finally linked to the user code in view class section.
I don't need details, just to understand basic mechanism how the code works.
2021-05-16 11:20 PM
Hello BParh.1,
Hope this is clearer ^^
/Alexandre
2021-05-17 12:01 AM
Hi,
The swapFrameBuffers() function is implemented when using the "Double Framebuffer" strategy. As explained in the "Main Loop" and the "Performance" article in the online documentation the graphic engine renders the updated graphics/frame to the framebuffer. It alternates between the two framebuffers where it draws the frame into a framebuffer while the other one is transferred and shown on the display.
The tick() function will be executed once every frame. The tick source used by TouchGFX can be set in the Driver setup in the TouchGFX Generator configuration within STM32CubeMX. It depends on the platform implementation but in the application templates for ST development boards available in TouchGFX Designer the period is 16ms (so 60 ticks is around 1s). The handleTick() function is then used in animated widgets or in demos that require a timer of sort.
/Romain
2021-05-17 12:12 AM
Thank you @Alexandre RENOUX and @Romain DIELEMAN , so much clearer now. So does it mean for the user perspective like us, what we care is simply modifying this frame buffer content in ScreenView class and for the rest, let the magic of TouchGFX handle it? :grinning_face:
If I want to slow down this tick period, which of the STM32CubeMX setting I should change? Is it under Additional Software-> STM XCube?
2021-05-17 01:39 AM
what we care is simply modifying this frame buffer content in ScreenView class and for the rest, let the magic of TouchGFX handle it?
Kind of yes :grinning_face_with_sweat:
If you wish to slow down the tick period it would be in the "Tick Source" settings in the "Driver" section I was referencing above in the Additional Software -> STMicroelectronics.X-Cube-TouchGFX.4.16.1 like you said. If you are using the LTDC as the tick source you can change the period by lowering the pixel clock frequency of your display (what you want is to set the vsync). If you are using "Custom" it would then be through code in the relevant sections (you can go through the available application templates to understand how we configured the ST development kits in STM32CubeMX and in user code).
But to be fair if you just wish to slow down the animations you can just do it within the ScreenView class like this for example:
int16_t tickCounter = 0;
void ScreenView::handleTickEvent()
{
tickCounter++;
if( tickCounter == 10) // slowing down the call of the function by 10
{
doAction();
tickCounter = 0;
}
}
/Romain
2021-05-17 02:37 AM
Thanks @Romain DIELEMAN , clear! Much obliged :grinning_face: