diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/matrix.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c index 4fbcc2419..483d518ec 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
| @@ -69,7 +69,7 @@ uint8_t thisHand, thatHand; | |||
| 69 | // user-defined overridable functions | 69 | // user-defined overridable functions |
| 70 | __attribute__((weak)) void matrix_init_pins(void); | 70 | __attribute__((weak)) void matrix_init_pins(void); |
| 71 | __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); | 71 | __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); |
| 72 | __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); | 72 | __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col, matrix_row_t row_shifter); |
| 73 | #ifdef SPLIT_KEYBOARD | 73 | #ifdef SPLIT_KEYBOARD |
| 74 | __attribute__((weak)) void matrix_slave_scan_kb(void) { matrix_slave_scan_user(); } | 74 | __attribute__((weak)) void matrix_slave_scan_kb(void) { matrix_slave_scan_user(); } |
| 75 | __attribute__((weak)) void matrix_slave_scan_user(void) {} | 75 | __attribute__((weak)) void matrix_slave_scan_user(void) {} |
| @@ -113,10 +113,11 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[] | |||
| 113 | // Start with a clear matrix row | 113 | // Start with a clear matrix row |
| 114 | matrix_row_t current_row_value = 0; | 114 | matrix_row_t current_row_value = 0; |
| 115 | 115 | ||
| 116 | for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { | 116 | matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; |
| 117 | for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { | ||
| 117 | pin_t pin = direct_pins[current_row][col_index]; | 118 | pin_t pin = direct_pins[current_row][col_index]; |
| 118 | if (pin != NO_PIN) { | 119 | if (pin != NO_PIN) { |
| 119 | current_row_value |= readPin(pin) ? 0 : (MATRIX_ROW_SHIFTER << col_index); | 120 | current_row_value |= readPin(pin) ? 0 : row_shifter; |
| 120 | } | 121 | } |
| 121 | } | 122 | } |
| 122 | 123 | ||
| @@ -169,11 +170,12 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[] | |||
| 169 | matrix_output_select_delay(); | 170 | matrix_output_select_delay(); |
| 170 | 171 | ||
| 171 | // For each col... | 172 | // For each col... |
| 172 | for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { | 173 | matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; |
| 174 | for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { | ||
| 173 | uint8_t pin_state = readMatrixPin(col_pins[col_index]); | 175 | uint8_t pin_state = readMatrixPin(col_pins[col_index]); |
| 174 | 176 | ||
| 175 | // Populate the matrix row with the state of the col pin | 177 | // Populate the matrix row with the state of the col pin |
| 176 | current_row_value |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index); | 178 | current_row_value |= pin_state ? 0 : row_shifter; |
| 177 | } | 179 | } |
| 178 | 180 | ||
| 179 | // Unselect row | 181 | // Unselect row |
| @@ -217,7 +219,7 @@ __attribute__((weak)) void matrix_init_pins(void) { | |||
| 217 | } | 219 | } |
| 218 | } | 220 | } |
| 219 | 221 | ||
| 220 | __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { | 222 | __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col, matrix_row_t row_shifter) { |
| 221 | bool key_pressed = false; | 223 | bool key_pressed = false; |
| 222 | 224 | ||
| 223 | // Select col | 225 | // Select col |
| @@ -231,11 +233,11 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[] | |||
| 231 | // Check row pin state | 233 | // Check row pin state |
| 232 | if (readMatrixPin(row_pins[row_index]) == 0) { | 234 | if (readMatrixPin(row_pins[row_index]) == 0) { |
| 233 | // Pin LO, set col bit | 235 | // Pin LO, set col bit |
| 234 | current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col); | 236 | current_matrix[row_index] |= row_shifter; |
| 235 | key_pressed = true; | 237 | key_pressed = true; |
| 236 | } else { | 238 | } else { |
| 237 | // Pin HI, clear col bit | 239 | // Pin HI, clear col bit |
| 238 | current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col); | 240 | current_matrix[row_index] &= ~row_shifter; |
| 239 | } | 241 | } |
| 240 | } | 242 | } |
| 241 | 243 | ||
| @@ -347,8 +349,9 @@ uint8_t matrix_scan(void) { | |||
| 347 | } | 349 | } |
| 348 | #elif (DIODE_DIRECTION == ROW2COL) | 350 | #elif (DIODE_DIRECTION == ROW2COL) |
| 349 | // Set col, read rows | 351 | // Set col, read rows |
| 350 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | 352 | matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; |
| 351 | matrix_read_rows_on_col(curr_matrix, current_col); | 353 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++, row_shifter <<= 1) { |
| 354 | matrix_read_rows_on_col(curr_matrix, current_col, row_shifter); | ||
| 352 | } | 355 | } |
| 353 | #endif | 356 | #endif |
| 354 | 357 | ||
