Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About
I extended the current debounce logic with an adaptive by switch debouncing. This way a bad switch gets a higher debouncing as a good switch.
How it works
The debounce filtering reports a key/switch change directly as before, without any extra delay. The new thing is that the debounce logic will filter all further changes, until the key/switch reports the same state for the given count of scans. As long as the switch toggles the internal debounce counter of the switch will set to DEBOUNCE from config.h. The counter is decreased every scan where the switch didn't changed it's state.
So a perfect switch will get a short debounce period (min. DEBOUNCE) and a bad key will get a much longer debounce period. The result is an adaptive debouncing period for each switch.
In other words this gives an adaptive debouncing period for each switch / keypress.
Background
I've got an ergodox with kailh cooper switches. I love this switches but the operation point and the reset point are very close together, directly on the pressure point. So a slightly wobbling of the key creates a double key press, when you type slowly without bottoming out. With the old debouncing (before #1279) this wasn't a problem. But since then, some of my keys needed a debouncing value of 35. With this patch I could reduce DEBOUNCE scan count to 10 without any problems, even super fast double key presses are correctly detected with out bouncing. Slow-mo typing without bottoming out, which means I hold the key directly between operation and reset point, is no longer a problem. So with this patch the ergodox-ez should be faster (DEBOUNCE is now 10) and more robust against bouncing.
@ezuk Do you see any problems with this? I think this should reduce the bounce problem of the mentioned ergodox-ez batches in the comment.