Capacitive touch - trapping a long press?


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Capacitive touch - trapping a long press?

    Quote Originally Posted by rsocor01 View Post
    You might be able to use some code for a long press in a regular pushbutton and convert it to what you need. Robert
    Hi Robert, unfortunately, I don't think that would be possible.

    With a regular button/switch press using interrupts, firstly an interrupt happens (ie when the switch is pressed), then in the interrupt routine the rogram just rechecks after a short while to see if the same condition is held.

    But with capacitive touch, you have to exit the interrupt routine in order to get the next 'timebase' (the timebase here being 'time' between a timer based based interrupt - & is used to count the output from the CPS module), in other words you can't hang around in the interrupt routine to see if the condition has held.
    Last edited by HankMcSpank; - 10th June 2011 at 09:25.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Capacitive touch - trapping a long press?

    HI Hank. Here I go with my counters again. Once you detect a "press", the pressed condition becomes the "normal" Then you are really checking for "unpress". Check the time between the 2, and determine if it was a long press short press or whatever. So the counter is used to count the time while waiting for the release.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default Re: Capacitive touch - trapping a long press?

    I was thinking of some logic outside the interrrupt routine, in the main program. In the interrupt routine you find the variables Last_High_Reading and Current_Reading. Even though the main program is stuck in a loop, it will still be going to the interrupt routine. I was thinking of something like this,

    Cnt = 0
    REPEAT 'Main program will be in this loop until sensor is released.
    Cnt = Cnt + 1
    Pause 2
    If Cnt > 500 then RETURN 'A long press was detected. Exit sub-routine.
    UNTIL Current_Reading > 0.8*Last_High_Reading
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Capacitive touch - trapping a long press?

    Thanks guys....I'll give both of those ideas some serious consideration as I hadn't considered either.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts