Skip to content

Commit

Permalink
Add support for driving unselected row/col. (#16278)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzarc authored Feb 9, 2022
1 parent e26778c commit efdaa7f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 139 deletions.
2 changes: 2 additions & 0 deletions docs/config_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ This is a C header file that is one of the first things included, and will persi
* pins unused by the keyboard for reference
* `#define MATRIX_HAS_GHOST`
* define is matrix has ghost (unlikely)
* `#define MATRIX_UNSELECT_DRIVE_HIGH`
* On un-select of matrix pins, rather than setting pins to input-high, sets them to output-high.
* `#define DIODE_DIRECTION COL2ROW`
* COL2ROW or ROW2COL - how your matrix is configured. COL2ROW means the black mark on your diode is facing to the rows, and between the switch and the rows.
* `#define DIRECT_PINS { { F1, F0, B0, C7 }, { F4, F5, F6, F7 } }`
Expand Down
2 changes: 2 additions & 0 deletions keyboards/keychron/q2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#define MATRIX_ROW_PINS { B4, B3, A15, A14, A13 }
#define MATRIX_COL_PINS { C14, C15, A0, A1, A2, A3, A4, A5, A6, A7, B0, B1, A8, A9, H3 }

#define MATRIX_UNSELECT_DRIVE_HIGH

/* DIP switch */
#define DIP_SWITCH_MATRIX_GRID { {4, 4} }

Expand Down
139 changes: 0 additions & 139 deletions keyboards/keychron/q2/matrix.c

This file was deleted.

15 changes: 15 additions & 0 deletions quantum/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ static inline void setPinOutput_writeLow(pin_t pin) {
}
}

static inline void setPinOutput_writeHigh(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
setPinOutput(pin);
writePinHigh(pin);
}
}

static inline void setPinInputHigh_atomic(pin_t pin) {
ATOMIC_BLOCK_FORCEON { setPinInputHigh(pin); }
}
Expand Down Expand Up @@ -141,7 +148,11 @@ static bool select_row(uint8_t row) {
static void unselect_row(uint8_t row) {
pin_t pin = row_pins[row];
if (pin != NO_PIN) {
# ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin);
# else
setPinInputHigh_atomic(pin);
# endif
}
}

Expand Down Expand Up @@ -200,7 +211,11 @@ static bool select_col(uint8_t col) {
static void unselect_col(uint8_t col) {
pin_t pin = col_pins[col];
if (pin != NO_PIN) {
# ifdef MATRIX_UNSELECT_DRIVE_HIGH
setPinOutput_writeHigh(pin);
# else
setPinInputHigh_atomic(pin);
# endif
}
}

Expand Down

0 comments on commit efdaa7f

Please sign in to comment.