X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=keyboard%2Fphantom%2Fmatrix.c;h=7ea494a7e2da54025829cdcad27dccabbb2ac426;hb=c852b0412826f53d8598f9577f9da439cb7bd720;hp=07f3f428924596f9624ebc40c9f57dd442f8c5c2;hpb=613fdb24fcdb4f8920f0d344cad5800d343f535c;p=max%2Ftmk_keyboard.git diff --git a/keyboard/phantom/matrix.c b/keyboard/phantom/matrix.c index 07f3f428..7ea494a7 100644 --- a/keyboard/phantom/matrix.c +++ b/keyboard/phantom/matrix.c @@ -26,8 +26,8 @@ static uint8_t debouncing = DEBOUNCE; // bit array of key state(1:on, 0:off) static matrix_row_t *matrix; static matrix_row_t *matrix_debounced; -static matrix_row_t _matrix0[MATRIX_ROWS]; -static matrix_row_t _matrix1[MATRIX_ROWS]; +static matrix_row_t matrix0[MATRIX_ROWS]; +static matrix_row_t matrix1[MATRIX_ROWS]; #define _DDRA (uint8_t *const)&DDRA @@ -164,20 +164,16 @@ void matrix_init(void) setup_leds(); // initialize matrix state: all keys off - for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; - for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00; - matrix = _matrix0; - matrix_debounced = _matrix1; + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix0[i] = 0; + matrix1[i] = 0; + } + matrix = matrix0; + matrix_debounced = matrix1; } uint8_t matrix_scan(void) { - if (!debouncing) { - matrix_row_t *tmp = matrix_debounced; - matrix_debounced = matrix; - matrix = tmp; - } - for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-16 pull_column(col); // output hi on theline _delay_us(3); // without this wait it won't read stable value. @@ -196,7 +192,13 @@ uint8_t matrix_scan(void) } if (debouncing) { - debouncing--; + if (--debouncing) { + _delay_ms(1); + } else { + matrix_row_t *tmp = matrix_debounced; + matrix_debounced = matrix; + matrix = tmp; + } } return 1; @@ -208,12 +210,6 @@ bool matrix_is_modified(void) return true; } -inline -bool matrix_has_ghost(void) -{ - return false; -} - inline bool matrix_is_on(uint8_t row, uint8_t col) {