cancel
Showing results for 
Search instead for 
Did you mean: 

Touch event problem

S.Mirza
Associate II

Hi. I generate a touchgfx project that toggle an led by pressing a button. the problem is trigger action by clicking button is randomly happen. the problem comes from that the touch function gets some touch sample and they slightly different .How do I fix this Issue?

12 REPLIES 12
S.Mirza
Associate II

Hello. the touch works but if I want turn on the led by clicking the button, sometime at the first try the led turns on and sometimes I have to try multiple time(As I show it at the video I uploaded). When I fixed the touch point manually inside the code and press the button it works perfectly for that specific point. The problem is when I touch the screen the read point vary slightly. The color of button change(it show that the press screen is sensed) but the corresponding function work randomly.

for propagate the touch event I used below code:

bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y)

{

  

 if(XPT2046_TouchPressed())

 {

  XPT2046_TouchGetCoordinates((uint16_t*) &x, (uint16_t*) &y);

  return true;

 }

  /**

   * 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);

   *

   */

  return false;

}

Alexandre RENOUX
Principal

Hello,

If the TouchController is correctly implemented, the color change when the button is clicked should happen correctly. It should not be a problem on TouchGFX Framework and Designer side.

You are using a Touch panel different from what we provide (from my knowledge). If the coordinates of the touched point that you receive are wrong, the communication between your touch panel and the MCU via SPI might be unstable. Verify this part because to me it's the most probable issue in your situation.

/Alexandre

S.Mirza
Associate II

Hello. You are right Alexandre RENOUX(ST Employee). I found the problem. When I touch the touch screen, the function return the true coordinate but at the moment I release the touch, the last coordinate was unvalid (I mean the last coordinate that the function returned is outside of the range. ) so I filtered the unvalide coordinate and the problem solved.

thanks to everyone.