aboutsummaryrefslogtreecommitdiff
path: root/quantum/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/matrix.c')
-rw-r--r--quantum/matrix.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c
index 07eb87bc3..5337e2626 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -1,6 +1,5 @@
1/* 1/*
2Copyright 2012 Jun Wako 2Copyright 2012-2017 Jun Wako, Jack Humbert
3Copyright 2014 Jack Humbert
4 3
5This program is free software: you can redistribute it and/or modify 4This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by 5it under the terms of the GNU General Public License as published by
@@ -60,13 +59,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
60 extern const matrix_row_t matrix_mask[]; 59 extern const matrix_row_t matrix_mask[];
61#endif 60#endif
62 61
62#if (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)
63static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; 63static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
64static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; 64static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
65#endif
65 66
66/* matrix state(1:on, 0:off) */ 67/* matrix state(1:on, 0:off) */
67static matrix_row_t matrix[MATRIX_ROWS]; 68static matrix_row_t matrix[MATRIX_ROWS];
68 69
69static matrix_row_t matrix_raw[MATRIX_ROWS];
70static matrix_row_t matrix_debouncing[MATRIX_ROWS]; 70static matrix_row_t matrix_debouncing[MATRIX_ROWS];
71 71
72 72
@@ -76,7 +76,7 @@ static matrix_row_t matrix_debouncing[MATRIX_ROWS];
76 static void unselect_rows(void); 76 static void unselect_rows(void);
77 static void select_row(uint8_t row); 77 static void select_row(uint8_t row);
78 static void unselect_row(uint8_t row); 78 static void unselect_row(uint8_t row);
79#else // ROW2COL 79#elif (DIODE_DIRECTION == ROW2COL)
80 static void init_rows(void); 80 static void init_rows(void);
81 static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); 81 static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col);
82 static void unselect_cols(void); 82 static void unselect_cols(void);
@@ -133,7 +133,7 @@ uint8_t matrix_cols(void) {
133// /* PORTxn */ 133// /* PORTxn */
134// _SFR_IO8((col_pins[c] >> 4) + 2) |= _BV(col_pins[c] & 0xF); 134// _SFR_IO8((col_pins[c] >> 4) + 2) |= _BV(col_pins[c] & 0xF);
135// } 135// }
136// #else 136// #elif (DIODE_DIRECTION == ROW2COL)
137// for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) { 137// for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
138// /* DDRxn */ 138// /* DDRxn */
139// _SFR_IO8((col_pins[c] >> 4) + 1) |= _BV(col_pins[c] & 0xF); 139// _SFR_IO8((col_pins[c] >> 4) + 1) |= _BV(col_pins[c] & 0xF);
@@ -158,7 +158,7 @@ void matrix_init(void) {
158#if (DIODE_DIRECTION == COL2ROW) 158#if (DIODE_DIRECTION == COL2ROW)
159 unselect_rows(); 159 unselect_rows();
160 init_cols(); 160 init_cols();
161#else // ROW2COL 161#elif (DIODE_DIRECTION == ROW2COL)
162 unselect_cols(); 162 unselect_cols();
163 init_rows(); 163 init_rows();
164#endif 164#endif
@@ -166,7 +166,6 @@ void matrix_init(void) {
166 // initialize matrix state: all keys off 166 // initialize matrix state: all keys off
167 for (uint8_t i=0; i < MATRIX_ROWS; i++) { 167 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
168 matrix[i] = 0; 168 matrix[i] = 0;
169 matrix_raw[i] = 0;
170 matrix_debouncing[i] = 0; 169 matrix_debouncing[i] = 0;
171 } 170 }
172 171
@@ -194,7 +193,7 @@ uint8_t matrix_scan(void)
194 193
195 } 194 }
196 195
197#else // ROW2COL 196#elif (DIODE_DIRECTION == ROW2COL)
198 197
199 // Set col, read rows 198 // Set col, read rows
200 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { 199 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
@@ -336,7 +335,7 @@ static void unselect_rows(void)
336 } 335 }
337} 336}
338 337
339#else // ROW2COL 338#elif (DIODE_DIRECTION == ROW2COL)
340 339
341static void init_rows(void) 340static void init_rows(void)
342{ 341{