Skip to main content
AJT141
Associate III
November 6, 2020
Solved

alternative to TICK_INTERVAL_MS constant in touchFGX

  • November 6, 2020
  • 4 replies
  • 1748 views

Hello,

I'm wondering if there is a an alternative to TICK_INTERVAL_MS constant which is deprecated. It is said that handleTickEvent() function is called by the Application on the current screen with a frequency of Application::TICK_INTERVAL_MS.

For the moment I've changed the frequency at which handleTickEvent() is called with this code :

/**
 * 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()
 { 
 static int cnt = 0;
 static int modulo = 2;
 if(cnt%modulo ==0)
 {
 swapFrameBuffers();
 tick();
 }
 cnt++;
 }

(Here i got the same LTDC frequency but the frequency display is divided by 2)

regards,

AJT

This topic has been closed for replies.
Best answer by Alexandre RENOUX

To do so, you have to modify the HAL_LTDC_LineEventCallback() function.

Basically you are preventing the TouchGFX framework to render a new frame every time the display has finished refreshing itself.

You do so by calling OSWrappers::signalVSync() only every x display refreshes.

Here is a sample code :

extern "C"
{
static volatile uint8_t renderNextFrameNb = 1;
 
 void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef* hltdc)
 {
 if (LTDC->LIPCR == lcd_int_active_line)
 {
 //entering active area
 HAL_LTDC_ProgramLineEvent(hltdc, lcd_int_porch_line);
 
 if(renderNextFrameNb%x == 0)
 {
 HAL::getInstance()->vSync();
 OSWrappers::signalVSync();
 // Swap frame buffers immediately instead of waiting for the task to be scheduled in.
 // Note: task will also swap when it wakes up, but that operation is guarded and will not have
 // any effect if already swapped.
 HAL::getInstance()->swapFrameBuffers();
 GPIO::set(GPIO::VSYNC_FREQ);
 }
 
 }
 else
 {
 //exiting active area
 HAL_LTDC_ProgramLineEvent(hltdc, lcd_int_active_line);
 if(renderNextFrameNb%x == 0)
 {
 GPIO::clear(GPIO::VSYNC_FREQ);
 HAL::getInstance()->frontPorchEntered();
 }
 renderNextFrameNb++;
 if(renderNextFrameNb > x)
 {
 renderNextFrameNb = 0;
 }
 }
 }
}

When your question is answered, please close this topic by choosing Select as Best.

/Alexandre

4 replies

Alexandre RENOUX
Visitor II
November 9, 2020

Hello,

I'm not sure I get your point. Why do you want to change the frequency at which handleTickEvent() is called ?

handleTickEvent() is called every "display tick" which refers to every time a Tearing Effect event sent from the display is received by the MCU. Usually this period is around 16 ms.

/Alexandre

AJT141
AJT141Author
Associate III
November 9, 2020

Hello​

I​ just want to change the frequency of the display so instead decreasing frequency of the LTDC screen that leads to display glitches (like screen flickering), I change how many time we call handTIckEvent function.

And I don't want to change all screens handletickevent functions so is there a proper way to do that or did I do the right thing ?

Regards,

Ajt​

Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II
November 10, 2020

To do so, you have to modify the HAL_LTDC_LineEventCallback() function.

Basically you are preventing the TouchGFX framework to render a new frame every time the display has finished refreshing itself.

You do so by calling OSWrappers::signalVSync() only every x display refreshes.

Here is a sample code :

extern "C"
{
static volatile uint8_t renderNextFrameNb = 1;
 
 void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef* hltdc)
 {
 if (LTDC->LIPCR == lcd_int_active_line)
 {
 //entering active area
 HAL_LTDC_ProgramLineEvent(hltdc, lcd_int_porch_line);
 
 if(renderNextFrameNb%x == 0)
 {
 HAL::getInstance()->vSync();
 OSWrappers::signalVSync();
 // Swap frame buffers immediately instead of waiting for the task to be scheduled in.
 // Note: task will also swap when it wakes up, but that operation is guarded and will not have
 // any effect if already swapped.
 HAL::getInstance()->swapFrameBuffers();
 GPIO::set(GPIO::VSYNC_FREQ);
 }
 
 }
 else
 {
 //exiting active area
 HAL_LTDC_ProgramLineEvent(hltdc, lcd_int_active_line);
 if(renderNextFrameNb%x == 0)
 {
 GPIO::clear(GPIO::VSYNC_FREQ);
 HAL::getInstance()->frontPorchEntered();
 }
 renderNextFrameNb++;
 if(renderNextFrameNb > x)
 {
 renderNextFrameNb = 0;
 }
 }
 }
}

When your question is answered, please close this topic by choosing Select as Best.

/Alexandre

AJT141
AJT141Author
Associate III
November 10, 2020

Looks like it is working !

Thank you !