aboutsummaryrefslogtreecommitdiff
path: root/keyboard/phantom/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard/phantom/matrix.c')
-rw-r--r--keyboard/phantom/matrix.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/keyboard/phantom/matrix.c b/keyboard/phantom/matrix.c
index 07f3f4289..7ea494a7e 100644
--- a/keyboard/phantom/matrix.c
+++ b/keyboard/phantom/matrix.c
@@ -26,8 +26,8 @@ static uint8_t debouncing = DEBOUNCE;
26// bit array of key state(1:on, 0:off) 26// bit array of key state(1:on, 0:off)
27static matrix_row_t *matrix; 27static matrix_row_t *matrix;
28static matrix_row_t *matrix_debounced; 28static matrix_row_t *matrix_debounced;
29static matrix_row_t _matrix0[MATRIX_ROWS]; 29static matrix_row_t matrix0[MATRIX_ROWS];
30static matrix_row_t _matrix1[MATRIX_ROWS]; 30static matrix_row_t matrix1[MATRIX_ROWS];
31 31
32 32
33#define _DDRA (uint8_t *const)&DDRA 33#define _DDRA (uint8_t *const)&DDRA
@@ -164,20 +164,16 @@ void matrix_init(void)
164 setup_leds(); 164 setup_leds();
165 165
166 // initialize matrix state: all keys off 166 // initialize matrix state: all keys off
167 for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; 167 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
168 for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00; 168 matrix0[i] = 0;
169 matrix = _matrix0; 169 matrix1[i] = 0;
170 matrix_debounced = _matrix1; 170 }
171 matrix = matrix0;
172 matrix_debounced = matrix1;
171} 173}
172 174
173uint8_t matrix_scan(void) 175uint8_t matrix_scan(void)
174{ 176{
175 if (!debouncing) {
176 matrix_row_t *tmp = matrix_debounced;
177 matrix_debounced = matrix;
178 matrix = tmp;
179 }
180
181 for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-16 177 for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-16
182 pull_column(col); // output hi on theline 178 pull_column(col); // output hi on theline
183 _delay_us(3); // without this wait it won't read stable value. 179 _delay_us(3); // without this wait it won't read stable value.
@@ -196,7 +192,13 @@ uint8_t matrix_scan(void)
196 } 192 }
197 193
198 if (debouncing) { 194 if (debouncing) {
199 debouncing--; 195 if (--debouncing) {
196 _delay_ms(1);
197 } else {
198 matrix_row_t *tmp = matrix_debounced;
199 matrix_debounced = matrix;
200 matrix = tmp;
201 }
200 } 202 }
201 203
202 return 1; 204 return 1;
@@ -209,12 +211,6 @@ bool matrix_is_modified(void)
209} 211}
210 212
211inline 213inline
212bool matrix_has_ghost(void)
213{
214 return false;
215}
216
217inline
218bool matrix_is_on(uint8_t row, uint8_t col) 214bool matrix_is_on(uint8_t row, uint8_t col)
219{ 215{
220 return (matrix_debounced[row] & ((matrix_row_t)1<<col)); 216 return (matrix_debounced[row] & ((matrix_row_t)1<<col));