Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

Sort of a code question, sort of a hardware question. I'm working on some microcontroller projects involving a standard 4-wire resistive touchscreen.

I roughly understand how touchscreen controllers detect when the screen is pressed (when the screen is inactive, tie Y+ to ground and set X- to input, and trigger an interrupt when X- goes to ground, or something along those lines).

What I'm not sure about is how to detect a dragging motion on the screen, such as how a slider would be manipulated. In my head, the definition of a drag is a situation where the screen stays pressed, but the coordinate of the press is moving. Does this definition make sense? How do I detect such an event in code? I'm lost as to the logic to read a sliding motion.

share|improve this question
    
I think you kind of answered this yourself - detect a touch, then track the coordinates of the touch as it moves. If the movement matches your "slide motion" threshold (touch was never broken, touch location moved in a certain direction), then call it such and respond with some action. –  Kurt E. Clothier May 16 '13 at 4:02
    
I'm not sure how to detect if the touch is continuous though. I can detect when the touch starts but I'm not sure how to confirm that the touch is sustained as the cursor moves. If I just look for movement of the touch location, it could potentially interpret a bunch of taps in a line as a "slide". –  tummychow May 16 '13 at 4:04
    
There are controller chips which do this, and put out data that just has to be parsed. I was recently working with an EGalax touchscreen that supports multitouch. Basically it puts out the info out on an I2C bus, and you have to parse it. The tracking of multiple touches (which are identified by integers) is done by the hardware. –  Kaz May 16 '13 at 4:33
    
When a finger is lifted, then the hardware generates a message which indicates that that contact number has ended. So while you are getting coordinates for a contact number and not seeing that termination message, you can assume that it's a continuous swipe and not a series of touches. –  Kaz May 16 '13 at 4:35
    
Okay, so what I'm thinking is I'll poll the touchscreen for the pen-down signal, and then read the ADC a few times to find the touch position. Then I'll check the pen-down signal again once the last conversion is done, to see if the pen is STILL down, and then continue like that until the pendown signal is no longer asserted. –  tummychow May 16 '13 at 6:15
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.