cancel
Showing results for 
Search instead for 
Did you mean: 

Switching the screen by Hardware button.

KM L.1
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
Alexandre RENOUX
Principal

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

View solution in original post

3 REPLIES 3
Alexandre RENOUX
Principal

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

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

  }

}

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