keymap: Improve debouncing behavior.

- Update debouncing code to properly handle rollover.
- Update ghost debouncing to properly set the debounce start time.

Signed-off-by: Evan Lojewski <github@meklort.com>
This commit is contained in:
Evan Lojewski 2020-05-06 20:21:42 -06:00 committed by Jeremy Soller
parent a6093d8708
commit 7aa5767455

View File

@ -227,11 +227,7 @@ void kbscan_event(void) {
// If debounce complete
if (debounce) {
uint32_t time = time_get();
//TODO: time test with overflow
if (time < debounce_time) {
// Overflow, reset debounce_time
debounce_time = time;
} else if (time >= (debounce_time + DEBOUNCE_DELAY)) {
if ((time - debounce_time) >= DEBOUNCE_DELAY) {
// Finish debounce
debounce = false;
}
@ -249,6 +245,7 @@ void kbscan_event(void) {
kbscan_ghost[i] = false;
// Debounce to allow remaining ghosts to settle.
debounce = true;
debounce_time = time_get();
}
// A key was pressed or released