diff options
author | Takeshi ISHII <2170248+mtei@users.noreply.github.com> | 2021-07-13 16:50:25 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-13 16:50:25 +0900 |
commit | ac2e6e01f155811d0e206298f0d7cadcc9234603 (patch) | |
tree | ee70abbdb373ef7e0802173a34bb91fc6d5fefbf | |
parent | a62b10176e6781f3b2e176a681b2090998c6d157 (diff) | |
download | qmk_firmware-ac2e6e01f155811d0e206298f0d7cadcc9234603.tar.gz qmk_firmware-ac2e6e01f155811d0e206298f0d7cadcc9234603.zip |
Change the prototype of matrix_output_unselect_delay() (#13045)
The prototype of matrix_output_unselect_delay() has been changed as follows.
```c
void matrix_output_unselect_delay(uint8_t line, bool key_pressed);
```
Currently, no keyboard seems to be redefining `matrix_output_unselect_delay()`, so there is no change in the system behavior.
With this change, the keyboard level code can get some optimization hints, for example, the following.
```c
void matrix_output_unselect_delay(uint8_t line, bool key_pressed) {
/* If none of the keys are pressed,
* there is no need to wait for time for the next line. */
if (key_pressed) {
#ifdef MATRIX_IO_DELAY
# if MATRIX_IO_DELAY > 0
wait_us(MATRIX_IO_DELAY);
# endif
#else
wait_us(30);
#endif
}
}
```
-rw-r--r-- | quantum/matrix.c | 7 | ||||
-rw-r--r-- | quantum/matrix.h | 2 | ||||
-rw-r--r-- | quantum/matrix_common.c | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c index 235b16769..d22817bf4 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
@@ -182,7 +182,7 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[] | |||
182 | 182 | ||
183 | // Unselect row | 183 | // Unselect row |
184 | unselect_row(current_row); | 184 | unselect_row(current_row); |
185 | matrix_output_unselect_delay(); // wait for all Col signals to go HIGH | 185 | matrix_output_unselect_delay(current_row, current_row_value != 0); // wait for all Col signals to go HIGH |
186 | 186 | ||
187 | // Update the matrix | 187 | // Update the matrix |
188 | current_matrix[current_row] = current_row_value; | 188 | current_matrix[current_row] = current_row_value; |
@@ -222,6 +222,8 @@ __attribute__((weak)) void matrix_init_pins(void) { | |||
222 | } | 222 | } |
223 | 223 | ||
224 | __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { | 224 | __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { |
225 | bool key_pressed = false; | ||
226 | |||
225 | // Select col | 227 | // Select col |
226 | if (!select_col(current_col)) { // select col | 228 | if (!select_col(current_col)) { // select col |
227 | return; // skip NO_PIN col | 229 | return; // skip NO_PIN col |
@@ -234,6 +236,7 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[] | |||
234 | if (readMatrixPin(row_pins[row_index]) == 0) { | 236 | if (readMatrixPin(row_pins[row_index]) == 0) { |
235 | // Pin LO, set col bit | 237 | // Pin LO, set col bit |
236 | current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col); | 238 | current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col); |
239 | key_pressed = true; | ||
237 | } else { | 240 | } else { |
238 | // Pin HI, clear col bit | 241 | // Pin HI, clear col bit |
239 | current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col); | 242 | current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col); |
@@ -242,7 +245,7 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[] | |||
242 | 245 | ||
243 | // Unselect col | 246 | // Unselect col |
244 | unselect_col(current_col); | 247 | unselect_col(current_col); |
245 | matrix_output_unselect_delay(); // wait for all Row signals to go HIGH | 248 | matrix_output_unselect_delay(current_col, key_pressed); // wait for all Row signals to go HIGH |
246 | } | 249 | } |
247 | 250 | ||
248 | # else | 251 | # else |
diff --git a/quantum/matrix.h b/quantum/matrix.h index 3fe691aae..5c696622f 100644 --- a/quantum/matrix.h +++ b/quantum/matrix.h | |||
@@ -56,7 +56,7 @@ matrix_row_t matrix_get_row(uint8_t row); | |||
56 | void matrix_print(void); | 56 | void matrix_print(void); |
57 | /* delay between changing matrix pin state and reading values */ | 57 | /* delay between changing matrix pin state and reading values */ |
58 | void matrix_output_select_delay(void); | 58 | void matrix_output_select_delay(void); |
59 | void matrix_output_unselect_delay(void); | 59 | void matrix_output_unselect_delay(uint8_t line, bool key_pressed); |
60 | /* only for backwards compatibility. delay between changing matrix pin state and reading values */ | 60 | /* only for backwards compatibility. delay between changing matrix pin state and reading values */ |
61 | void matrix_io_delay(void); | 61 | void matrix_io_delay(void); |
62 | 62 | ||
diff --git a/quantum/matrix_common.c b/quantum/matrix_common.c index efbad6a5f..66c89970b 100644 --- a/quantum/matrix_common.c +++ b/quantum/matrix_common.c | |||
@@ -88,7 +88,7 @@ uint8_t matrix_key_count(void) { | |||
88 | __attribute__((weak)) void matrix_io_delay(void) { wait_us(MATRIX_IO_DELAY); } | 88 | __attribute__((weak)) void matrix_io_delay(void) { wait_us(MATRIX_IO_DELAY); } |
89 | 89 | ||
90 | __attribute__((weak)) void matrix_output_select_delay(void) { waitInputPinDelay(); } | 90 | __attribute__((weak)) void matrix_output_select_delay(void) { waitInputPinDelay(); } |
91 | __attribute__((weak)) void matrix_output_unselect_delay(void) { matrix_io_delay(); } | 91 | __attribute__((weak)) void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { matrix_io_delay(); } |
92 | 92 | ||
93 | // CUSTOM MATRIX 'LITE' | 93 | // CUSTOM MATRIX 'LITE' |
94 | __attribute__((weak)) void matrix_init_custom(void) {} | 94 | __attribute__((weak)) void matrix_init_custom(void) {} |