cancel
Showing results for 
Search instead for 
Did you mean: 

How to add delay in TouchGFX application?

biki
Associate II

I'm trying to develop an application where i have to display 3 different texts for 5 secs for 3 cycles and then change to different screen.

I'm adding 3 interactions for this.

  1. Delay for 1 sec when screen1 is entered.
  2. Execute C++ code when interaction1 is done.

code i'm writing is

for(int i=1;i<=3;i++)

{

textArea.setTypedText(TypedText(T_R1));

textArea.invalidate();

Sleep(5000);

textArea.setTypedText(TypedText(T_R2));

textArea.invalidate();

Sleep(5000);

textArea.setTypedText(TypedText(T_R3));

textArea.invalidate();

Sleep(5000);

}

Here i'm adding #include <windows.h> for using Sleep();

3. After interaction 2 is done, it has to go to screen 2

It is building fine and running but required functionality i'm not able to achieve. Please help me with the different methods available to do this. i don't mind calling a virtual function.

With the built-in functions "Set Text" and "wait for", i'm able to achieve one cycle only .

Also i tried with tick handling but with this method i could not do as i'm not very familiar with it.

2 REPLIES 2
davidra7
Associate II

try using void handleTickEvent() function inside screen View class, it enters the function every 16.6ms ( 60 hz - if you trigger less it will enter when you trigger )

Better not to use sleep / HAL_Delay / osDelay inside this function but you can do it with counter ( every entry is 16.6ms)

Martin KJELDSEN
Chief III

Either do as david says by hooking into handleTickEvent() or keep track of time in your model and use the modelListener to issue an event to any active presenter. The resolution of the tick is as dictated by your LTDC / TE interrupt handler that ticks touchgfx.

Here's a contrived example:

if( currTime > fiveSecTimeOut)
{
    modelListener->fiveSecondsPassed();
}

And then keep track of which TextArea to show as an internal state in the presenter/view.

/Martin