From 5ed883afc905a20fbf29c8ef3de383f6a3c7d5de Mon Sep 17 00:00:00 2001 From: Evan Sailer Date: Tue, 23 May 2017 22:37:00 -0500 Subject: [PATCH] fixed matrix config for proper diode direction --- keyboard/bananasplit/matrix.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/keyboard/bananasplit/matrix.c b/keyboard/bananasplit/matrix.c index 0c6b16f0..ac8aa2e4 100644 --- a/keyboard/bananasplit/matrix.c +++ b/keyboard/bananasplit/matrix.c @@ -37,9 +37,6 @@ static uint8_t debouncing = DEBOUNCE; static matrix_row_t matrix[MATRIX_ROWS]; static matrix_row_t matrix_debouncing[MATRIX_ROWS]; -static matrix_row_t matrix_reversed[MATRIX_COLS]; -static matrix_row_t matrix_reversed_debouncing[MATRIX_COLS]; - static matrix_row_t read_cols(void); static void init_cols(void); static void unselect_rows(void); @@ -77,12 +74,12 @@ void matrix_init(void) uint8_t matrix_scan(void) { - for (uint8_t i = 0; i < MATRIX_COLS; i++) { + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { select_row(i); _delay_us(30); // without this wait read unstable value. - matrix_row_t rows = read_cols(); - if (matrix_reversed_debouncing[i] != rows) { - matrix_reversed_debouncing[i] = rows; + matrix_row_t cols = read_cols(); + if (matrix_debouncing[i] != cols) { + matrix_debouncing[i] = cols; if (debouncing) { debug("bounce!: "); debug_hex(debouncing); debug("\n"); } @@ -95,20 +92,12 @@ uint8_t matrix_scan(void) if (--debouncing) { _delay_ms(1); } else { - for (uint8_t i = 0; i < MATRIX_COLS; i++) { - matrix_reversed[i] = matrix_reversed_debouncing[i]; + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = matrix_debouncing[i]; } } } - for (uint8_t y = 0; y < MATRIX_ROWS; y++) { - matrix_row_t row = 0; - for (uint8_t x = 0; x < MATRIX_COLS; x++) { - row |= ((matrix_reversed[x] & (1<> y) << x; - } - matrix[y] = row; - } - return 1; } @@ -140,6 +129,15 @@ void matrix_print(void) } } +uint8_t matrix_key_count(void) +{ + uint8_t count = 0; + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + count += bitpop16(matrix[i]); + } + return count; +} + /* Column pin configuration * col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 * pin: F0 F1 E6 C7 C6 B6 D4 B1 B0 B5 B4 D7 D6 B3 (Rev.A) -- 2.39.3