core: Change matrix_init and matrix_print
authortmk <hasu@tmk-kbd.com>
Sat, 8 Oct 2016 01:57:38 +0000 (10:57 +0900)
committertmk <hasu@tmk-kbd.com>
Sat, 8 Oct 2016 04:13:48 +0000 (13:13 +0900)
tmk_core/common/matrix.c
tmk_core/common/matrix.h

index 9694bd1a87aebd8587e7b06df2bfb5061fb007cc..9939307a77c47701968732cb16feaf6bd627ddd5 100644 (file)
@@ -33,7 +33,6 @@ uint8_t matrix_cols(void)
 __attribute__ ((weak))
 void matrix_clear(void)
 {
-    matrix_init();
 }
 
 __attribute__ ((weak))
@@ -55,23 +54,22 @@ void matrix_print(void)
 #elif (MATRIX_COLS <= 32)
     print("r/c 0123456789ABCDEF0123456789ABCDEF\n");
 #endif
+
     for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
-        xprintf("%02X:", row);
 
 #if (MATRIX_COLS <= 8)
-        print_bin_reverse8(matrix_get_row(row));
+        xprintf("%02X: %08b%s\n", row, bitrev(matrix_get_row(row)),
 #elif (MATRIX_COLS <= 16)
-        print_bin_reverse16(matrix_get_row(row));
+        xprintf("%02X: %016b%s\n", row, bitrev16(matrix_get_row(row)),
 #elif (MATRIX_COLS <= 32)
-        print_bin_reverse32(matrix_get_row(row));
+        xprintf("%02X: %032b%s\n", row, bitrev32(matrix_get_row(row)),
 #endif
-
 #ifdef MATRIX_HAS_GHOST
-        if (matrix_has_ghost_in_row(row)) {
-            print(" <ghost");
-        }
+        matrix_has_ghost_in_row(row) ?  " <ghost" : ""
+#else
+        ""
 #endif
-        print("\n");
+        );
     }
 }
 
index e913ee7ac6c2e81d2a1d3ac19242f1c220eb6cf7..bf866477f4579704f82ef337006e7dc581ea12a1 100644 (file)
@@ -32,6 +32,10 @@ typedef  uint32_t   matrix_row_t;
 #error "MATRIX_COLS: invalid value"
 #endif
 
+#if (MATRIX_ROWS > 255)
+#error "MATRIX_ROWS must not exceed 255"
+#endif
+
 #define MATRIX_IS_ON(row, col)  (matrix_get_row(row) && (1<<col))
 
 
Imprint / Impressum