cancel
Showing results for 
Search instead for 
Did you mean: 

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

Lli.1
Associate II
 
5 REPLIES 5
Lli.1
Associate II

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

Lli.1
Associate II

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

PDeck.2281
Associate III

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?

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
Chief III

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