Disable touch controller while running the code.
Hello everyone,
I've been pondering the most effective method to disable touch functionality while running my application. It's crucial for me to do so because I'm developing an RF product that could potentially cause interference with touch inputs.
Should I incorporate some logic within the function below, or is there a better approach to achieve this?
Thank you for your insights!
bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y)
{
/**
* By default sampleTouch returns false,
* return true if a touch has been detected, otherwise false.
*
* Coordinates are passed to the caller by reference by x and y.
*
* This function is called by the TouchGFX framework.
* By default sampleTouch is called every tick, this can be adjusted by HAL::setTouchSampleRate(int8_t);
*
*/
uint8_t rx_buf[16] = {0};
if (TouchINT_irq)
// if (! HAL_GPIO_ReadPin( CTP_INT_GPIO_Port, CTP_INT_Pin ) )
{
TouchINT_irq = 0;
if (HAL_OK != HAL_I2C_Master_Receive(&hi2c1, (0x41 << 1), rx_buf, 16, 100))
{
return false;
}
if (rx_buf[0] == 0x48)
{
X_touch = 0;
X_touch = rx_buf[3] & 0x0F;
X_touch <<= 8;
X_touch |= rx_buf[2];
Y_touch = 0;
Y_touch = rx_buf[5] & 0x0F;
Y_touch <<= 8;
Y_touch |= rx_buf[4];
*(int32_t*)&x = X_touch;
*(int32_t*)&y = Y_touch;
return true;
}
else
{
return false;
}
}
return false;

