From: Mathias Andersson Date: Sun, 28 Apr 2013 16:54:38 +0000 (+0200) Subject: Fix debouncing on Phantom. X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=3d503c8932b981ceb772c2e4e605607f421b49bf;p=max%2Ftmk_keyboard.git Fix debouncing on Phantom. --- diff --git a/keyboard/phantom/matrix.c b/keyboard/phantom/matrix.c index 7ea494a7..7b2461dc 100644 --- a/keyboard/phantom/matrix.c +++ b/keyboard/phantom/matrix.c @@ -24,10 +24,8 @@ static uint8_t debouncing = DEBOUNCE; // bit array of key state(1:on, 0:off) -static matrix_row_t *matrix; -static matrix_row_t *matrix_debounced; -static matrix_row_t matrix0[MATRIX_ROWS]; -static matrix_row_t matrix1[MATRIX_ROWS]; +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; #define _DDRA (uint8_t *const)&DDRA @@ -165,11 +163,9 @@ void matrix_init(void) // initialize matrix state: all keys off for (uint8_t i=0; i < MATRIX_ROWS; i++) { - matrix0[i] = 0; - matrix1[i] = 0; + matrix[i] = 0; + matrix_debouncing[i] = 0; } - matrix = matrix0; - matrix_debounced = matrix1; } uint8_t matrix_scan(void) @@ -178,10 +174,10 @@ uint8_t matrix_scan(void) pull_column(col); // output hi on theline _delay_us(3); // without this wait it won't read stable value. for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-5 - bool prev_bit = matrix[row] & ((matrix_row_t)1<