aboutsummaryrefslogtreecommitdiff
path: root/keyboard/phantom
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard/phantom')
-rw-r--r--keyboard/phantom/config.h13
-rw-r--r--keyboard/phantom/matrix.c34
2 files changed, 26 insertions, 21 deletions
diff --git a/keyboard/phantom/config.h b/keyboard/phantom/config.h
index 9e8a823d7..a5d472979 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/>.
26#define MANUFACTURER t.m.k. 26#define MANUFACTURER t.m.k.
27#define PRODUCT Phantom 27#define PRODUCT Phantom
28 28
29
30/* message strings */ 29/* message strings */
31#define DESCRIPTION t.m.k. keyboard firmware for Phantom 30#define DESCRIPTION t.m.k. keyboard firmware for Phantom
32 31
33
34/* matrix size */ 32/* matrix size */
35#define MATRIX_ROWS 6 33#define MATRIX_ROWS 6
36#define MATRIX_COLS 17 34#define MATRIX_COLS 17
@@ -41,12 +39,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
41/* Set 0 if need no debouncing */ 39/* Set 0 if need no debouncing */
42#define DEBOUNCE 7 40#define DEBOUNCE 7
43 41
42/* legacy keymap support */
43#define USE_LEGACY_KEYMAP
44 44
45/* key combination for command */ 45/* key combination for command */
46#define IS_COMMAND() ( \ 46#define IS_COMMAND() ( \
47 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ 47 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
48) 48)
49 49
50/* Boot Section Size in *BYTEs*
51 * Teensy halfKay 512
52 * Teensy++ halfKay 1024
53 * Atmel DFU loader 4096
54 * LUFA bootloader 4096
55 * USBaspLoader 2048
56 */
57#define BOOTLOADER_SIZE 4096
58
50// TODO: configurable 59// TODO: configurable
51#define DEBUG_LED 0 60#define DEBUG_LED 0
52#define DEBUG_LED_CONFIG 61#define DEBUG_LED_CONFIG
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));