cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing custom touch controller... Advice needed

HBosh
Associate

Hi colleagues,

I'm facing some problems interfacing the I2C touch controller of my LCD dislay.

The board's LCD works perfect using only MXCube for hardware configuration and Attolic to debug.

Please give me advice what will be the best way to make a custom .c/.h files which I could be able to use only to this hardware configuration, to talk to the msp.c file generated by the MXCube and interface to the touchGFX properly as well.

Please share some similar projects or tutorials for this particular example.

1 REPLY 1
Martin KJELDSEN
Chief III

In terms of the TouchGFX interface, what you need to do is supply the implementation details for the methods TouchController::init() and TouchController::sampleTouch(). e.g.

void MyTouchController::init()
{
    BSP_TS_Init(LCD_GetXSize(), LCD_GetYSize());
}
 
bool MyTouchController::sampleTouch(int32_t& x, int32_t& y)
{
    TS_StateTypeDef state = { 0 };
    BSP_TS_GetState(&state);
    if (state.touchDetected)
    {
        x = state.touchX[0];
        y = state.touchY[0];
 
        return true;
    }
    return false;
}

You'll find a TouchController class for each board in the Application Templates downloaded through the designer. So, you just need to develop your driver (And maybe configure I2C during system start up) and interface with it through TouchGFX.

/Martin