diff options
| author | Joel Challis <git@zvecr.com> | 2020-02-12 10:54:05 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-12 11:54:05 +0100 |
| commit | 667b29b77c71cb0a0f8b4298900304c08b13e410 (patch) | |
| tree | 26a462b4515ae24f8147ceaf3bd6a22a33d0b6c1 /quantum/split_common | |
| parent | 7740470a94ef10de3cedbe57c38d9f06c06a618d (diff) | |
| download | qmk_firmware-667b29b77c71cb0a0f8b4298900304c08b13e410.tar.gz qmk_firmware-667b29b77c71cb0a0f8b4298900304c08b13e410.zip | |
Align split_common/matrix.c with matrix.c (#8153)
Diffstat (limited to 'quantum/split_common')
| -rw-r--r-- | quantum/split_common/matrix.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 454ea59c3..2c0e028f7 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c | |||
| @@ -19,10 +19,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 19 | #include "wait.h" | 19 | #include "wait.h" |
| 20 | #include "util.h" | 20 | #include "util.h" |
| 21 | #include "matrix.h" | 21 | #include "matrix.h" |
| 22 | #include "debounce.h" | ||
| 23 | #include "quantum.h" | ||
| 22 | #include "split_util.h" | 24 | #include "split_util.h" |
| 23 | #include "config.h" | 25 | #include "config.h" |
| 24 | #include "quantum.h" | ||
| 25 | #include "debounce.h" | ||
| 26 | #include "transport.h" | 26 | #include "transport.h" |
| 27 | 27 | ||
| 28 | #ifdef ENCODER_ENABLE | 28 | #ifdef ENCODER_ENABLE |
| @@ -35,7 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 35 | 35 | ||
| 36 | #ifdef DIRECT_PINS | 36 | #ifdef DIRECT_PINS |
| 37 | static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS; | 37 | static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS; |
| 38 | #else | 38 | #elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) |
| 39 | static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | 39 | static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; |
| 40 | static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | 40 | static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; |
| 41 | #endif | 41 | #endif |
| @@ -115,8 +115,11 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 115 | 115 | ||
| 116 | // For each col... | 116 | // For each col... |
| 117 | for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { | 117 | for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { |
| 118 | // Select the col pin to read (active low) | ||
| 119 | uint8_t pin_state = readPin(col_pins[col_index]); | ||
| 120 | |||
| 118 | // Populate the matrix row with the state of the col pin | 121 | // Populate the matrix row with the state of the col pin |
| 119 | current_matrix[current_row] |= readPin(col_pins[col_index]) ? 0 : (MATRIX_ROW_SHIFTER << col_index); | 122 | current_matrix[current_row] |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index); |
| 120 | } | 123 | } |
| 121 | 124 | ||
| 122 | // Unselect row | 125 | // Unselect row |
| @@ -160,12 +163,12 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | |||
| 160 | matrix_row_t last_row_value = current_matrix[row_index]; | 163 | matrix_row_t last_row_value = current_matrix[row_index]; |
| 161 | 164 | ||
| 162 | // Check row pin state | 165 | // Check row pin state |
| 163 | if (readPin(row_pins[row_index])) { | 166 | if (readPin(row_pins[row_index]) == 0) { |
| 164 | // Pin HI, clear col bit | ||
| 165 | current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col); | ||
| 166 | } else { | ||
| 167 | // Pin LO, set col bit | 167 | // Pin LO, set col bit |
| 168 | current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col); | 168 | current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col); |
| 169 | } else { | ||
| 170 | // Pin HI, clear col bit | ||
| 171 | current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col); | ||
| 169 | } | 172 | } |
| 170 | 173 | ||
| 171 | // Determine if the matrix changed state | 174 | // Determine if the matrix changed state |
