WiringProject/Wiring — pull request #28 by bhagman (2012-11-15 17:12:54+00:00)
Title: Changed framework/libraries/Button

changed isPressed() to scan(), as I found using the isPressed() method awkward in terms of readability, in event mode.

added property sets:
- setDebounceDelay (changed from setDebounceTime)
- setHoldRepeat (to set repeat calls to the Hold event)

added property gets:
- getPin (to identify the button in handlers)
- getHoldRepeatCount (to get the number of times the hold event has been called during the current hold)

changed the size of some of the reporting members
- times, since they could be longer than 65 seconds
- numberOfPresses, since you could conceivably have more than 65K presses on a single button.

I cleaned up the debounce logic.

I changed the multi click functionality - and IMO the logical way to do it. See below.

The onClick handler isn't called unless the multi click threshold has expired, and it will only fire ONCE for multi clicks. So, if the multi click threshold is 0, then ALL clicks events are fired, but if it is > 0, then only a single click event is fired if more than one click fits within the threshold. What this means is that if you get a "double click", then you only get a single click event, and it is identified as a "double click" - you could theoretically have a octuple click - eek! :)

Finally, the main reason for the changes - I needed Hold event repeats! So now it's done. Now, if the button is held longer than the initial hold threshold + hold repeat, a second Hold event will be fired. If held longer, it will continue to call the Hold event, according to the holdEventRepeatTime interval. There is a reporting member (getHoldRepeatCount) to get the number of times the hold event has been called.

Signed-off-by: Brett Hagman (bhagman-ws1)