cancel
Showing results for 
Search instead for 
Did you mean: 

Disable touch controller while running the code.

GMene.785
Associate II

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;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Osman SOYKURT
ST Employee

Hello @GMene.785 ,

I invite you to edit your post and use this code sample button :

OsmanSOYKURT_0-1709118425345.png

 

To answer your question, it depends on what you exactly want to achieve here.

To me, there are 3 ways to "disable" touch.

1) You set your screen with TouchGFX to not react to any touch. This means that the touch event is detected still (by the screen driver and then the TouchController) but triggers nothing. 

2) You use the sampleTouch() function to return only false. But here also, the touch event is detected from the screen driver.

3) You use one function from your screen driver to disable the touch screen (if there's any). TouchGFX and the TouchController have no information from the driver that a touch has ever occurred.

You could try to use a logic analyzer and see if for each of these suggestions the touch inputs are causing interference.

Osman SOYKURT
ST Software Developer | TouchGFX

View solution in original post

2 REPLIES 2
Osman SOYKURT
ST Employee

Hello @GMene.785 ,

I invite you to edit your post and use this code sample button :

OsmanSOYKURT_0-1709118425345.png

 

To answer your question, it depends on what you exactly want to achieve here.

To me, there are 3 ways to "disable" touch.

1) You set your screen with TouchGFX to not react to any touch. This means that the touch event is detected still (by the screen driver and then the TouchController) but triggers nothing. 

2) You use the sampleTouch() function to return only false. But here also, the touch event is detected from the screen driver.

3) You use one function from your screen driver to disable the touch screen (if there's any). TouchGFX and the TouchController have no information from the driver that a touch has ever occurred.

You could try to use a logic analyzer and see if for each of these suggestions the touch inputs are causing interference.

Osman SOYKURT
ST Software Developer | TouchGFX

Hello @GMene.785 ,

Did you succeed in disabling the touch controller? Do you need more assistance?

Osman SOYKURT
ST Software Developer | TouchGFX