-
-
Notifications
You must be signed in to change notification settings - Fork 40.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for NO_PIN to all matrix types #12238
Conversation
I would say the better way is to define this function and use it. static inline uint8_t readMatrixPin(pin_t pin) {
if (pin != NO_PIN) {
return readPin(pin);
} else {
return 1;
}
} |
I have one more suggestion. -static void select_row(uint8_t row) { setPinOutput_writeLow(row_pins[row]); }
+static bool select_row(uint8_t row) {
+ pin_t pin = row_pins[row];
+ if (pin != NO_PIN) {
+ setPinOutput_writeLow(pin);
+ return true;
+ }
+ return false;
+}
-static void unselect_row(uint8_t row) { setPinInputHigh_atomic(row_pins[row]); }
+static void unselect_row(uint8_t row) {
+ pin_t pin = row_pins[row];
+ if (pin != NO_PIN) {
+ setPinInputHigh_atomic(pin);
+ }
+}
static void unselect_rows(void) {
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
- if (row_pins[x] != NO_PIN) {
- setPinInputHigh_atomic(row_pins[x]);
- }
+ unselect_row(x);
}
} @@ -113,8 +123,9 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Start with a clear matrix row
matrix_row_t current_row_value = 0;
- // Select row
- select_row(current_row);
+ if (!select_row(current_row)) { // Select row
+ return false; // skip NO_PIN row
+ }
matrix_output_select_delay(); |
Thank you for your contribution! |
b0d17b9
to
e707c68
Compare
f005b55
to
90e0729
Compare
90e0729
to
ddef6f5
Compare
Co-authored-by: Nick Brassel <nick@tzarc.org>
bdccd39
to
7807404
Compare
I need to leave a note here. I'm guessing that the reason support for NO_PIN didn't exist until today is because QMK takes binary side into account very seriously. I've heard QMK is turning its wheel to the direction of data driven design. If so, check for NO_PIN could have been made to activated only for those do include NO_PINs in the definition. This was my thought on this PR. |
Co-authored-by: Nick Brassel <nick@tzarc.org>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Description
Adds support for
NO_PIN
in the regular matricesTypes of Changes
Checklist