From 4ae979f6ef8dbf9e1d1f35be15322ad6d02e2958 Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 6 Oct 2012 02:23:12 +0900 Subject: Initial version of new code for layer switch is added. --- keyboard/hhkb/matrix.c | 50 ++++++-------------------------------------------- 1 file changed, 6 insertions(+), 44 deletions(-) (limited to 'keyboard/hhkb/matrix.c') diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c index 79d2d98731..3bd6e73b35 100644 --- a/keyboard/hhkb/matrix.c +++ b/keyboard/hhkb/matrix.c @@ -43,22 +43,10 @@ along with this program. If not, see . // matrix state buffer(1:on, 0:off) -#if (MATRIX_COLS <= 8) -static uint8_t *matrix; -static uint8_t *matrix_prev; -static uint8_t _matrix0[MATRIX_ROWS]; -static uint8_t _matrix1[MATRIX_ROWS]; -#else -static uint16_t *matrix; -static uint16_t *matrix_prev; -static uint16_t _matrix0[MATRIX_ROWS]; -static uint16_t _matrix1[MATRIX_ROWS]; -#endif - -// HHKB has no ghost and no bounce. -#ifdef MATRIX_HAS_GHOST -static bool matrix_has_ghost_in_row(uint8_t row); -#endif +static matrix_row_t *matrix; +static matrix_row_t *matrix_prev; +static matrix_row_t _matrix0[MATRIX_ROWS]; +static matrix_row_t _matrix1[MATRIX_ROWS]; // Matrix I/O ports @@ -192,6 +180,8 @@ uint8_t matrix_scan(void) } // Ignore if this code region execution time elapses more than 20us. + // MEMO: 20[us] * (TIMER_RAW_FREQ / 1000000)[count per us] + // MEMO: then change above using this rule: a/(b/c) = a*1/(b/c) = a*(c/b) if (TIMER_DIFF_RAW(TIMER_RAW, last) > 20/(1000000/TIMER_RAW_FREQ)) { matrix[row] = matrix_prev[row]; } @@ -219,12 +209,6 @@ bool matrix_is_modified(void) inline bool matrix_has_ghost(void) { -#ifdef MATRIX_HAS_GHOST - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - if (matrix_has_ghost_in_row(i)) - return true; - } -#endif return false; } @@ -257,11 +241,6 @@ void matrix_print(void) pbin_reverse(matrix_get_row(row)); #else pbin_reverse16(matrix_get_row(row)); -#endif -#ifdef MATRIX_HAS_GHOST - if (matrix_has_ghost_in_row(row)) { - print(" Date: Wed, 17 Oct 2012 14:23:31 +0900 Subject: HHKB scan matrix: fix wait time on power on --- keyboard/hhkb/matrix.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'keyboard/hhkb/matrix.c') diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c index 3bd6e73b35..01473d1ec7 100644 --- a/keyboard/hhkb/matrix.c +++ b/keyboard/hhkb/matrix.c @@ -23,7 +23,7 @@ along with this program. If not, see . #include #include #include -#include "print.h" +#include "debug.h" #include "util.h" #include "timer.h" #include "matrix.h" @@ -107,7 +107,7 @@ static matrix_row_t _matrix1[MATRIX_ROWS]; #define KEY_POWER_ON() do { \ KEY_INIT(); \ PORTB &= ~(1<<5); \ - _delay_us(200); \ + _delay_ms(1); \ } while (0) #define KEY_POWER_OFF() do { \ DDRB &= ~0x3F; \ @@ -228,21 +228,24 @@ uint16_t matrix_get_row(uint8_t row) return matrix[row]; } -void matrix_print(void) +void matrix_debug(void) { + if (!debug_matrix) + return; + #if (MATRIX_COLS <= 8) - print("\nr/c 01234567\n"); + debug("\nr/c 01234567\n"); #else - print("\nr/c 0123456789ABCDEF\n"); + debug("\nr/c 0123456789ABCDEF\n"); #endif for (uint8_t row = 0; row < matrix_rows(); row++) { - phex(row); print(": "); + debug_hex(row); debug(": "); #if (MATRIX_COLS <= 8) - pbin_reverse(matrix_get_row(row)); + debug_bin_reverse(matrix_get_row(row)); #else - pbin_reverse16(matrix_get_row(row)); + debug_bin_reverse16(matrix_get_row(row)); #endif - print("\n"); + debug("\n"); } } -- cgit v1.2.3 From ce2e06c39465b76a1780e5d594eaea7697afafd6 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 17 Oct 2012 21:43:44 +0900 Subject: Fix projects for new keycodes --- keyboard/hhkb/matrix.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'keyboard/hhkb/matrix.c') diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c index 01473d1ec7..fd0d6f97f6 100644 --- a/keyboard/hhkb/matrix.c +++ b/keyboard/hhkb/matrix.c @@ -23,7 +23,7 @@ along with this program. If not, see . #include #include #include -#include "debug.h" +#include "print.h" #include "util.h" #include "timer.h" #include "matrix.h" @@ -228,24 +228,21 @@ uint16_t matrix_get_row(uint8_t row) return matrix[row]; } -void matrix_debug(void) +void matrix_print(void) { - if (!debug_matrix) - return; - #if (MATRIX_COLS <= 8) - debug("\nr/c 01234567\n"); + print("\nr/c 01234567\n"); #else - debug("\nr/c 0123456789ABCDEF\n"); + print("\nr/c 0123456789ABCDEF\n"); #endif for (uint8_t row = 0; row < matrix_rows(); row++) { - debug_hex(row); debug(": "); + phex(row); print(": "); #if (MATRIX_COLS <= 8) - debug_bin_reverse(matrix_get_row(row)); + pbin_reverse(matrix_get_row(row)); #else - debug_bin_reverse16(matrix_get_row(row)); + pbin_reverse16(matrix_get_row(row)); #endif - debug("\n"); + print("\n"); } } -- cgit v1.2.3