summaryrefslogtreecommitdiff
path: root/keyboards/halfcliff
diff options
context:
space:
mode:
authorフィルターペーパー <76888457+filterpaper@users.noreply.github.com>2025-10-19 10:14:37 +0800
committerGitHub <noreply@github.com>2025-10-19 03:14:37 +0100
commit81df54308687713371ed5fbf4947e38963c7867b (patch)
tree36d0a432adcf7613f8a362f3a534e68b4ddaad19 /keyboards/halfcliff
parent4f21beb7153c2b0a1f4d41de7dad5a2173f896b6 (diff)
Debounce: Deprecate num_rows parameter (#25632)
Diffstat (limited to 'keyboards/halfcliff')
-rw-r--r--keyboards/halfcliff/matrix.c56
1 files changed, 36 insertions, 20 deletions
diff --git a/keyboards/halfcliff/matrix.c b/keyboards/halfcliff/matrix.c
index 790f8c41bb..fc9d437a45 100644
--- a/keyboards/halfcliff/matrix.c
+++ b/keyboards/halfcliff/matrix.c
@@ -29,16 +29,20 @@ static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
29static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; 29static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
30 30
31/* matrix state(1:on, 0:off) */ 31/* matrix state(1:on, 0:off) */
32static matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values 32static matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
33static matrix_row_t matrix[MATRIX_ROWS]; // debounced values 33static matrix_row_t matrix[MATRIX_ROWS]; // debounced values
34 34
35// row offsets for each hand 35// row offsets for each hand
36uint8_t thisHand, thatHand; 36uint8_t thisHand, thatHand;
37 37
38// user-defined overridable functions 38// user-defined overridable functions
39__attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); } 39__attribute__((weak)) void matrix_init_kb(void) {
40 matrix_init_user();
41}
40 42
41__attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); } 43__attribute__((weak)) void matrix_scan_kb(void) {
44 matrix_scan_user();
45}
42 46
43__attribute__((weak)) void matrix_init_user(void) {} 47__attribute__((weak)) void matrix_init_user(void) {}
44 48
@@ -46,7 +50,9 @@ __attribute__((weak)) void matrix_scan_user(void) {}
46 50
47__attribute__((weak)) void matrix_slave_scan_user(void) {} 51__attribute__((weak)) void matrix_slave_scan_user(void) {}
48 52
49matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } 53matrix_row_t matrix_get_row(uint8_t row) {
54 return matrix[row];
55}
50 56
51void matrix_print(void) {} 57void matrix_print(void) {}
52 58
@@ -58,13 +64,19 @@ static inline void gpio_atomic_set_pin_output_low(pin_t pin) {
58} 64}
59 65
60static inline void gpio_atomic_set_pin_input_high(pin_t pin) { 66static inline void gpio_atomic_set_pin_input_high(pin_t pin) {
61 ATOMIC_BLOCK_FORCEON { gpio_set_pin_input_high(pin); } 67 ATOMIC_BLOCK_FORCEON {
68 gpio_set_pin_input_high(pin);
69 }
62} 70}
63 71
64// matrix code 72// matrix code
65static void select_row(uint8_t row) { gpio_atomic_set_pin_output_low(row_pins[row]); } 73static void select_row(uint8_t row) {
74 gpio_atomic_set_pin_output_low(row_pins[row]);
75}
66 76
67static void unselect_row(uint8_t row) { gpio_atomic_set_pin_input_high(row_pins[row]); } 77static void unselect_row(uint8_t row) {
78 gpio_atomic_set_pin_input_high(row_pins[row]);
79}
68 80
69static void unselect_rows(void) { 81static void unselect_rows(void) {
70 for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { 82 for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
@@ -92,7 +104,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
92 // Unselect row 104 // Unselect row
93 unselect_row(current_row); 105 unselect_row(current_row);
94 if (current_row + 1 < MATRIX_ROWS) { 106 if (current_row + 1 < MATRIX_ROWS) {
95 wait_us(30); // wait for row signal to go HIGH 107 wait_us(30); // wait for row signal to go HIGH
96 } 108 }
97 109
98 // If the row has changed, store the row and return the changed flag. 110 // If the row has changed, store the row and return the changed flag.
@@ -103,9 +115,13 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
103 return false; 115 return false;
104} 116}
105 117
106static void select_col(uint8_t col) { gpio_atomic_set_pin_output_low(col_pins[col]); } 118static void select_col(uint8_t col) {
119 gpio_atomic_set_pin_output_low(col_pins[col]);
120}
107 121
108static void unselect_col(uint8_t col) { gpio_atomic_set_pin_input_high(col_pins[col]); } 122static void unselect_col(uint8_t col) {
123 gpio_atomic_set_pin_input_high(col_pins[col]);
124}
109 125
110static void unselect_cols(void) { 126static void unselect_cols(void) {
111 for (uint8_t x = 0; x < MATRIX_COLS; x++) { 127 for (uint8_t x = 0; x < MATRIX_COLS; x++) {
@@ -156,7 +172,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
156 // Unselect col 172 // Unselect col
157 unselect_col(current_col); 173 unselect_col(current_col);
158 if (current_col + 1 < MATRIX_COLS) { 174 if (current_col + 1 < MATRIX_COLS) {
159 wait_us(30); // wait for col signal to go HIGH 175 wait_us(30); // wait for col signal to go HIGH
160 } 176 }
161 177
162 return matrix_changed; 178 return matrix_changed;
@@ -201,7 +217,7 @@ void matrix_init(void) {
201 matrix[i] = 0; 217 matrix[i] = 0;
202 } 218 }
203 219
204 debounce_init(ROWS_PER_HAND); 220 debounce_init();
205 221
206 matrix_init_kb(); 222 matrix_init_kb();
207 223
@@ -248,26 +264,26 @@ bool matrix_post_scan(void) {
248} 264}
249 265
250uint8_t matrix_scan(void) { 266uint8_t matrix_scan(void) {
251 bool local_changed = false; 267 bool local_changed = false;
252 static matrix_row_t temp_raw_matrix[MATRIX_ROWS]; // temp raw values 268 static matrix_row_t temp_raw_matrix[MATRIX_ROWS]; // temp raw values
253 269
254 // Set row, read cols 270 // Set row, read cols
255 for (uint8_t current_row = 0; current_row < ROWS_PER_HAND/2; current_row++) { 271 for (uint8_t current_row = 0; current_row < ROWS_PER_HAND / 2; current_row++) {
256 local_changed |= read_cols_on_row(raw_matrix, current_row); 272 local_changed |= read_cols_on_row(raw_matrix, current_row);
257 } 273 }
258 274
259 // Set col, read rows 275 // Set col, read rows
260 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { 276 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
261 local_changed |= read_rows_on_col(temp_raw_matrix, current_col); 277 local_changed |= read_rows_on_col(temp_raw_matrix, current_col);
262 //Updated key matrix on lines 6-10 (or lines 16-20) 278 // Updated key matrix on lines 6-10 (or lines 16-20)
263 if(local_changed) { 279 if (local_changed) {
264 for (uint8_t i = ROWS_PER_HAND/2; i < ROWS_PER_HAND; i++) { 280 for (uint8_t i = ROWS_PER_HAND / 2; i < ROWS_PER_HAND; i++) {
265 raw_matrix[i] = temp_raw_matrix[i]; 281 raw_matrix[i] = temp_raw_matrix[i];
266 } 282 }
267 } 283 }
268 } 284 }
269 285
270 debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, local_changed); 286 debounce(raw_matrix, matrix + thisHand, local_changed);
271 287
272 bool remote_changed = matrix_post_scan(); 288 bool remote_changed = matrix_post_scan();
273 return (uint8_t)(local_changed || remote_changed); 289 return (uint8_t)(local_changed || remote_changed);