summaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2019-10-15 13:32:52 +0100
committerDrashna Jael're <drashna@live.com>2019-12-05 16:03:51 -0800
commit9148b001ff69d5ab863a7f32bf1e68fab9797938 (patch)
treeb41c126fe3f71280c9a94aed638efca41da8e70e /tmk_core/common
parentcb7d24d95d33e2f66656c3eea404eeae9d737a08 (diff)
Port DEBUG_MATRIX_SCAN_RATE to core (#7029)
* Port DEBUG_MATRIX_SCAN_RATE to core * Remove duplicate DEBUG_MATRIX_SCAN_RATE implementations * Remove duplicate DEBUG_MATRIX_SCAN_RATE implementation from handwired/xealous * Add console logic from ergodox_ez
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/keyboard.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 060b45f1bc..0e8ba826e6 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -82,6 +82,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "velocikey.h"
#endif
+// Only enable this if console is enabled to print to
+#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE)
+static uint32_t matrix_timer = 0;
+static uint32_t matrix_scan_count = 0;
+
+void matrix_scan_perf_task(void) {
+ matrix_scan_count++;
+
+ uint32_t timer_now = timer_read32();
+ if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) {
+ dprintf("matrix scan frequency: %d\n", matrix_scan_count);
+
+ matrix_timer = timer_now;
+ matrix_scan_count = 0;
+ }
+}
+#else
+# define matrix_scan_perf_task()
+#endif
+
#ifdef MATRIX_HAS_GHOST
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) {
@@ -296,6 +316,10 @@ void keyboard_task(void) {
MATRIX_LOOP_END:
+#ifdef DEBUG_MATRIX_SCAN_RATE
+ matrix_scan_perf_task();
+#endif
+
#ifdef QWIIC_ENABLE
qwiic_task();
#endif