cancel
Showing results for 
Search instead for 
Did you mean: 

Detect any touch

MauFanGilaMedical
Associate III

Hello,

I developed a product,

but customer wants that if no touch detected in 10 seconds the device will go in home page.

 

I believe that the only way is to manage STM32TouchController.cpp in the point I have higlighted

 

MauFanGilaMedical_0-1764747915219.png

 

Is it the best way ?

Thankyou for your patience.

1 ACCEPTED SOLUTION

Accepted Solutions
JohanAstrup
ST Employee

The execution rate of handleTickEvent() is actually determined by how you tick the application. TouchGFX is designed to operate at 60 Hz by default, which is why I assumed 60 Hz in the code snippet.

You are correct that the generation of the screen transition code needs to be triggered, e.g. as shown in your screenshot.

You can use getCurrentScreen(), which returns a pointer to the currently displayed screen: https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_application#getcurrentscreen.
Another option is to manually save the current screen in the model, e.g. every time a screen constructor is entered.

Best regards,
Johan

View solution in original post

3 REPLIES 3
JohanAstrup
ST Employee

Hello @MauFanGilaMedical.

I believe a better solution would be to implement it in FrontendApplication. E.g. by doing something like this:

void FrontendApplication::handleTickEvent()
{
    model.tick();
    FrontendApplicationBase::handleTickEvent();

    idleTickCounter++;

    if (idleTickCounter == 10 * 60)
    {
        gotoHomeScreenNoTransition();
    }
}

void FrontendApplication::handleClickEvent(const ClickEvent& evt)
{
    FrontendApplicationBase::handleClickEvent(evt);

    idleTickCounter = 0;
}


Best regards,
Johan

MauFanGilaMedical
Associate III

OK: but I deduce that

handleTickEvent

is executed at 60fps.

 

But to have

gotoHomeScreenNoTransition();

I have to add interaction like in the picture below, right ?

MauFanGilaMedical_1-1765353423517.png

 

And there is a way to deduce what is the current display screen ? Because I have to go Home if I am in screens different from Home, Power on and Power off

JohanAstrup
ST Employee

The execution rate of handleTickEvent() is actually determined by how you tick the application. TouchGFX is designed to operate at 60 Hz by default, which is why I assumed 60 Hz in the code snippet.

You are correct that the generation of the screen transition code needs to be triggered, e.g. as shown in your screenshot.

You can use getCurrentScreen(), which returns a pointer to the currently displayed screen: https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_application#getcurrentscreen.
Another option is to manually save the current screen in the model, e.g. every time a screen constructor is entered.

Best regards,
Johan