cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware button

MEde.1
Associate III

I have been struggling for a few days now with trying to trigger an interaction within TouchGFX (V4.23.1) via a hardware button.

The board is a STM32H747i Discovery. The board bring up has been completed with a standard TouchGFX template and the touch screen and display are working fine.

I have verified that I can toggle LED4 with the wake button suing a RTOS function

 

 

 

#define LED4_GPIO_Port GPIOI

#define LED4_Pin GPIO_PIN_15

...

/* USER CODE BEGIN RTOS_THREADS */

osThreadId_t toggleLEDTaskHandle;

const osThreadAttr_t toggleLEDTask_attributes = {

.name = "toggleLEDTask",

.stack_size = 128 * 4, // Adjust stack size as needed

.priority = (osPriority_t) osPriorityNormal,

};



toggleLEDTaskHandle = osThreadNew(ToggleLEDTask, NULL, &toggleLEDTask_attributes);



/* USER CODE END RTOS_THREADS */

...

/* USER CODE BEGIN 4 */

void ToggleLEDTask(void *argument) {

uint8_t ledState = 0; // Track LED state, 0 = off, 1 = on



for(;;) {

if(HAL_GPIO_ReadPin(BTN_USER_GPIO_Port, BTN_USER_Pin) == GPIO_PIN_SET) {

key = 1; // Set key to 1 to indicate button press



// If button is pressed, toggle the LED state

ledState = !ledState; // Toggle state

HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, ledState ? GPIO_PIN_SET : GPIO_PIN_RESET);



// Debounce delay and wait for button release

osDelay(200); // Adjust delay as needed for debounce

while(HAL_GPIO_ReadPin(BTN_USER_GPIO_Port, BTN_USER_Pin) == GPIO_PIN_SET){

osDelay(10); // Short delay to wait for button release

}

}

osDelay(10); // Small delay to prevent the task from hogging CPU resources

}





}







/* USER CODE END 4 */

...

 

 

I am pretty confident that the LED and USER_BTN are configured correctly as the LED toggles when I press the USR_BTN.

 

I am trying to follow this:

 

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

 

I am unsure where this code should be added:

 

MEde1_0-1708011935228.png

 

I have modified this:

MEde1_1-1708011989401.png

 

Everything compiles but whilst the LED toggles and the BTN_USER is selectable in the TouchGFX designer interactions drop down, the interaction doesn't get triggered. I am a bit stumped.

 

 

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
10 REPLIES 10
LouisB
ST Employee

Hello @MEde.1 ,

Were you able to solve your issue ?

Regards,

Louis BOUDO
ST Software Developer | TouchGFX