forked from mirrors/qmk_userspace
[Enhancement] Improvements for debounce test coverage + bug fixes for sym_defer_g and sym_eager_pr (#21667)
Co-authored-by: Nebuleon <2391500+Nebuleon@users.noreply.github.com>
This commit is contained in:
parent
dd94877ec6
commit
960d6e0d7d
15 changed files with 458 additions and 23 deletions
|
@ -24,6 +24,12 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
|
|||
# define DEBOUNCE 5
|
||||
#endif
|
||||
|
||||
// Maximum debounce: 255ms
|
||||
#if DEBOUNCE > UINT8_MAX
|
||||
# undef DEBOUNCE
|
||||
# define DEBOUNCE UINT8_MAX
|
||||
#endif
|
||||
|
||||
#if DEBOUNCE > 0
|
||||
static bool debouncing = false;
|
||||
static fast_timer_t debouncing_time;
|
||||
|
@ -36,11 +42,10 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
|
|||
if (changed) {
|
||||
debouncing = true;
|
||||
debouncing_time = timer_read_fast();
|
||||
}
|
||||
|
||||
if (debouncing && timer_elapsed_fast(debouncing_time) >= DEBOUNCE) {
|
||||
if (memcmp(cooked, raw, sizeof(matrix_row_t) * num_rows) != 0) {
|
||||
memcpy(cooked, raw, sizeof(matrix_row_t) * num_rows);
|
||||
} else if (debouncing && timer_elapsed_fast(debouncing_time) >= DEBOUNCE) {
|
||||
size_t matrix_size = num_rows * sizeof(matrix_row_t);
|
||||
if (memcmp(cooked, raw, matrix_size) != 0) {
|
||||
memcpy(cooked, raw, matrix_size);
|
||||
cooked_changed = true;
|
||||
}
|
||||
debouncing = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue