Shop OBEX P1 Docs P2 Docs Learn Events
Simple Button - Page 2 — Parallax Forums

Simple Button

2»

Comments

  • cavelambcavelamb Posts: 720
    edited 2012-10-31 13:33
    TheVig wrote: »
    I think I just wrapped my head around this...

    Tracking time between the ON and OFF, then another ON and OFF, the program should be able to tell if a double tap occured.

    Does anyone have experience with a program like this, any catches I should be worried about? Especially if I try to ad a triple tap :cool:

    Yeah, some. Nothing is really cast in stone.
    Too many things that can differ from one device to the next.

    Just mess around with it some.
    Try different delays values.
    Try to "bracket" the delay a few times (short one, long one, less short one, less long one...)
    That should zero in a few minutes.

    Too long delays make the system feel sluggish, unresponsive.
    Too short, and the program responds to the bounces (as you noticed).

    I would think that once you get it working on one click, all the rest should work right.
    Remember, we are talking about machine speed here.

    The people part pressing the button should never notice this delay.
    It's for the machine part...

    As for the double and triple tap, I've not done those.
    Iwould think the trick is to catch the CNT after the first click and then
    decide if the next click is within the time limit you think proper for a
    double. Then again for a triple?

    Let's see what you come up with?
  • TheVigTheVig Posts: 41
    edited 2012-10-31 13:37
    I'm sending any commands on the first ON then doing the waiting around for the bounce to stop, so that helps ;-)
  • MagIO2MagIO2 Posts: 2,243
    edited 2012-10-31 13:45
    I think you should simply experiment a little bit. First try to find the best time to wait to eliminate the bouncing. It should be as little as possible. Then you can try to measure the time between two button pushs in case of a double/triple click.

    This would be the algorithm:
    wait for push
    wait for release
    wait for push for max. measured time between double/triple pushs
    if time exceeded it was a single click and go back to top
    wait for release
    wait for push for max. measured time between triple pushs
    if time exceeded it was a double click and go back to top
    else it was a triple click
    wait for release
    go back to top

    A few hours ago I found some other threads about debounce (simply search for debounce). There was one thread where Jonny Mac gave a "debounce" function which includes a maximum waittime. Maybe I'll find it again.
Sign In or Register to comment.