Skip to main content
KM L.1
Associate III
August 19, 2020
Solved

Switching the screen by Hardware button.

  • August 19, 2020
  • 3 replies
  • 1576 views

How to switch the screens in touchgfx using hardware button .

I have tried it by creating queue but its not working. Can anyone share the reference code for the same.

Thank You

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

Hello,

To propagate the hardware button event to your UI, please refer to : https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/backend-communication as well as https://support.touchgfx.com/docs/development/board-bring-up/example-gpio#touchgfx-hal-development

Also you can look at the Application Template for L496G-DISCO available in TouchGFX Designer that implements a buttonController called KeySampler.

An easy way to do the transition after you received correctly the button event, is to create a dummy button outside the screen in the Designer and create a screen transition when this button is clicked. Then just copy paste the generated code line that looks like goToScreenxxx() in your handleKeyEvent() function.

Also please look at older posts before posting this kind of question. I'm pretty sure it was answered several times before.

/Alexandre

3 replies

Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II
August 20, 2020

Hello,

To propagate the hardware button event to your UI, please refer to : https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/backend-communication as well as https://support.touchgfx.com/docs/development/board-bring-up/example-gpio#touchgfx-hal-development

Also you can look at the Application Template for L496G-DISCO available in TouchGFX Designer that implements a buttonController called KeySampler.

An easy way to do the transition after you received correctly the button event, is to create a dummy button outside the screen in the Designer and create a screen transition when this button is clicked. Then just copy paste the generated code line that looks like goToScreenxxx() in your handleKeyEvent() function.

Also please look at older posts before posting this kind of question. I'm pretty sure it was answered several times before.

/Alexandre

ABanu.1
Associate
October 29, 2020

Hi,

After getting the code, what is the corrct process to change the UI screen with a hardware button.

Came accross some queries, but didnt understood properly. Please help me through this

//Handles when a key is pressed

void Screen1ViewBase::handleKeyEvent(uint8_t key)

{

  if(1 == key)

  {

    //Interaction2

    //When hardware button 1 clicked change screen to Screen2

    //Go to Screen2 with no screen transition

    application().gotoScreen2ScreenNoTransition();

  }

}

Alexandre RENOUX
Visitor II
October 30, 2020

What do you not understand in this piece of code ? Also this is some code generated by TouchGFX Designer because you created an interaction in Designer for a hardware button pressed. This must not be changed manually.

/Alexandre