Make debounce() signal changes in the cooked matrix as return value (#17554)
This commit is contained in:
parent
cca5d35321
commit
8224f62806
13 changed files with 83 additions and 39 deletions
|
@ -20,6 +20,7 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
|
|||
#include "matrix.h"
|
||||
#include "timer.h"
|
||||
#include "quantum.h"
|
||||
#include <string.h>
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 5
|
||||
#endif
|
||||
|
@ -30,18 +31,23 @@ static fast_timer_t debouncing_time;
|
|||
|
||||
void debounce_init(uint8_t num_rows) {}
|
||||
|
||||
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 cooked_changed = false;
|
||||
|
||||
if (changed) {
|
||||
debouncing = true;
|
||||
debouncing_time = timer_read_fast();
|
||||
}
|
||||
|
||||
if (debouncing && timer_elapsed_fast(debouncing_time) >= DEBOUNCE) {
|
||||
for (int i = 0; i < num_rows; i++) {
|
||||
cooked[i] = raw[i];
|
||||
if (memcmp(cooked, raw, sizeof(matrix_row_t) * num_rows) != 0) {
|
||||
memcpy(cooked, raw, sizeof(matrix_row_t) * num_rows);
|
||||
cooked_changed = true;
|
||||
}
|
||||
debouncing = false;
|
||||
}
|
||||
|
||||
return cooked_changed;
|
||||
}
|
||||
|
||||
void debounce_free(void) {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue