Skip to content
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

Merged
merged 12 commits into from
Jul 3, 2021

Conversation

drashna
Copy link
Member

@drashna drashna commented Mar 14, 2021

Description

Adds support for NO_PIN in the regular matrices

Types of Changes

  • Core
  • Enhancement/optimization

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@mtei
Copy link
Contributor

mtei commented Mar 14, 2021

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;
   }
}

@mtei
Copy link
Contributor

mtei commented Mar 15, 2021

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();

@drashna drashna requested a review from a team March 17, 2021 07:10
@stale
Copy link

stale bot commented Jun 2, 2021

Thank you for your contribution!
This pull request has been automatically marked as stale because it has not had activity in the last 45 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, or re-open when it's ready.
For maintainers: Please label with awaiting review, breaking_change, in progress, or on hold to prevent the issue from being re-flagged.

@drashna drashna force-pushed the feature/no_pin_support branch from b0d17b9 to e707c68 Compare June 3, 2021 14:20
@stale stale bot removed the awaiting changes label Jun 3, 2021
@drashna drashna changed the base branch from master to develop June 7, 2021 06:52
@tzarc tzarc requested a review from a team June 7, 2021 13:10
@drashna drashna force-pushed the feature/no_pin_support branch from f005b55 to 90e0729 Compare June 7, 2021 17:11
@drashna drashna force-pushed the feature/no_pin_support branch from 90e0729 to ddef6f5 Compare June 10, 2021 04:52
@tzarc tzarc requested a review from a team June 10, 2021 05:03
@drashna drashna force-pushed the feature/no_pin_support branch from bdccd39 to 7807404 Compare June 21, 2021 06:37
@sigprof sigprof mentioned this pull request Jun 29, 2021
14 tasks
@drashna drashna merged commit 3ab805f into qmk:develop Jul 3, 2021
@drashna drashna deleted the feature/no_pin_support branch July 3, 2021 07:20
@elfmimi
Copy link
Contributor

elfmimi commented Jul 3, 2021

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.

nhongooi pushed a commit to nhongooi/qmk_firmware that referenced this pull request Dec 5, 2021
Co-authored-by: Nick Brassel <nick@tzarc.org>
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
Co-authored-by: Nick Brassel <nick@tzarc.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants