Hi @Ebun.1,
TouchGFX HAL interfaces with touch controllers through the TouchController interface. If you use the generator or start from an AT you will have a file called STM32TouchController.cpp. It contains a method sampleTouch() - Here's an example for the F746G-DISCO TouchController. Simply use your new driver to get the touch coordinates and assign x and y, return true or false depending on "touched" or not.
bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y)
{
/* Checking if the screen has been touched */
if (tsDriver)
{
if (tsDriver->DetectTouch(TS_I2C_ADDRESS))
{
/* Get each touch coordinates */
tsDriver->GetXY(TS_I2C_ADDRESS, (uint16_t*)&y, (uint16_t*)&x);
return true;
}
}
return false;
}
Here's the interface class with documentation:
/**
* @fn virtual bool TouchController::sampleTouch(int32_t& x, int32_t& y) = 0;
*
* @brief Checks whether the touch screen is being touched, and if so, what coordinates.
*
* Checks whether the touch screen is being touched, and if so, what coordinates.
*
* @param [out] x The x position of the touch
* @param [out] y The y position of the touch
*
* @return True if a touch has been detected, otherwise false.
*/
virtual bool sampleTouch(int32_t& x, int32_t& y) = 0;