I would also like to know. I am using an off board touch controller interfaced with I2C to the STM32 MCU. It can use polling to read XY or also trigger an interrupt when XY changes for MCU to read new XY. How would this driver be connected to TouchGFX?
For TouchGFX Touch Controller Drivers you must satisfy the following interface which is called by HAL in every tick:
/**
* @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;
It usually goes something like this, using your own drivers
Is touch detected?
Retrieve X and Y
Set x and y input parameters to retrieved touch values
Example code:
Finger finger; //only single touch through x and y coords supported
if (touchDetected())
{
//Get sample for finger 1 and extract data
if (getSample(&finger))
{
x = finger.x;
y = finger.y;
return true;
}
}
return false;
Configure the TouchGFX HAL to use this touch controller: