aboutsummaryrefslogtreecommitdiff
path: root/keyboard/hid_liber/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard/hid_liber/matrix.c')
-rw-r--r--keyboard/hid_liber/matrix.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/keyboard/hid_liber/matrix.c b/keyboard/hid_liber/matrix.c
index 6798b36d7..2d939ef63 100644
--- a/keyboard/hid_liber/matrix.c
+++ b/keyboard/hid_liber/matrix.c
@@ -19,7 +19,7 @@
19 19
20 20
21#ifndef DEBOUNCE 21#ifndef DEBOUNCE
22# define DEBOUNCE 0 22# define DEBOUNCE 0
23#endif 23#endif
24static uint8_t debouncing = DEBOUNCE; 24static uint8_t debouncing = DEBOUNCE;
25 25
@@ -142,7 +142,7 @@ void matrix_init(void)
142 // To use PORTF disable JTAG with writing JTD bit twice within four cycles. 142 // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
143 MCUCR |= (1<<JTD); 143 MCUCR |= (1<<JTD);
144 MCUCR |= (1<<JTD); 144 MCUCR |= (1<<JTD);
145 145
146 // initialize row and col 146 // initialize row and col
147 setup_io_pins(); 147 setup_io_pins();
148 setup_leds(); 148 setup_leds();
@@ -164,7 +164,7 @@ uint8_t matrix_scan(void)
164 164
165 for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-7 165 for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-7
166 pull_column(col); // output hi on theline 166 pull_column(col); // output hi on theline
167 _delay_us(3); // without this wait it won't read stable value. 167 _delay_us(5); // without this wait it won't read stable value.
168 for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-17 168 for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-17
169 bool prev_bit = matrix[row] & (1<<col); 169 bool prev_bit = matrix[row] & (1<<col);
170 bool curr_bit = *row_pin[row] & row_bit[row]; 170 bool curr_bit = *row_pin[row] & row_bit[row];
@@ -173,6 +173,7 @@ uint8_t matrix_scan(void)
173 if (debouncing) { 173 if (debouncing) {
174 debug("bounce!: "); debug_hex(debouncing); print("\n"); 174 debug("bounce!: "); debug_hex(debouncing); print("\n");
175 } 175 }
176 _delay_ms(1); // improved affect on bouncing
176 debouncing = DEBOUNCE; 177 debouncing = DEBOUNCE;
177 } 178 }
178 } 179 }