summaryrefslogtreecommitdiffstats
path: root/quantum/debounce
diff options
context:
space:
mode:
authoralex-ong <the.onga@gmail.com>2019-01-26 07:29:02 +0100
committeralex-ong <the.onga@gmail.com>2019-01-26 07:29:02 +0100
commit4d8733591f30a299d6ac99165c834162d2c08fd1 (patch)
tree73e3d008c0b52bf1d161483969b9e1ff975f3e88 /quantum/debounce
parent123608fb318a42500d64d29aa46c7d08140033fd (diff)
downloadqmk_firmware-4d8733591f30a299d6ac99165c834162d2c08fd1.tar.gz
qmk_firmware-4d8733591f30a299d6ac99165c834162d2c08fd1.tar.xz
Working eager_pk
Diffstat (limited to 'quantum/debounce')
-rw-r--r--quantum/debounce/debounce_eager_pk.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/quantum/debounce/debounce_eager_pk.c b/quantum/debounce/debounce_eager_pk.c
index e6e8bfd31..f1457496e 100644
--- a/quantum/debounce/debounce_eager_pk.c
+++ b/quantum/debounce/debounce_eager_pk.c
@@ -39,22 +39,16 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred.
#define debounce_counter_t uint8_t
-static matrix_row_t matrix_debounced[MATRIX_ROWS];
static debounce_counter_t debounce_counters[MATRIX_ROWS*MATRIX_COLS];
#define DEBOUNCE_ELAPSED 251
#define MAX_DEBOUNCE (DEBOUNCE_ELAPSED - 1)
-void update_debounce_counters(uint8_t current_time);
-void transfer_matrix_values(uint8_t current_time);
+void update_debounce_counters(uint8_t num_rows, uint8_t current_time);
+void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time);
-void matrix_debounce_init(void)
+void debounce_init(uint8_t num_rows)
{
- for (uint8_t r = 0; r < MATRIX_ROWS; r++)
- {
- matrix_debounced[r] = 0;
- }
-
int i = 0;
for (uint8_t r = 0; r < MATRIX_ROWS; r++)
{
@@ -65,25 +59,24 @@ void matrix_debounce_init(void)
}
}
-void matrix_debounce(void)
+void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed)
{
uint8_t current_time = timer_read() % MAX_DEBOUNCE;
- update_debounce_counters(current_time);
- transfer_matrix_values(current_time);
+ update_debounce_counters(num_rows, current_time);
+ transfer_matrix_values(raw, cooked, num_rows, current_time);
}
//If the current time is > debounce counter, set the counter to enable input.
-void update_debounce_counters(uint8_t current_time)
+void update_debounce_counters(uint8_t num_rows, uint8_t current_time)
{
debounce_counter_t *debounce_pointer = debounce_counters;
- for (uint8_t row = 0; row < MATRIX_ROWS; row++)
+ for (uint8_t row = 0; row < num_rows; row++)
{
for (uint8_t col = 0; col < MATRIX_COLS; col++)
{
if (*debounce_pointer != DEBOUNCE_ELAPSED)
{
- if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >=
- DEBOUNCING_DELAY) {
+ if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) {
*debounce_pointer = DEBOUNCE_ELAPSED;
}
}
@@ -93,13 +86,13 @@ void update_debounce_counters(uint8_t current_time)
}
// upload from raw_matrix to final matrix;
-void transfer_matrix_values(uint8_t current_time)
+void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time)
{
debounce_counter_t *debounce_pointer = debounce_counters;
- for (uint8_t row = 0; row < MATRIX_ROWS; row++)
+ for (uint8_t row = 0; row < num_rows; row++)
{
- matrix_row_t existing_row = matrix_debounced[row];
- matrix_row_t raw_row = matrix_get_row(row);
+ matrix_row_t existing_row = cooked[row];
+ matrix_row_t raw_row = raw[row];
for (uint8_t col = 0; col < MATRIX_COLS; col++)
{
@@ -114,10 +107,12 @@ void transfer_matrix_values(uint8_t current_time)
}
debounce_pointer++;
}
- matrix_debounced[row] = existing_row;
+ cooked[row] = existing_row;
}
}
+bool debounce_active()
+{
+ return true;
+}
-
-//Implementation of no debounce.