diff options
| author | Michael Stapelberg <stapelberg@users.noreply.github.com> | 2021-05-19 22:43:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-20 06:43:36 +1000 |
| commit | 82aa9ad4a567695d1f7d0b1e36bf8563d2967813 (patch) | |
| tree | 4f27b34928fb3ddbfaf0af8cde0ce701721bd624 | |
| parent | 068af97b7aac1fc787b5e9fb76d9250d48638e58 (diff) | |
| download | qmk_firmware-82aa9ad4a567695d1f7d0b1e36bf8563d2967813.tar.gz qmk_firmware-82aa9ad4a567695d1f7d0b1e36bf8563d2967813.zip | |
matrix: wait for row signal to go HIGH for every row (#12945)
I noticed this discrepancy (last row of the matrix treated differently than the
others) when optimizing the input latency of my keyboard controller, see also
https://michael.stapelberg.ch/posts/2021-05-08-keyboard-input-latency-qmk-kinesis/
Before this commit, when tuning the delays I noticed ghost key presses when
pressing the F2 key, which is on the last row of the keyboard matrix: the
dead_grave key, which is on the first row of the keyboard matrix, would be
incorrectly detected as pressed.
After this commit, all keyboard matrix rows are interpreted correctly.
I suspect that my setup is more susceptible to this nuance than others because I
use GPIO_INPUT_PIN_DELAY=0 and hence don’t have another delay that might mask
the problem.
| -rw-r--r-- | quantum/matrix.c | 8 | ||||
| -rw-r--r-- | quantum/split_common/matrix.c | 8 |
2 files changed, 4 insertions, 12 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c index c027b7bf2..34d6af2e6 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
| @@ -116,9 +116,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 116 | 116 | ||
| 117 | // Unselect row | 117 | // Unselect row |
| 118 | unselect_row(current_row); | 118 | unselect_row(current_row); |
| 119 | if (current_row + 1 < MATRIX_ROWS) { | 119 | matrix_output_unselect_delay(); // wait for all Col signals to go HIGH |
| 120 | matrix_output_unselect_delay(); // wait for row signal to go HIGH | ||
| 121 | } | ||
| 122 | 120 | ||
| 123 | // If the row has changed, store the row and return the changed flag. | 121 | // If the row has changed, store the row and return the changed flag. |
| 124 | if (current_matrix[current_row] != current_row_value) { | 122 | if (current_matrix[current_row] != current_row_value) { |
| @@ -178,9 +176,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | |||
| 178 | 176 | ||
| 179 | // Unselect col | 177 | // Unselect col |
| 180 | unselect_col(current_col); | 178 | unselect_col(current_col); |
| 181 | if (current_col + 1 < MATRIX_COLS) { | 179 | matrix_output_unselect_delay(); // wait for all Row signals to go HIGH |
| 182 | matrix_output_unselect_delay(); // wait for col signal to go HIGH | ||
| 183 | } | ||
| 184 | 180 | ||
| 185 | return matrix_changed; | 181 | return matrix_changed; |
| 186 | } | 182 | } |
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index f8de17809..039e7d977 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c | |||
| @@ -130,9 +130,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 130 | 130 | ||
| 131 | // Unselect row | 131 | // Unselect row |
| 132 | unselect_row(current_row); | 132 | unselect_row(current_row); |
| 133 | if (current_row + 1 < MATRIX_ROWS) { | 133 | matrix_output_unselect_delay(); // wait for all Col signals to go HIGH |
| 134 | matrix_output_unselect_delay(); // wait for row signal to go HIGH | ||
| 135 | } | ||
| 136 | 134 | ||
| 137 | // If the row has changed, store the row and return the changed flag. | 135 | // If the row has changed, store the row and return the changed flag. |
| 138 | if (current_matrix[current_row] != current_row_value) { | 136 | if (current_matrix[current_row] != current_row_value) { |
| @@ -192,9 +190,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | |||
| 192 | 190 | ||
| 193 | // Unselect col | 191 | // Unselect col |
| 194 | unselect_col(current_col); | 192 | unselect_col(current_col); |
| 195 | if (current_col + 1 < MATRIX_COLS) { | 193 | matrix_output_unselect_delay(); // wait for all Row signals to go HIGH |
| 196 | matrix_output_unselect_delay(); // wait for col signal to go HIGH | ||
| 197 | } | ||
| 198 | 194 | ||
| 199 | return matrix_changed; | 195 | return matrix_changed; |
| 200 | } | 196 | } |
