FTDI Community

General Category => Discussion - Software => Topic started by: scorpioprise on March 19, 2019, 04:43:20 PM

Title: EVE down signal: sensing continuous
Post by: scorpioprise on March 19, 2019, 04:43:20 PM
Hi there, have you any idea on how to detect that you have a long click on (for instance) a imagebutton ( and do something different in your code ) ?
It involves the down signal, ok, but how would you modify it?

Title: Re: EVE down signal: sensing continuous
Post by: FTDI Community on March 20, 2019, 12:53:39 PM
Hello,

You can check for a pen down condition where the REG_TOUCH_SCREEN_XY becomes not-equal-to 0x80008000 and likewise a pen-up condition where it changes from a coordinate to value 0x80008000. You can use a small state machine or if-else routine in your code to track the previous and current values and therefore detect pen-down and pen-up conditions.   You can use these along with a counter in your MCU code to detect the length of touch that was held on the screen.

As the item is normally a tagged object, you can monitor the tag value and count the number of polls of the tag register where the tag remains at the value of the object being monitored. This can be used to determine how long the touch was held for.

You can also combine these two techniques to allow you to detect both how long a touch is held and for how long it was on the particular tagged item being monitored. e.g. if you detect pen-down, also poll the TOUCH_TAG register to confirm that the touch is actually on the image button whilst waiting for the pen-up.

If you use interrupts, there are also interrupts available for both touch detect and the tag value changing which could be used to reduce the polling required in the above cases.

Best Regards,
FTDI Community