cancel
Showing results for 
Search instead for 
Did you mean: 

Where can I find the source code of touchgfx library?

BParh.1
Senior III

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();
    }

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

7 REPLIES 7
Alexandre RENOUX
Principal

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

BParh.1
Senior III

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.

Hello BParh.1,

  • swapFrameBuffers(), as the name states, swaps the framebuffers. This means that if you have 2 framebuffers, the pointer will now point to the non-filled framebuffer. If you have only one framebuffer, it does nothing.
  • tick() is the heartbeat of the library. By calling tick you initiate a new rendering that will fill the framebuffer you just swapped to. In this function handleTickEvent() is called. So your heartbeat in your ScreenView is the handleTickEvent() function.

Hope this is clearer ^^

/Alexandre

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

BParh.1
Senior III

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?

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

BParh.1
Senior III

Thanks @Romain DIELEMAN​ , clear! Much obliged :grinning_face: