aboutsummaryrefslogtreecommitdiffstats
path: root/keyboards/handwired
diff options
context:
space:
mode:
authorフィルターペーパー2025-10-19 04:14:37 +0200
committerGitHub2025-10-19 04:14:37 +0200
commit81df54308687713371ed5fbf4947e38963c7867b (patch)
tree36d0a432adcf7613f8a362f3a534e68b4ddaad19 /keyboards/handwired
parent4f21beb7153c2b0a1f4d41de7dad5a2173f896b6 (diff)
Debounce: Deprecate num_rows parameter (#25632)
Diffstat (limited to 'keyboards/handwired')
-rw-r--r--keyboards/handwired/owlet60/matrix.c144
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c42
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/matrix.c4
3 files changed, 84 insertions, 106 deletions
diff --git a/keyboards/handwired/owlet60/matrix.c b/keyboards/handwired/owlet60/matrix.c
index 7ef5d66a9f..2017b4de85 100644
--- a/keyboards/handwired/owlet60/matrix.c
+++ b/keyboards/handwired/owlet60/matrix.c
@@ -29,82 +29,62 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "timer.h"
#if (MATRIX_COLS <= 8)
-# define print_matrix_header() print("\nr/c 01234567\n")
-# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
+# define print_matrix_header() print("\nr/c 01234567\n")
+# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
# define ROW_SHIFTER ((uint8_t)1)
#elif (MATRIX_COLS <= 16)
-# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
-# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
+# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
+# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
# define ROW_SHIFTER ((uint16_t)1)
#elif (MATRIX_COLS <= 32)
-# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
-# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
-# define ROW_SHIFTER ((uint32_t)1)
+# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
+# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
+# define ROW_SHIFTER ((uint32_t)1)
#endif
static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
-static const uint8_t col_select_pins[3] = MATRIX_COL_SELECT_PINS;
-static const uint8_t dat_pin = MATRIX_COL_DATA_PIN;
+static const uint8_t col_select_pins[3] = MATRIX_COL_SELECT_PINS;
+static const uint8_t dat_pin = MATRIX_COL_DATA_PIN;
/* matrix state(1:on, 0:off) */
-static matrix_row_t raw_matrix[MATRIX_ROWS]; //raw values
-static matrix_row_t matrix[MATRIX_ROWS]; //raw values
+static matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
+static matrix_row_t matrix[MATRIX_ROWS]; // raw values
/* 2d array containing binary representation of its index */
static const uint8_t num_in_binary[8][3] = {
- {0, 0, 0},
- {0, 0, 1},
- {0, 1, 0},
- {0, 1, 1},
- {1, 0, 0},
- {1, 0, 1},
- {1, 1, 0},
- {1, 1, 1},
+ {0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 1, 1}, {1, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1},
};
static void select_col_analog(uint8_t col);
static void mux_pin_control(const uint8_t binary[]);
-void debounce_init(uint8_t num_rows);
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed);
+void debounce_init(void);
+void debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed);
+__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) {}
-
-__attribute__ ((weak))
-void matrix_init_kb(void) {
- matrix_init_user();
+__attribute__((weak)) void matrix_init_kb(void) {
+ matrix_init_user();
}
-__attribute__ ((weak))
-void matrix_scan_kb(void) {
- matrix_scan_user();
+__attribute__((weak)) void matrix_scan_kb(void) {
+ matrix_scan_user();
}
-inline
-uint8_t matrix_rows(void)
-{
+inline uint8_t matrix_rows(void) {
return MATRIX_ROWS;
}
-inline
-uint8_t matrix_cols(void)
-{
+inline uint8_t matrix_cols(void) {
return MATRIX_COLS;
}
-inline
-bool matrix_is_on(uint8_t row, uint8_t col)
-{
- return (matrix[row] & ((matrix_row_t)1<<col));
+inline bool matrix_is_on(uint8_t row, uint8_t col) {
+ return (matrix[row] & ((matrix_row_t)1 << col));
}
-inline
-matrix_row_t matrix_get_row(uint8_t row)
-{
+inline matrix_row_t matrix_get_row(uint8_t row) {
// Matrix mask lets you disable switches in the returned matrix data. For example, if you have a
// switch blocker installed and the switch is always pressed.
#ifdef MATRIX_MASKED
@@ -114,48 +94,44 @@ matrix_row_t matrix_get_row(uint8_t row)
#endif
}
-void matrix_print(void)
-{
+void matrix_print(void) {
print_matrix_header();
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
- print_hex8(row); print(": ");
+ print_hex8(row);
+ print(": ");
print_matrix_row(row);
print("\n");
}
}
// uses standard row code
-static void select_row(uint8_t row)
-{
+static void select_row(uint8_t row) {
gpio_set_pin_output(row_pins[row]);
gpio_write_pin_low(row_pins[row]);
}
-static void unselect_row(uint8_t row)
-{
+static void unselect_row(uint8_t row) {
gpio_set_pin_input_high(row_pins[row]);
}
-static void unselect_rows(void)
-{
- for(uint8_t x = 0; x < MATRIX_ROWS; x++) {
+static void unselect_rows(void) {
+ for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
gpio_set_pin_input_high(row_pins[x]);
}
}
-static void init_pins(void) { // still need some fixing, this might not work
- unselect_rows(); // with the loop
- /*
- for (uint8_t x = 0; x < MATRIX_COLS; x++) {
- gpio_set_pin_input_high(col_pins[x]);
- }
- */
- gpio_set_pin_input_high(dat_pin);
+static void init_pins(void) { // still need some fixing, this might not work
+ unselect_rows(); // with the loop
+ /*
+ for (uint8_t x = 0; x < MATRIX_COLS; x++) {
+ gpio_set_pin_input_high(col_pins[x]);
+ }
+ */
+ gpio_set_pin_input_high(dat_pin);
}
-static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
-{
+static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
// Store last value of row prior to reading
matrix_row_t last_row_value = current_matrix[current_row];
@@ -167,15 +143,14 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
wait_us(30);
// For each col...
- for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
-
+ for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
// Select the col pin to read (active low)
select_col_analog(col_index);
wait_us(30);
uint8_t pin_state = gpio_read_pin(dat_pin);
// Populate the matrix row with the state of the col pin
- current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
+ current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
}
// Unselect row
@@ -184,19 +159,17 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
return (last_row_value != current_matrix[current_row]);
}
-
void matrix_init(void) {
-
// initialize key pins
init_pins();
// initialize matrix state: all keys off
- for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
raw_matrix[i] = 0;
- matrix[i] = 0;
+ matrix[i] = 0;
}
- debounce_init(MATRIX_ROWS);
+ debounce_init();
matrix_init_kb();
@@ -205,15 +178,14 @@ void matrix_init(void) {
}
// modified for per col read matrix scan
-uint8_t matrix_scan(void)
-{
+uint8_t matrix_scan(void) {
bool changed = false;
for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
changed |= read_cols_on_row(raw_matrix, current_row);
}
- debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
+ debounce(raw_matrix, matrix, changed);
matrix_scan_kb();
return (uint8_t)changed;
@@ -231,7 +203,7 @@ uint8_t matrix_scan(void)
}
#endif
- debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
+ debounce(raw_matrix, matrix, changed);
matrix_scan_kb();
return (uint8_t)changed;
@@ -239,8 +211,7 @@ uint8_t matrix_scan(void)
*/
static void select_col_analog(uint8_t col) {
- switch(col) {
-
+ switch (col) {
case 0:
mux_pin_control(num_in_binary[0]);
break;
@@ -273,26 +244,23 @@ static void select_col_analog(uint8_t col) {
static void mux_pin_control(const uint8_t binary[]) {
// set pin0
gpio_set_pin_output(col_select_pins[0]);
- if(binary[2] == 0) {
+ if (binary[2] == 0) {
gpio_write_pin_low(col_select_pins[0]);
- }
- else {
+ } else {
gpio_write_pin_high(col_select_pins[0]);
}
// set pin1
gpio_set_pin_output(col_select_pins[1]);
- if(binary[1] == 0) {
+ if (binary[1] == 0) {
gpio_write_pin_low(col_select_pins[1]);
- }
- else {
+ } else {
gpio_write_pin_high(col_select_pins[1]);
}
// set pin2
gpio_set_pin_output(col_select_pins[2]);
- if(binary[0] == 0) {
+ if (binary[0] == 0) {
gpio_write_pin_low(col_select_pins[2]);
- }
- else {
+ } else {
gpio_write_pin_high(col_select_pins[2]);
}
}
diff --git a/keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c b/keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c
index fa9b6ef0fd..2fa06ec7ce 100644
--- a/keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c
+++ b/keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c
@@ -44,7 +44,7 @@ static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS;
static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
# ifdef MATRIX_MUL_SELECT
-static const pin_t col_sel[MATRIX_COLS] = MATRIX_MUL_SEL;
+static const pin_t col_sel[MATRIX_COLS] = MATRIX_MUL_SEL;
# endif
#endif
@@ -57,8 +57,8 @@ static const uint8_t delay_sel[] = {MATRIX_IO_DELAY_MULSEL};
#endif
/* matrix state(1:on, 0:off) */
-extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
-extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
+extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
+extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
@@ -68,7 +68,9 @@ static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
}
static inline void gpio_atomic_set_pin_input_high(pin_t pin) {
- ATOMIC_BLOCK_FORCEON { gpio_set_pin_input_high(pin); }
+ ATOMIC_BLOCK_FORCEON {
+ gpio_set_pin_input_high(pin);
+ }
}
// matrix code
@@ -108,9 +110,13 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
#elif defined(DIODE_DIRECTION)
# if (DIODE_DIRECTION == COL2ROW)
-static void select_row(uint8_t row) { gpio_atomic_set_pin_output_low(row_pins[row]); }
+static void select_row(uint8_t row) {
+ gpio_atomic_set_pin_output_low(row_pins[row]);
+}
-static void unselect_row(uint8_t row) { gpio_atomic_set_pin_input_high(row_pins[row]); }
+static void unselect_row(uint8_t row) {
+ gpio_atomic_set_pin_input_high(row_pins[row]);
+}
static void unselect_rows(void) {
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
@@ -153,7 +159,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Unselect row
unselect_row(current_row);
# ifdef MATRIX_IO_DELAY_PORTS
- if (current_row_value) { // wait for col signal to go HIGH
+ if (current_row_value) { // wait for col signal to go HIGH
bool is_pressed;
do {
MATRIX_DEBUG_DELAY_START();
@@ -170,7 +176,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
}
# endif
# ifdef MATRIX_IO_DELAY_ADAPTIVE
- if (current_row_value) { // wait for col signal to go HIGH
+ if (current_row_value) { // wait for col signal to go HIGH
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
MATRIX_DEBUG_DELAY_START();
# ifdef MATRIX_MUL_SELECT
@@ -184,7 +190,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
}
# endif
# ifdef MATRIX_IO_DELAY_ADAPTIVE2
- if (current_row_value) { // wait for col signal to go HIGH
+ if (current_row_value) { // wait for col signal to go HIGH
pin_t state;
do {
MATRIX_DEBUG_DELAY_START();
@@ -204,7 +210,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
# endif
if (MATRIX_IO_DELAY_ALWAYS || current_row + 1 < MATRIX_ROWS) {
MATRIX_DEBUG_DELAY_START();
- matrix_output_unselect_delay(current_row, current_row_value != 0); // wait for col signal to go HIGH
+ matrix_output_unselect_delay(current_row, current_row_value != 0); // wait for col signal to go HIGH
MATRIX_DEBUG_DELAY_END();
}
@@ -218,9 +224,13 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
# elif (DIODE_DIRECTION == ROW2COL)
-static void select_col(uint8_t col) { gpio_atomic_set_pin_output_low(col_pins[col]); }
+static void select_col(uint8_t col) {
+ gpio_atomic_set_pin_output_low(col_pins[col]);
+}
-static void unselect_col(uint8_t col) { gpio_atomic_set_pin_input_high(col_pins[col]); }
+static void unselect_col(uint8_t col) {
+ gpio_atomic_set_pin_input_high(col_pins[col]);
+}
static void unselect_cols(void) {
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
@@ -237,7 +247,7 @@ static void init_pins(void) {
static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
bool matrix_changed = false;
- bool key_pressed = false;
+ bool key_pressed = false;
// Select col
select_col(current_col);
@@ -269,7 +279,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
// Unselect col
unselect_col(current_col);
if (MATRIX_IO_DELAY_ALWAYS || current_col + 1 < MATRIX_COLS) {
- matrix_output_unselect_delay(current_col, key_pressed); // wait for col signal to go HIGH
+ matrix_output_unselect_delay(current_col, key_pressed); // wait for col signal to go HIGH
}
return matrix_changed;
@@ -292,7 +302,7 @@ void matrix_init(void) {
matrix[i] = 0;
}
- debounce_init(MATRIX_ROWS);
+ debounce_init();
matrix_init_kb();
}
@@ -317,7 +327,7 @@ uint8_t matrix_scan(void) {
MATRIX_DEBUG_GAP();
MATRIX_DEBUG_SCAN_START();
- debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
+ debounce(raw_matrix, matrix, changed);
MATRIX_DEBUG_SCAN_END();
MATRIX_DEBUG_GAP();
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/matrix.c b/keyboards/handwired/symmetric70_proto/matrix_fast/matrix.c
index 842df65dbd..99ce2f2c2d 100644
--- a/keyboards/handwired/symmetric70_proto/matrix_fast/matrix.c
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/matrix.c
@@ -166,7 +166,7 @@ void matrix_init(void) {
matrix[i] = 0;
}
- debounce_init(MATRIX_ROWS);
+ debounce_init();
matrix_init_kb();
}
@@ -221,7 +221,7 @@ uint8_t matrix_scan(void) {
MATRIX_DEBUG_SCAN_END(); MATRIX_DEBUG_GAP(); MATRIX_DEBUG_SCAN_START();
// debounce raw_matrix[] to matrix[]
- debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
+ debounce(raw_matrix, matrix, changed);
MATRIX_DEBUG_SCAN_END(); MATRIX_DEBUG_GAP();
MATRIX_DEBUG_SCAN_START();