]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Added debug counter of matrix scan frequency
authorOleg Kostyuk <cub.uanic@gmail.com>
Sun, 8 Sep 2013 15:25:40 +0000 (18:25 +0300)
committerOleg Kostyuk <cub.uanic@gmail.com>
Sun, 8 Sep 2013 15:26:38 +0000 (18:26 +0300)
keyboard/ergodox/config.h
keyboard/ergodox/matrix.c

index d2ca7ea69e7e6add1bc9b72a206efba2d5caaf02..62e5ff6a81a82d0730c30c4f5d4835c1516e6b34 100644 (file)
@@ -71,5 +71,6 @@ Project located at <https://github.com/benblazak/ergodox-firmware>
 //#define NO_ACTION_ONESHOT
 //#define NO_ACTION_MACRO
 //#define NO_ACTION_FUNCTION
+//#define DEBUG_MATRIX_FREQ
 
 #endif
index b0ba1c0e7342f5188bf2b17c28de531753e28c94..e35b65c95af4b16410d8a20e410d3b381f2e972c 100644 (file)
@@ -29,6 +29,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "matrix.h"
 #include "ergodox.h"
 #include "i2cmaster.h"
+#ifdef DEBUG_MATRIX_FREQ
+#include  "timer.h"
+#endif
 
 #ifndef DEBOUNCE
 #   define DEBOUNCE    5
@@ -44,6 +47,10 @@ static void init_cols(void);
 static void unselect_rows(uint8_t mcp23018_status);
 static void select_row(uint8_t mcp23018_status, uint8_t row);
 
+#ifdef DEBUG_MATRIX_FREQ
+uint32_t matrix_timer;
+uint32_t matrix_scan_count;
+#endif
 
 inline
 uint8_t matrix_rows(void)
@@ -71,10 +78,29 @@ void matrix_init(void)
         matrix[i] = 0;
         matrix_debouncing[i] = 0;
     }
+
+#ifdef DEBUG_MATRIX_FREQ
+    matrix_timer = timer_read32();
+    matrix_scan_count = 0;
+#endif
 }
 
 uint8_t matrix_scan(void)
 {
+#ifdef DEBUG_MATRIX_FREQ
+    matrix_scan_count++;
+
+    uint32_t timer_now = timer_read32();
+    if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) {
+        print("matrix scan frequency: ");
+        pdec(matrix_scan_count);
+        print("\n");
+
+        matrix_timer = timer_now;
+        matrix_scan_count = 0;
+    }
+#endif
+
 #ifdef KEYMAP_CUB
     uint8_t layer = biton32(layer_state);