Skip to main content
S.Mirza
Associate II
May 22, 2020
Question

Touch event problem

  • May 22, 2020
  • 12 replies
  • 2600 views

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?

This topic has been closed for replies.

12 replies

Alexandre RENOUX
Visitor II
May 22, 2020

Hello,

Could you provide more information, pieces of code, something that showcases your issue ?

/Alexandre

S.Mirza
S.MirzaAuthor
Associate II
May 22, 2020

I just add toggle button code inside button function. I'll send a video for show the case.

http://s13.picofile.com/d/8397941400/e2cf349d-b62d-433b-8a0a-e69cf4fcbc38/buttonProblem.mp4

Karan 123
Senior
May 22, 2020

Hello,

Please send us code . I haven't faced this issue.

--

Karan

S.Mirza
S.MirzaAuthor
Associate II
May 22, 2020

Ok. This is my code. I create two button. one for turn LED 'ON' and another for Turn it OFF.

http://uupload.ir/filelink/79GxOweRqBbx/1t23_video6.rar

Alexandre RENOUX
Visitor II
May 25, 2020

Hello,

Can you upload this .rar project and .mp4 video directly on this thread instead ?

You will find a a paper clip logo on the left of the button "Answer" that allows you to enclose files.

Also what board are you using ? What version of TouchGFX Designer ? What IDE ? Please provide these information for us to have a better overview of your setup.

/Alexandre

S.Mirza
S.MirzaAuthor
Associate II
May 25, 2020

Hello,

Unfortiunatly I couldn't upload the code files here maybe because the size.

I used a costume board with stm32f429ig microcontroller, XPT2046 Touch Screen Controller, MT48LC16M16A2P SDRAM.

touchGfx 4.13.0, cubeMx 5.6, IAR 8.2.

If you couldn't download the code file from the URL that I sent, please give me an email address to send that.

Alexandre RENOUX
Visitor II
May 26, 2020

Hello,

Can you provide the gui/ folder and .touchgfx file ? This should be very small in size.

It might also be a problem regarding your touch controller implementation. Please provide also the code of your touch controller implementation.

How did you create your application ?

/Alexandre

S.Mirza
S.MirzaAuthor
Associate II
May 27, 2020

I used cubeMx to create the project. I added the touchGfx v 4.13.0 to the cubemx. the I open the ApplicationTemplate.touchgfx.part file inside the Src folder that created by cubeMx. In the touchGfx I just addet two button and define two interaction "call new virtual function". I opened the IAR compiler and add some code to turn on and turn off the LED. I added these code in Screen 1ViewBase.hpp file. When I simulate the project it work fine but when I programe it on the hardware the problem show up. I attach the touch screen files.

Alexandre RENOUX
Visitor II
May 28, 2020

Hello,

Have you tried debugging with IAR ?

When you press the button on your screen does it go correctly into the sampleTouch function in STM32TouchController.cpp ?

How do you propagate the touch event to your GUI ?

/Alexandre

S.Mirza
S.MirzaAuthor
Associate II
May 28, 2020

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
Visitor II
May 29, 2020

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