Closed fleetingbytes closed 6 years ago
Bounce is unwanted mechanical switching that occurs when a physical contactor moves from one state to another. The debounce time is a short time that allows the MCU to ignore the intermediate switching, thus eliminating the potential to detect multiple ACTIVE/INACTIVE transitions during the bounce period.
The actual switch 'pressed' detection occurs when the first transition of INACTIVE to ACTIVE switch states is detected, irrespective of the debounce time.
Hello Marco,
I see an issue with the debouncing algorithm. It doesn't ignore presses shorter than the debounce time. When I press a single digital button shorter than the duration set in setDebounceTime(), the keyResult_t still returns a KEY_SINGLE event.
Isn't the whole idea of debouncing such that only after the button has been continuously and steadily pressed for the time defined in setDebounceTime(), only then it is supposed to send the logical signal of a keypress?
I tested this with a purposefully long debounce time of 400 ms: