1
0
Fork 0

Make debounce() signal changes in the cooked matrix as return value (#17554)

This commit is contained in:
Stefan Kerkmann 2022-07-07 10:00:40 +02:00 committed by GitHub
parent cca5d35321
commit 8224f62806
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 83 additions and 39 deletions

View file

@ -49,6 +49,7 @@ static debounce_counter_t *debounce_counters;
static fast_timer_t last_time;
static bool counters_need_update;
static bool matrix_need_update;
static bool cooked_changed;
# define DEBOUNCE_ELAPSED 0
@ -71,8 +72,9 @@ void debounce_free(void) {
debounce_counters = NULL;
}
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool updated_last = false;
cooked_changed = false;
if (counters_need_update) {
fast_timer_t now = timer_read_fast();
@ -96,6 +98,8 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
transfer_matrix_values(raw, cooked, num_rows);
}
return cooked_changed;
}
// If the current time is > debounce counter, set the counter to enable input.
@ -132,6 +136,7 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
*debounce_pointer = DEBOUNCE;
counters_need_update = true;
existing_row ^= col_mask; // flip the bit.
cooked_changed = true;
}
}
debounce_pointer++;