Skip to main content
Lli.1
Associate
Jan 11, 2020 7:11 AM UTC
Question

Hello, is there an official tutorial for touch ports that is not a Discovery board

..

This topic has been closed for replies.

5 replies

Lli.1
Lli.1Author
Associate
Jan 11, 2020 7:25 AM UTC

After writing the touch screen driver, where to implant the touch screen driver?When simulating IIC, are port pins set in CubeMX?

Lli.1
Lli.1Author
Associate
Jan 11, 2020 7:32 AM UTC

After looking at the official touch screen driver port, it is still unclear where the defined pins are implemented.

PDeck.2281
Associate
Jan 14, 2020 1:43 AM UTC

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?

Lli.1
Lli.1Author
Associate
Jan 14, 2020 1:46 AM UTC

I'm very glad to receive your reply, but I haven't made the touch driver yet. I'm sorry that I can't help you.

Martin KJELDSEN
Principal III
Jan 20, 2020 10:23 AM UTC

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

  1. Is touch detected?
  2. Retrieve X and Y
  3. 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:

MyTouchController tc;
void touchgfx_init()
{
 HAL& hal = touchgfx_generic_init<STM32F7HAL>(dma, display, tc, 480, 272, 0, 0);
 ...

/Martin