cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware button with TouchGFX for screen transition

Josh_W020
Associate II

Hi,

I have been trying to implement the functionality to change the currently active screen on TouchGFX using a hardware button with no luck so far.

I'm using an STM32H743zit6.

Here are the resources I've looked at but haven't managed to get working:

https://www.youtube.com/watch?v=ufvJ5bcesL8

https://www.youtube.com/watch?v=QgEDSjvGAlk

https://support.touchgfx.com/docs/development/scenarios/example-gpio

https://support.touchgfx.com/docs/development/board-bring-up/how-to/10-physical-buttons

https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/screen-transitions

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/hardware-button/td-p/640357

 

Any help would be greatly appreciated,

Thanks.

15 REPLIES 15

Hi,

I have tried implementing as you said:

#include <gui/common/FrontendApplication.hpp>

Model::Model() : modelListener(0)
{

}

void Model::tick()
{
    if (HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_2) == GPIO_PIN_RESET)
    {
        static_cast<FrontendApplication*>(Application::getInstance())->handleKeyEvent('A');
    }
}

But still have had no luck with it. Thanks for the suggestion though, I think that using handle key event to make it think I've pressed the 'A' key is a good way to do it. Just unsure why it hasn't worked in this case.

Hi,

Thanks for the response.

Is the MB1642ButtonController.cpp a file that you have created or one that is generated?

the reason I ask is that in my project I have ButtonController.hpp generated but don't have a file called ButtonController.cpp

Kind Regards,

Josh

Are you sure, you have on active screen created Interaction for handle A key , that start transition to next screen?

Next point is in debuger test if tick is realy executed and not blocked ...

I am sure tick is being executed as I also have another function in it that passes data from the main.c file to a graph I have set up and that works no problem. The key press also works in the simulator so that is not the issue. Furthermore I have ensured the physical button press is being detected on GPIO input and it is working.

Model.cpp:

#include <gui/model/Model.hpp>
#include <gui/model/ModelListener.hpp>
#include "stm32h7xx_hal.h"
#include <gui/common/FrontendApplication.hpp>

extern __IO uint16_t graphData[124];
extern __IO uint16_t buttonClicked;

Model::Model() : modelListener(0)
{

}

void Model::tick()
{
	for(int i = 0; i < 124; i++)
	{
		modelListener->UpdateGraph(i, graphData[i]);
	}

	if (HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_2) == GPIO_PIN_RESET)
	{
		static_cast<FrontendApplication*>(Application::getInstance())->handleKeyEvent('A');
	}
}

 

Hello @Josh_W020,

 

MB1642ButtonController.cpp was created, not generated.
This is because it has to be done by hand to link the correct GPIOs that are used for the hardware buttons.

Every project has the ButtonController.hpp file.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
Josh_W020
Associate II

HI,

Thought I'd update this incase anyone else is having the same issue.
In my project I am using an internal framebuffer. In order to set this up I followed this guide made by STM: https://support.touchgfx.com/docs/development/board-bring-up/how-to/03-display-internal
In the guide it specifically states to add the line:

 HAL_LTDC_ProgramLineEvent(&hltdc,0);

to the stm32h7xx_it.c file. However, adding this line will prevent tick from updating? So my tick function was only called once on startup and this if statement never checked: 

if (HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_2) == GPIO_PIN_RESET)
	{
		static_cast<FrontendApplication*>(Application::getInstance())->handleKeyEvent('A');
	}

 Removing that line from stm32h7xx_it.c fixed the issue and now tick updates as expected. Just out of curiosity if anyone can explain a bit of the reasoning behind this that would be great.

Thank you for the help,
Josh.