2024-02-15 07:51 AM
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:
I have modified this:
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.
Solved! Go to Solution.
2024-03-21 04:03 AM
Hello @MEde.1 ,
Were you able to solve your issue ?
Regards,