Hi Roger,
Let me just paste some of the code here from that article:
#include <platform/driver/button/ButtonController.hpp>
class H7B3ButtonController : public touchgfx::ButtonController
{
virtual void init() { }
virtual bool sample(uint8_t& key)
{
if (HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) != GPIO_PIN_RESET)
{
key = 1;
return true;
}
return false;
}
private:
};
...
H7B3ButtonController bc;
void TouchGFXHAL::initialize()
{
TouchGFXGeneratedHAL::initialize();
hal.setButtonController(&bc);
}
In this code you're defining a class that inherits from ButtonController and implementing the sample() function so that it reads a GPIO port where a button is connected. You can define this class anywhere you want in your program structure. Add the line hal.setButtonController(&bc) inside the initialize() function of your TouchGFXHAL.cpp.
When you configure your HAL via setButtonController() function to use the ButtonController you just defined to distribute the value returned from sample() to the active application. And by telling .touchgfx file about it you can now use that value as a tigger in an interaction
/Martin