diff options
Diffstat (limited to 'quantum/debounce/sym_defer_g.c')
| -rw-r--r-- | quantum/debounce/sym_defer_g.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/quantum/debounce/sym_defer_g.c b/quantum/debounce/sym_defer_g.c index 3ed9055d2..fbefd55ed 100644 --- a/quantum/debounce/sym_defer_g.c +++ b/quantum/debounce/sym_defer_g.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2017 Alex Ong<the.onga@gmail.com> | 2 | Copyright 2017 Alex Ong<the.onga@gmail.com> |
| 3 | Copyright 2021 Simon Arlott | ||
| 3 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify |
| 4 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
| 5 | the Free Software Foundation, either version 2 of the License, or | 6 | the Free Software Foundation, either version 2 of the License, or |
| @@ -23,30 +24,29 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state. | |||
| 23 | # define DEBOUNCE 5 | 24 | # define DEBOUNCE 5 |
| 24 | #endif | 25 | #endif |
| 25 | 26 | ||
| 26 | void debounce_init(uint8_t num_rows) {} | 27 | #if DEBOUNCE > 0 |
| 27 | static bool debouncing = false; | 28 | static bool debouncing = false; |
| 29 | static fast_timer_t debouncing_time; | ||
| 28 | 30 | ||
| 29 | #if DEBOUNCE > 0 | 31 | void debounce_init(uint8_t num_rows) {} |
| 30 | static uint16_t debouncing_time; | 32 | |
| 31 | void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { | 33 | void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { |
| 32 | if (changed) { | 34 | if (changed) { |
| 33 | debouncing = true; | 35 | debouncing = true; |
| 34 | debouncing_time = timer_read(); | 36 | debouncing_time = timer_read_fast(); |
| 35 | } | 37 | } |
| 36 | 38 | ||
| 37 | if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) { | 39 | if (debouncing && timer_elapsed_fast(debouncing_time) >= DEBOUNCE) { |
| 38 | for (int i = 0; i < num_rows; i++) { | 40 | for (int i = 0; i < num_rows; i++) { |
| 39 | cooked[i] = raw[i]; | 41 | cooked[i] = raw[i]; |
| 40 | } | 42 | } |
| 41 | debouncing = false; | 43 | debouncing = false; |
| 42 | } | 44 | } |
| 43 | } | 45 | } |
| 44 | #else // no debouncing. | ||
| 45 | void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { | ||
| 46 | for (int i = 0; i < num_rows; i++) { | ||
| 47 | cooked[i] = raw[i]; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | #endif | ||
| 51 | 46 | ||
| 52 | bool debounce_active(void) { return debouncing; } | 47 | bool debounce_active(void) { return debouncing; } |
| 48 | |||
| 49 | void debounce_free(void) {} | ||
| 50 | #else // no debouncing. | ||
| 51 | # include "none.c" | ||
| 52 | #endif | ||
