bxparks / AceButton

An adjustable, compact, event-driven button library for Arduino that debounces and dispatches events to a user-defined event handler.
MIT License
385 stars 37 forks source link

reduce default debounce delay from 50 ms to 20 ms #14

Closed bxparks closed 6 years ago

bxparks commented 6 years ago

I'm going to change the default debouncing delay kDebounceDelay from 50 ms to 20 ms.

I have noticed that at 50 milliseconds, a button can feel sluggish if I push it up and down fast enough. With the current delay of 50 ms, a Pressed event is delayed by 50 ms, then a Released event is delayed by 50 ms, for a total delay of at least 100 ms, and it is actually possible to push a button up and down fast enough for the library to miss real button events. At 20 ms, a button feels far more responsive.

This extensive article (http://www.ganssle.com/debouncing-pt2.htm) says that most switches will settle down within 10 ms, and recommends a debounce time of 20-50 ms. I'm going with the lower end of that.

This change means that the AceButton::check() must be called a little more frequently than before. So instead of calling it every 10-20 ms, it should be called every 5 ms or lower.

End-users are, of course, always free to override the default values of any of the timing parameters.