diff options
author | tmk <nobody@nowhere> | 2013-03-12 16:05:50 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-03-12 16:05:50 +0900 |
commit | 30f9baf8985f3caa626bcd0eef8519b93f23669b (patch) | |
tree | ea5b5e0aba4c1229c57d184205d4fc11abfa0a86 /keyboard/phantom | |
parent | c4ab832be0f110a127b20e8df2b5223bceb8dcd1 (diff) |
Fix debouncing and add legacy keymap support
Diffstat (limited to 'keyboard/phantom')
-rw-r--r-- | keyboard/phantom/config.h | 13 | ||||
-rw-r--r-- | keyboard/phantom/matrix.c | 34 |
2 files changed, 26 insertions, 21 deletions
diff --git a/keyboard/phantom/config.h b/keyboard/phantom/config.h index 9e8a823d7c..a5d472979a 100644 --- a/keyboard/phantom/config.h +++ b/keyboard/phantom/config.h @@ -26,11 +26,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define MANUFACTURER t.m.k. #define PRODUCT Phantom - /* message strings */ #define DESCRIPTION t.m.k. keyboard firmware for Phantom - /* matrix size */ #define MATRIX_ROWS 6 #define MATRIX_COLS 17 @@ -41,12 +39,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. /* Set 0 if need no debouncing */ #define DEBOUNCE 7 +/* legacy keymap support */ +#define USE_LEGACY_KEYMAP /* key combination for command */ #define IS_COMMAND() ( \ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ ) +/* Boot Section Size in *BYTEs* + * Teensy halfKay 512 + * Teensy++ halfKay 1024 + * Atmel DFU loader 4096 + * LUFA bootloader 4096 + * USBaspLoader 2048 + */ +#define BOOTLOADER_SIZE 4096 + // TODO: configurable #define DEBUG_LED 0 #define DEBUG_LED_CONFIG diff --git a/keyboard/phantom/matrix.c b/keyboard/phantom/matrix.c index 07f3f42892..7ea494a7e2 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; @@ -209,12 +211,6 @@ bool matrix_is_modified(void) } inline -bool matrix_has_ghost(void) -{ - return false; -} - -inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix_debounced[row] & ((matrix_row_t)1<<col)); |