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

@ -46,11 +46,12 @@ void debounce_free(void) {
last_raw = NULL;
}
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
uint16_t now = timer_read();
uint16_t elapsed16 = TIMER_DIFF_16(now, last_time);
last_time = now;
uint8_t elapsed = (elapsed16 > 255) ? 255 : elapsed16;
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
uint16_t now = timer_read();
uint16_t elapsed16 = TIMER_DIFF_16(now, last_time);
last_time = now;
uint8_t elapsed = (elapsed16 > 255) ? 255 : elapsed16;
bool cooked_changed = false;
uint8_t* countdown = countdowns;
@ -63,10 +64,13 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
} else if (*countdown > elapsed) {
*countdown -= elapsed;
} else if (*countdown) {
cooked_changed |= cooked[row] ^ raw_row;
cooked[row] = raw_row;
*countdown = 0;
}
}
return cooked_changed;
}
bool debounce_active(void) {