diff options
author | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2020-12-05 22:38:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-06 17:38:46 +1100 |
commit | a6a12890037c706e67716e28e37432693ba17ace (patch) | |
tree | 734aae5a6a21791dc6ac3585195599ec640d0c4d /keyboards/duck | |
parent | 644dd9c388f9664d17177e78966264afcbd23462 (diff) | |
download | qmk_firmware-a6a12890037c706e67716e28e37432693ba17ace.tar.gz qmk_firmware-a6a12890037c706e67716e28e37432693ba17ace.zip |
Revert back to the old matrix (Take the blue pill) (#10568)
* revert back to the old matrix.
* apparently I can't count, J is the 19th not the 20th column
Diffstat (limited to 'keyboards/duck')
-rw-r--r-- | keyboards/duck/tcv3/matrix.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/keyboards/duck/tcv3/matrix.c b/keyboards/duck/tcv3/matrix.c index 38bc5c882..d2d90470a 100644 --- a/keyboards/duck/tcv3/matrix.c +++ b/keyboards/duck/tcv3/matrix.c | |||
@@ -21,8 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
21 | #include "util.h" | 21 | #include "util.h" |
22 | #include "print.h" | 22 | #include "print.h" |
23 | #include "debug.h" | 23 | #include "debug.h" |
24 | #include "debounce.h" | 24 | |
25 | #include "wait.h" | 25 | static uint8_t debouncing = DEBOUNCE; |
26 | 26 | ||
27 | /* matrix state(1:on, 0:off) */ | 27 | /* matrix state(1:on, 0:off) */ |
28 | static matrix_row_t matrix[MATRIX_ROWS]; | 28 | static matrix_row_t matrix[MATRIX_ROWS]; |
@@ -74,16 +74,13 @@ void matrix_init(void) { | |||
74 | matrix_debouncing[i] = 0; | 74 | matrix_debouncing[i] = 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | debounce_init(MATRIX_ROWS); | ||
78 | |||
79 | matrix_init_quantum(); | 77 | matrix_init_quantum(); |
80 | } | 78 | } |
81 | uint8_t matrix_scan(void) { | ||
82 | bool changed = false; | ||
83 | 79 | ||
84 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | 80 | uint8_t matrix_scan(void) { |
81 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
85 | select_col(col); | 82 | select_col(col); |
86 | wait_us(30); | 83 | _delay_us(3); |
87 | 84 | ||
88 | uint8_t rows = read_rows(col); | 85 | uint8_t rows = read_rows(col); |
89 | 86 | ||
@@ -92,16 +89,27 @@ uint8_t matrix_scan(void) { | |||
92 | bool curr_bit = rows & (1<<row); | 89 | bool curr_bit = rows & (1<<row); |
93 | if (prev_bit != curr_bit) { | 90 | if (prev_bit != curr_bit) { |
94 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); | 91 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); |
95 | changed = true; | 92 | if (debouncing) { |
93 | dprint("bounce!: "); dprintf("%02X", debouncing); dprintln(); | ||
94 | } | ||
95 | debouncing = DEBOUNCE; | ||
96 | } | 96 | } |
97 | } | 97 | } |
98 | unselect_cols(); | 98 | unselect_cols(); |
99 | } | 99 | } |
100 | 100 | ||
101 | debounce(matrix, matrix_debouncing, MATRIX_ROWS, changed); | 101 | if (debouncing) { |
102 | if (--debouncing) { | ||
103 | _delay_ms(1); | ||
104 | } else { | ||
105 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
106 | matrix[i] = matrix_debouncing[i]; | ||
107 | } | ||
108 | } | ||
109 | } | ||
102 | 110 | ||
103 | matrix_scan_quantum(); | 111 | matrix_scan_quantum(); |
104 | return (uint8_t)changed; | 112 | return 1; |
105 | } | 113 | } |
106 | 114 | ||
107 | inline matrix_row_t matrix_get_row(uint8_t row) { | 115 | inline matrix_row_t matrix_get_row(uint8_t row) { |
@@ -132,7 +140,7 @@ static void init_rows(void) { | |||
132 | } | 140 | } |
133 | 141 | ||
134 | static uint8_t read_rows(uint8_t col) { | 142 | static uint8_t read_rows(uint8_t col) { |
135 | if (col == 20) { | 143 | if (col == 19) { |
136 | return PINE&(1<<2) ? 0 : (1<<0); | 144 | return PINE&(1<<2) ? 0 : (1<<0); |
137 | } else { | 145 | } else { |
138 | return (PIND&(1<<0) ? (1<<1) : 0) | | 146 | return (PIND&(1<<0) ? (1<<1) : 0) | |
@@ -269,4 +277,4 @@ static void select_col(uint8_t col) { | |||
269 | PORTB |= 0b00100000; | 277 | PORTB |= 0b00100000; |
270 | break; | 278 | break; |
271 | } | 279 | } |
272 | } | 280 | } \ No newline at end of file |