]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add new DIODE_DIRECTION option
authorNikolaus Wittenstein <nikolaus.wittenstein@gmail.com>
Mon, 6 Feb 2017 00:42:00 +0000 (19:42 -0500)
committerNikolaus Wittenstein <nikolaus.wittenstein@gmail.com>
Mon, 6 Feb 2017 00:47:33 +0000 (19:47 -0500)
The previous two options were COL2ROW, ROW2COL; this adds CUSTOM_MATRIX
to disable the built-in matrix scanning code.

Most notably, this obviates the need to set MATRIX_ROW_PINS or
MATRIX_COL_PINS.

quantum/config_common.h
quantum/matrix.c
quantum/template/config.h

index 4bdb2065d9449ef7ff6ead93a59e6ba4e6b0c37c..28f68b9c7001739770068c7348fc67fe4b1a5bcf 100644 (file)
@@ -2,8 +2,10 @@
 #define CONFIG_DEFINITIONS_H
 
 /* diode directions */
-#define COL2ROW 0
-#define ROW2COL 1
+#define COL2ROW       0
+#define ROW2COL       1
+#define CUSTOM_MATRIX 2 /* Disables built-in matrix scanning code */
+
 /* I/O pins */
 #ifndef F0
     #define B0 0x30
index fd312bffba194111355c44f3c57f0ec996454499..ac523482ad101e635b6b432942d768a058bb384f 100644 (file)
@@ -60,8 +60,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
     extern const matrix_row_t matrix_mask[];
 #endif
 
+#if (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)
 static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
 static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
+#endif
 
 /* matrix state(1:on, 0:off) */
 static matrix_row_t matrix[MATRIX_ROWS];
@@ -75,7 +77,7 @@ static matrix_row_t matrix_debouncing[MATRIX_ROWS];
     static void unselect_rows(void);
     static void select_row(uint8_t row);
     static void unselect_row(uint8_t row);
-#else // ROW2COL
+#elif (DIODE_DIRECTION == ROW2COL)
     static void init_rows(void);
     static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col);
     static void unselect_cols(void);
@@ -132,7 +134,7 @@ uint8_t matrix_cols(void) {
 //         /* PORTxn */
 //         _SFR_IO8((col_pins[c] >> 4) + 2) |= _BV(col_pins[c] & 0xF);
 //     }
-// #else
+// #elif (DIODE_DIRECTION == ROW2COL)
 //     for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
 //         /* DDRxn */
 //         _SFR_IO8((col_pins[c] >> 4) + 1) |= _BV(col_pins[c] & 0xF);
@@ -157,7 +159,7 @@ void matrix_init(void) {
 #if (DIODE_DIRECTION == COL2ROW)
     unselect_rows();
     init_cols();
-#else // ROW2COL
+#elif (DIODE_DIRECTION == ROW2COL)
     unselect_cols();
     init_rows();
 #endif
@@ -192,7 +194,7 @@ uint8_t matrix_scan(void)
 
     }
 
-#else // ROW2COL
+#elif (DIODE_DIRECTION == ROW2COL)
 
     // Set col, read rows
     for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
@@ -334,7 +336,7 @@ static void unselect_rows(void)
     }
 }
 
-#else // ROW2COL
+#elif (DIODE_DIRECTION == ROW2COL)
 
 static void init_rows(void)
 {
index b02f0c7ebc844fa5fa99188e01e9ced42c2f26ed..c61c4a618129944b3b0d6820407769ba0037b1d0 100644 (file)
@@ -46,7 +46,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define MATRIX_COL_PINS { F1, F0, B0 }
 #define UNUSED_PINS
 
-/* COL2ROW or ROW2COL */
+/* COL2ROW, ROW2COL, or CUSTOM_MATRIX */
 #define DIODE_DIRECTION COL2ROW
  
 // #define BACKLIGHT_PIN B7