]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Clean up #343's code (#348)
authorEric Tang <e_l_tang@outlook.com>
Tue, 24 May 2016 15:44:40 +0000 (08:44 -0700)
committerJack Humbert <jack.humb@gmail.com>
Tue, 24 May 2016 15:44:40 +0000 (11:44 -0400)
quantum/matrix.c
tmk_core/common/keyboard.c

index 22126aa7ae1175459d58aae40f6518dc06f4cfe5..d5fd7def8ab30efed89bfd33d6399ce53b938562 100644 (file)
@@ -37,10 +37,8 @@ static const io_pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
 /* matrix state */
 #if DIODE_DIRECTION == COL2ROW
 static matrix_row_t matrix[MATRIX_ROWS];
-static matrix_row_t debouncing_matrix[MATRIX_ROWS];
 #else
 static matrix_col_t matrix[MATRIX_COLS];
-static matrix_col_t debouncing_matrix[MATRIX_COLS];
 #endif
 static int8_t debouncing_delay = -1;
 
@@ -99,6 +97,7 @@ void matrix_init(void) {
 
 #if DIODE_DIRECTION == COL2ROW
 uint8_t matrix_scan(void) {
+    static matrix_row_t debouncing_matrix[MATRIX_ROWS];
     for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
         toggle_row(r);
         matrix_row_t state = read_cols();
@@ -146,6 +145,7 @@ matrix_row_t matrix_get_row(uint8_t row) {
 
 #else
 uint8_t matrix_scan(void) {
+    static matrix_col_t debouncing_matrix[MATRIX_COLS];
     for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
         toggle_col(c);
         matrix_col_t state = read_rows();
index c6d54ae3338d16a7564afed4d154d034e6d23d41..bd543c45e1a3bc1f94f6618a0f78f358fa3136f9 100644 (file)
@@ -96,17 +96,15 @@ void keyboard_init(void) {
 
 /* does routine keyboard jobs */
 void keyboard_task(void) {
-    static matrix_row_t previous_matrix[MATRIX_ROWS];
-#ifdef MATRIX_HAS_GHOST
-    static matrix_row_t deghosting_matrix[MATRIX_ROWS];
-#endif
-    static uint8_t led_status = 0;
+    static uint8_t led_status;
     matrix_scan();
     for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
+        static matrix_row_t previous_matrix[MATRIX_ROWS];
         matrix_row_t state = matrix_get_row(r);
         matrix_row_t changes = state ^ previous_matrix[r];
         if (changes) {
 #ifdef MATRIX_HAS_GHOST
+            static matrix_row_t deghosting_matrix[MATRIX_ROWS];
             if (is_row_ghosting(r)) {
                 /* debugs the deghosting mechanism */
                 /* doesn't update previous_matrix until the ghosting has stopped