Wednesday, April 25th 2018, 12:38am UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

rayf15

Beginner

Date of registration: Feb 4th 2014

Posts: 3

1

Tuesday, February 4th 2014, 10:11am

Touchscreen events...

Hello,
I hope this is the right place for my topic.


We are evaluating the use of emWIN (precompiled library version downloaded from LPCWARE) on our target (NXP LPC1788 with 7 inches LCD and resistive touchscreen).
The custom configuration of our display and touch screen went ok (we use builtin analog touch screen driver), but we have troubles with touchscreen events... I mean sometimes, not ever, when there is a new touch event on the screen it seems that the emWIN windows manager recognize a touch event in the last place when there has been the last touch before the current one.
For example, let's suppose there are 2 buttons on the screen, when I permanently touch button 1 it is correctly drawn pushed by windows manager. After the button 1 is released, and I push button 2, there is at first a "glitch" that before pressing as expected button 2, hits again button 1 for only a small period of time.
I suppose that I miss some update of the event related to the touchscreen...


Below there is an extract of our LCDConf.c where function ExecTouch() is called every 10ms as suggested on documentation.

[b]

TP_GetTouchData(&pos), as name explains, return 1 if there is a touch event on the screen. In this case _TouchX and _TouchY are updated
by new values returned by TP_GetTouchData(&pos). _TouchX and _TouchY are in turn the global values retuned by GUI_TOUCH_X_MeasureX and
GUI_TOUCH_X_MeasureY functions.

...
void ExecTouch(void)
{
GUI_PID_STATE State;
st_TP_Coordinates pos;

if (_IsInited == 0) {
return;
}


if ( 1 == TP_GetTouchData(&pos) )
{
_PenIsDown = 1;

_TouchX = pos.x;
_TouchY = pos.y;

GUI_TOUCH_Exec();

}
else if (_PenIsDown)
{
//
// No further touch event after at least one touch event means we have
// lift the pen from the touchscreen.
//

_PenIsDown = 0;

GUI_PID_GetState(&State);
State.x = 0;
State.y = 0;
State.Pressed = 0;
GUI_PID_StoreState(&State);
}

}[/b]
...


We have debugged the code and every touch recognized by low level touchscreen driver has correct x and y position... maybe some wrong issue about FIFO events pushed by our driver and processed by window manager?


Have you any hints about this behavior?


Than you in advance.






Date of registration: May 26th 2009

Posts: 1,022

2

Wednesday, February 5th 2014, 9:43am

Hello,

I would recommend calling the function GUI_PID_StoreState() when the touch is released, but also when the touch is pressed. Beyond the call to the function GUI_TOUCH_Exec() should be done regardless the pressed state of the touch screen.

Best regards,
Adrian

rayf15

Beginner

Date of registration: Feb 4th 2014

Posts: 3

3

Wednesday, February 5th 2014, 11:25am

Thank you Mr. Adrian for your reply.

As you suggested, I tried to add a call to GUI_PID_StoreState() also when touchscreen is pressed.


C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
...if ( 1 == TP_GetTouchData(&pos) )
{
_PenIsDown = 1;

_TouchX = pos.x;
_TouchY = pos.y; 
GUI_PID_GetCurrentState(&State);State.x = pos.x;State.y = pos.y;State.Pressed = 1;
GUI_PID_StoreState(&State);
GUI_TOUCH_Exec();
}
...



In order to exclude weird errors on application level, I tried the "WIDGET_ButtonSimple" application code. With the above additions I can't hold the button pressed when touch is pressed, but in this case there is a quick sequence of button pressed-unpressed-pressed-unpressed... In addition, sometimes there is still the false capture of the last place when there has been the last touch before the current one.

On the other hand, if I try the Widget_ButtonSimple.exe file for PC downloadable from Segger website, the button marked as "Click me..." is held pressed while left mouse button on PC is held pressed over the button itself... and the button disappears when left button of mouse is released.

Please consider that the behavior of simple PC demo is exactly the same as the behavior of my original version (apart from the random last touch event...).

What else could I check/consider to solve my problem?

Thank you again.

rayf15

This post has been edited 1 times, last edit by "rayf15" (Feb 5th 2014, 11:26am)


Date of registration: May 26th 2009

Posts: 1,022

4

Thursday, February 6th 2014, 9:26am

Hello rayf15,

The emWin sample application WIDGET_ButtonSimple works as expected. You will have to implement your touch function in a way it passes the correct state of the touch screen to emWin.

Best regards,
Adrian

rayf15

Beginner

Date of registration: Feb 4th 2014

Posts: 3

5

Monday, February 17th 2014, 5:15pm

Hello,
just an update about my issue...I could not get the emWin builtin analog touch screen driver work, so I decided to write my custom version of driver using Generic touch screen APIs... and now everything work as expected.
I still have no idea about the incorrect behavior of my first version, but now, at least, I have a working touchscreen!


rayf15