How can I handle a button in TouchGFX that allows me to switch on a LED when it is pressed, and switch off it when I release the button? The following code works but it switches the LED on/off every time you touch/untouch the screen...
void Screen1View::handleClickEvent(const ClickEvent& event)
{
if((event.getType() == ClickEvent::PRESSED))
{
HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_SET);
HAL_Delay(50);
}
if((event.getType() == ClickEvent::RELEASED))
{
HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_RESET);
}
}
If I use "flexButtonCallbackHandler(const touchgfx::AbstractButtonContainer& event)" function I can detect if button1, button2, etc were pressed, but I cannot detect if a button was released ... Any suggest?