From 6b7921f91b207820e03e33f8bd9a48e50ee3f2c2 Mon Sep 17 00:00:00 2001 From: Oleg Kostyuk Date: Sun, 8 Sep 2013 18:25:40 +0300 Subject: [PATCH] Added debug counter of matrix scan frequency --- keyboard/ergodox/config.h | 1 + keyboard/ergodox/matrix.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/keyboard/ergodox/config.h b/keyboard/ergodox/config.h index d2ca7ea6..62e5ff6a 100644 --- a/keyboard/ergodox/config.h +++ b/keyboard/ergodox/config.h @@ -71,5 +71,6 @@ Project located at //#define NO_ACTION_ONESHOT //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION +//#define DEBUG_MATRIX_FREQ #endif diff --git a/keyboard/ergodox/matrix.c b/keyboard/ergodox/matrix.c index b0ba1c0e..e35b65c9 100644 --- a/keyboard/ergodox/matrix.c +++ b/keyboard/ergodox/matrix.c @@ -29,6 +29,9 @@ along with this program. If not, see . #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); -- 2.46.2