diff options
author | Andrew Pritchard <awpr@google.com> | 2017-04-26 15:29:39 -0700 |
---|---|---|
committer | Andrew Pritchard <awpr@google.com> | 2017-04-26 15:29:39 -0700 |
commit | cd30a60d0e4f108403b19ec4c1bc4270b54b8c27 (patch) | |
tree | eacc9a73728bc060c5a71e668a47cfeeee69c430 /keyboards/ergodox/ez/config.h | |
parent | 7bd4559b4b8f323107de46ebf90d31bfa9880e78 (diff) |
Change to per-key eager debouncing for ErgoDox EZ.
Empirically, waiting for N consecutive identical scans as a debouncing
strategy doesn't work very well for the ErgoDox EZ where scans are very
slow compared to most keyboards. Instead, debounce the signals by
eagerly reporting a change as soon as one scan observes it, but then
ignoring further changes from that key for the next N scans.
This is implemented by keeping an extra matrix of uint8 countdowns, such
that only keys whose countdown is currently zero are eligible to change.
When we do observe a change, we bump that key's countdown to DEBOUNCE.
During each scan, every nonzero countdown is decremented.
With this approach to debouncing, much higher debounce constants are
tolerable, because latency does not increase with the constant, and
debounce countdowns on one key do not interfere with events on other
keys. The only negative effect of increasing the constant is that the
minimum duration of a keypress increases. Perhaps I'm just extremely
unlucky w.r.t. key switch quality, but I saw occasional bounces even
with DEBOUNCE=10; with 15, I've seen none so far. That's around 47ms,
which seems like an absolutely insane amount of time for a key to be
bouncy, but at least it works.
Diffstat (limited to 'keyboards/ergodox/ez/config.h')
-rw-r--r-- | keyboards/ergodox/ez/config.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/keyboards/ergodox/ez/config.h b/keyboards/ergodox/ez/config.h index a3347de45e..aa17c3e8d3 100644 --- a/keyboards/ergodox/ez/config.h +++ b/keyboards/ergodox/ez/config.h @@ -58,7 +58,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define RGBW 1 /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCE 15 #define USB_MAX_POWER_CONSUMPTION 500 |