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
This commit is contained in:
parent
e1de0d74a6
commit
cc5edb9eeb
@ -9,9 +9,6 @@
|
|||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
#include "ergodone.h"
|
#include "ergodone.h"
|
||||||
#include "expander.h"
|
#include "expander.h"
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
#include "timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This constant define not debouncing time in msecs, but amount of matrix
|
* This constant define not debouncing time in msecs, but amount of matrix
|
||||||
@ -41,12 +38,6 @@ static void init_cols(void);
|
|||||||
static void unselect_rows(void);
|
static void unselect_rows(void);
|
||||||
static void select_row(uint8_t row);
|
static void select_row(uint8_t row);
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
uint32_t matrix_timer;
|
|
||||||
uint32_t matrix_scan_count;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
void matrix_init_user(void) {}
|
void matrix_init_user(void) {}
|
||||||
|
|
||||||
@ -88,13 +79,7 @@ void matrix_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_power_up(void) {
|
void matrix_power_up(void) {
|
||||||
@ -105,11 +90,6 @@ void matrix_power_up(void) {
|
|||||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||||
matrix[i] = 0;
|
matrix[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a matrix_row_t whose bits are set if the corresponding key should be
|
// Returns a matrix_row_t whose bits are set if the corresponding key should be
|
||||||
@ -140,21 +120,6 @@ uint8_t matrix_scan(void)
|
|||||||
{
|
{
|
||||||
expander_scan();
|
expander_scan();
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
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_print();
|
|
||||||
|
|
||||||
matrix_timer = timer_now;
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||||
select_row(i);
|
select_row(i);
|
||||||
wait_us(30); // without this wait read unstable value.
|
wait_us(30); // without this wait read unstable value.
|
||||||
|
@ -32,15 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "debounce.h"
|
#include "debounce.h"
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
// Only enable this if console is enabled to print to
|
|
||||||
#if defined(DEBUG_MATRIX_SCAN_RATE) && !defined(CONSOLE_ENABLE)
|
|
||||||
# undef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
# include "timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This constant define not debouncing time in msecs, assuming eager_pr.
|
* This constant define not debouncing time in msecs, assuming eager_pr.
|
||||||
*
|
*
|
||||||
@ -65,11 +56,6 @@ static void select_row(uint8_t row);
|
|||||||
static uint8_t mcp23018_reset_loop;
|
static uint8_t mcp23018_reset_loop;
|
||||||
// static uint16_t mcp23018_reset_loop;
|
// static uint16_t mcp23018_reset_loop;
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
uint32_t matrix_timer;
|
|
||||||
uint32_t matrix_scan_count;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
__attribute__((weak)) void matrix_init_user(void) {}
|
__attribute__((weak)) void matrix_init_user(void) {}
|
||||||
|
|
||||||
__attribute__((weak)) void matrix_scan_user(void) {}
|
__attribute__((weak)) void matrix_scan_user(void) {}
|
||||||
@ -96,10 +82,6 @@ void matrix_init(void) {
|
|||||||
raw_matrix[i] = 0;
|
raw_matrix[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
debounce_init(MATRIX_ROWS);
|
debounce_init(MATRIX_ROWS);
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
}
|
}
|
||||||
@ -114,11 +96,6 @@ void matrix_power_up(void) {
|
|||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||||
matrix[i] = 0;
|
matrix[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads and stores a row, returning
|
// Reads and stores a row, returning
|
||||||
@ -149,20 +126,6 @@ uint8_t matrix_scan(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
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 LEFT_LEDS
|
#ifdef LEFT_LEDS
|
||||||
mcp23018_status = ergodox_left_leds_update();
|
mcp23018_status = ergodox_left_leds_update();
|
||||||
#endif // LEFT_LEDS
|
#endif // LEFT_LEDS
|
||||||
|
@ -13,13 +13,6 @@
|
|||||||
#define DEBOUNCE 10
|
#define DEBOUNCE 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define DEBUG_MATRIX_SCAN_RATE
|
|
||||||
|
|
||||||
//#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
//uint32_t matrix_timer;
|
|
||||||
//uint32_t matrix_scan_count;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
static uint8_t mcp23017_reset_loop = 0;
|
static uint8_t mcp23017_reset_loop = 0;
|
||||||
|
|
||||||
volatile matrix_row_t matrix[MATRIX_ROWS];
|
volatile matrix_row_t matrix[MATRIX_ROWS];
|
||||||
|
@ -26,9 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
#include "timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
#ifndef DEBOUNCE
|
||||||
# define DEBOUNCE 5
|
# define DEBOUNCE 5
|
||||||
@ -70,12 +67,6 @@ static void select_row(uint8_t row);
|
|||||||
static uint8_t mcp23018_reset_loop;
|
static uint8_t mcp23018_reset_loop;
|
||||||
// static uint16_t mcp23018_reset_loop;
|
// static uint16_t mcp23018_reset_loop;
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
uint32_t matrix_timer;
|
|
||||||
uint32_t matrix_scan_count;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
void matrix_init_user(void) {}
|
void matrix_init_user(void) {}
|
||||||
|
|
||||||
@ -121,10 +112,6 @@ void matrix_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,12 +125,6 @@ void matrix_power_up(void) {
|
|||||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||||
matrix[i] = 0;
|
matrix[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a matrix_row_t whose bits are set if the corresponding key should be
|
// Returns a matrix_row_t whose bits are set if the corresponding key should be
|
||||||
@ -192,18 +173,6 @@ uint8_t matrix_scan(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
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
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
|
for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
|
||||||
select_row(i);
|
select_row(i);
|
||||||
// and select on left hand
|
// and select on left hand
|
||||||
|
@ -27,10 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "keymap_steno.h"
|
#include "keymap_steno.h"
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
#include "timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
#ifndef DEBOUNCE
|
||||||
# define DEBOUNCE 5
|
# define DEBOUNCE 5
|
||||||
@ -92,12 +88,6 @@ static void select_row(uint8_t row);
|
|||||||
static uint8_t mcp23018_reset_loop;
|
static uint8_t mcp23018_reset_loop;
|
||||||
// static uint16_t mcp23018_reset_loop;
|
// static uint16_t mcp23018_reset_loop;
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
uint32_t matrix_timer;
|
|
||||||
uint32_t matrix_scan_count;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
void matrix_init_user(void) {}
|
void matrix_init_user(void) {}
|
||||||
|
|
||||||
@ -143,10 +133,6 @@ void matrix_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,12 +146,6 @@ void matrix_power_up(void) {
|
|||||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||||
matrix[i] = 0;
|
matrix[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a matrix_row_t whose bits are set if the corresponding key should be
|
// Returns a matrix_row_t whose bits are set if the corresponding key should be
|
||||||
@ -214,18 +194,6 @@ uint8_t matrix_scan(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
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
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
|
for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
|
||||||
select_row(i);
|
select_row(i);
|
||||||
// and select on left hand
|
// and select on left hand
|
||||||
|
@ -27,9 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "debounce.h"
|
#include "debounce.h"
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
# include "timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BALLER
|
#ifdef BALLER
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
@ -124,12 +121,6 @@ static void enableInterrupts(void);
|
|||||||
static uint8_t mcp23018_reset_loop;
|
static uint8_t mcp23018_reset_loop;
|
||||||
// static uint16_t mcp23018_reset_loop;
|
// static uint16_t mcp23018_reset_loop;
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
uint32_t matrix_timer;
|
|
||||||
uint32_t matrix_scan_count;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
__attribute__ ((weak)) void matrix_init_user(void) {}
|
__attribute__ ((weak)) void matrix_init_user(void) {}
|
||||||
|
|
||||||
__attribute__ ((weak)) void matrix_scan_user(void) {}
|
__attribute__ ((weak)) void matrix_scan_user(void) {}
|
||||||
@ -161,10 +152,6 @@ void matrix_init(void) {
|
|||||||
raw_matrix[i] = 0;
|
raw_matrix[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
debounce_init(MATRIX_ROWS);
|
debounce_init(MATRIX_ROWS);
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
}
|
}
|
||||||
@ -179,12 +166,6 @@ void matrix_power_up(void) {
|
|||||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||||
matrix[i] = 0;
|
matrix[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads and stores a row, returning
|
// Reads and stores a row, returning
|
||||||
@ -261,20 +242,6 @@ uint8_t matrix_scan(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
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
|
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
|
for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
|
||||||
// select rows from left and right hands
|
// select rows from left and right hands
|
||||||
|
@ -76,11 +76,6 @@ uint8_t expander_status;
|
|||||||
uint8_t expander_input_pin_mask;
|
uint8_t expander_input_pin_mask;
|
||||||
bool i2c_initialized = false;
|
bool i2c_initialized = false;
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
uint32_t matrix_timer;
|
|
||||||
uint32_t matrix_scan_count;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ROW_SHIFTER ((matrix_row_t)1)
|
#define ROW_SHIFTER ((matrix_row_t)1)
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
@ -129,11 +124,6 @@ void matrix_init(void)
|
|||||||
matrix_debouncing[i] = 0;
|
matrix_debouncing[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,20 +226,6 @@ uint8_t matrix_scan(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
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
|
|
||||||
|
|
||||||
#if (DIODE_DIRECTION == COL2ROW)
|
#if (DIODE_DIRECTION == COL2ROW)
|
||||||
for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
|
for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
|
||||||
# if (DEBOUNCE > 0)
|
# if (DEBOUNCE > 0)
|
||||||
|
@ -35,9 +35,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
#include "frenchdev.h"
|
#include "frenchdev.h"
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
#include "timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This constant define not debouncing time in msecs, but amount of matrix
|
* This constant define not debouncing time in msecs, but amount of matrix
|
||||||
@ -66,12 +63,6 @@ static void select_row(uint8_t row);
|
|||||||
|
|
||||||
static uint8_t mcp23018_reset_loop;
|
static uint8_t mcp23018_reset_loop;
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
uint32_t matrix_timer;
|
|
||||||
uint32_t matrix_scan_count;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
void matrix_init_user(void) {}
|
void matrix_init_user(void) {}
|
||||||
|
|
||||||
@ -120,13 +111,7 @@ void matrix_init(void)
|
|||||||
matrix_debouncing[i] = 0;
|
matrix_debouncing[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_power_up(void) {
|
void matrix_power_up(void) {
|
||||||
@ -140,12 +125,6 @@ void matrix_power_up(void) {
|
|||||||
matrix[i] = 0;
|
matrix[i] = 0;
|
||||||
matrix_debouncing[i] = 0;
|
matrix_debouncing[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t matrix_scan(void)
|
uint8_t matrix_scan(void)
|
||||||
@ -165,20 +144,6 @@ uint8_t matrix_scan(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
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
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||||
select_row(i);
|
select_row(i);
|
||||||
wait_us(30); // without this wait read unstable value.
|
wait_us(30); // without this wait read unstable value.
|
||||||
|
@ -30,18 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "pro_micro.h"
|
#include "pro_micro.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
#include "matrix_scanrate.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void matrix_scan_user(void)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_check_scan_rate();
|
|
||||||
matrix_time_between_scans();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy this code to split_common/matrix.c,
|
// Copy this code to split_common/matrix.c,
|
||||||
// and call it instead of the unoptimized col_reader. Scan-rate jumps from 1200->1920
|
// and call it instead of the unoptimized col_reader. Scan-rate jumps from 1200->1920
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include "wait.h"
|
|
||||||
#include "print.h"
|
|
||||||
#include "debug.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "matrix.h"
|
|
||||||
#include "timer.h"
|
|
||||||
|
|
||||||
#ifdef CONSOLE_ENABLE
|
|
||||||
static uint16_t matrix_scan_count = 0;
|
|
||||||
static uint32_t matrix_timer = 0;
|
|
||||||
void matrix_check_scan_rate(void) {
|
|
||||||
matrix_scan_count++;
|
|
||||||
if (matrix_scan_count > 1000) {
|
|
||||||
uint32_t timer_now = timer_read32();
|
|
||||||
uint16_t ms_per_thousand = TIMER_DIFF_32(timer_now, matrix_timer);
|
|
||||||
uint16_t rate_per_second = 1000000UL / ms_per_thousand;
|
|
||||||
print("scan_rate: ");
|
|
||||||
pdec(rate_per_second);
|
|
||||||
print("\n");
|
|
||||||
matrix_timer = timer_now;
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t last_scan_time = 0;
|
|
||||||
void matrix_time_between_scans(void) {
|
|
||||||
if (timer_elapsed(last_scan_time) > 1)
|
|
||||||
{
|
|
||||||
print(">1ms elapsed since last scan: ");
|
|
||||||
pdec(timer_elapsed(last_scan_time));
|
|
||||||
print("\n");
|
|
||||||
}
|
|
||||||
last_scan_time = timer_read();
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,4 +0,0 @@
|
|||||||
__attribute__((weak))
|
|
||||||
void matrix_check_scan_rate(void) {}
|
|
||||||
__attribute__((weak))
|
|
||||||
void matrix_time_between_scans(void) {}
|
|
@ -1,4 +1,4 @@
|
|||||||
SRC += matrix_scanrate.c matrix.c
|
SRC += matrix.c
|
||||||
|
|
||||||
# MCU name
|
# MCU name
|
||||||
MCU = atmega32u4
|
MCU = atmega32u4
|
||||||
|
@ -9,9 +9,6 @@
|
|||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
#include "hotdox.h"
|
#include "hotdox.h"
|
||||||
#include "left.h"
|
#include "left.h"
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
#include "timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This constant define not debouncing time in msecs, but amount of matrix
|
* This constant define not debouncing time in msecs, but amount of matrix
|
||||||
@ -41,12 +38,6 @@ static void init_cols(void);
|
|||||||
static void unselect_rows(void);
|
static void unselect_rows(void);
|
||||||
static void select_row(uint8_t row);
|
static void select_row(uint8_t row);
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
uint32_t matrix_timer;
|
|
||||||
uint32_t matrix_scan_count;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
void matrix_init_user(void) {}
|
void matrix_init_user(void) {}
|
||||||
|
|
||||||
@ -90,13 +81,7 @@ void matrix_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_power_up(void) {
|
void matrix_power_up(void) {
|
||||||
@ -107,11 +92,6 @@ void matrix_power_up(void) {
|
|||||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||||
matrix[i] = 0;
|
matrix[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
matrix_timer = timer_read32();
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a matrix_row_t whose bits are set if the corresponding key should be
|
// Returns a matrix_row_t whose bits are set if the corresponding key should be
|
||||||
@ -142,20 +122,6 @@ uint8_t matrix_scan(void)
|
|||||||
{
|
{
|
||||||
left_scan();
|
left_scan();
|
||||||
|
|
||||||
#ifdef DEBUG_MATRIX_SCAN_RATE
|
|
||||||
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_print();
|
|
||||||
|
|
||||||
matrix_timer = timer_now;
|
|
||||||
matrix_scan_count = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||||
select_row(i);
|
select_row(i);
|
||||||
wait_us(30); // without this wait read unstable value.
|
wait_us(30); // without this wait read unstable value.
|
||||||
|
@ -82,6 +82,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
# include "velocikey.h"
|
# include "velocikey.h"
|
||||||
#endif
|
#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
|
#ifdef MATRIX_HAS_GHOST
|
||||||
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
||||||
static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) {
|
static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) {
|
||||||
@ -301,6 +321,10 @@ void keyboard_task(void) {
|
|||||||
|
|
||||||
MATRIX_LOOP_END:
|
MATRIX_LOOP_END:
|
||||||
|
|
||||||
|
#ifdef DEBUG_MATRIX_SCAN_RATE
|
||||||
|
matrix_scan_perf_task();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef QWIIC_ENABLE
|
#ifdef QWIIC_ENABLE
|
||||||
qwiic_task();
|
qwiic_task();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user