From 49ce65f6981eeb973ddfe5dfd9c0e823adb3a58d Mon Sep 17 00:00:00 2001 From: Adam Mckaig Date: Fri, 19 Jun 2020 16:50:25 -0400 Subject: [PATCH 1/4] Ignore build artifacts These are derived from `make clean` in tmp_core/rules.mk --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8c6f3b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/*.hex +/*.eep +/*.cof +/*.elf +/*.map +/*.sym +/*.lss +/.dep +/obj_kc60_lufa From 806a54b651dd033c98388158d40f8eb9c9821880 Mon Sep 17 00:00:00 2001 From: Adam Mckaig Date: Fri, 19 Jun 2020 16:51:09 -0400 Subject: [PATCH 2/4] Update tmk_core to upstream master (as of 2020-06-19) Note that the upstream repo has added a couple fof submodules of its own since fb1fb12. We must init those with --recurse before the build will work. See: https://github.com/tmk/tmk_keyboard/tree/7cf3060a6dbfe57909668833cb3edb702b0899bb --- README.md | 2 +- tmk_core | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2a9355b..65b4e65 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ DIY compact keyboard by Massdrop. ## Build Move to this directory then just run `make` like: - $ git submodule update tmk_core + $ git submodule update --init --recursive $ make Use `make -f Makefile.pjrc` if you want to use PJRC stack but I find no reason to do so now. diff --git a/tmk_core b/tmk_core index fb1fb12..7cf3060 160000 --- a/tmk_core +++ b/tmk_core @@ -1 +1 @@ -Subproject commit fb1fb122a5971723f374cd737b7cc0aefd470af3 +Subproject commit 7cf3060a6dbfe57909668833cb3edb702b0899bb From b629cd69ff10f022bc07cbe54020705bcea51c27 Mon Sep 17 00:00:00 2001 From: Adam Mckaig Date: Fri, 19 Jun 2020 17:07:39 -0400 Subject: [PATCH 3/4] Update KC60 files from upstream GH60 It appears that these files (Makefile, keymap_common, matrix, led) were originally copied from tmk_core/keyboard/gh60. I've re-copied these from upstream at 7cf3060 to bring them up to date. They don't yet include the patches previously applied, so won't actually work until the next commit. I did this deliberately, so we can see the patch. --- Makefile | 7 +-- keymap_common.c | 30 ---------- keymap_common.h | 9 +-- keymap_default.c | 2 +- keymap_spacefn.c | 2 +- matrix.c | 144 ++++++++++++++++------------------------------- 6 files changed, 54 insertions(+), 140 deletions(-) delete mode 100644 keymap_common.c diff --git a/Makefile b/Makefile index eaa179f..68a446c 100644 --- a/Makefile +++ b/Makefile @@ -48,8 +48,7 @@ TMK_DIR = ./tmk_core/tmk_core TARGET_DIR = . # project specific files -SRC = keymap_common.c \ - matrix.c \ +SRC = matrix.c \ led.c ifdef KEYMAP @@ -119,8 +118,8 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450) #CONSOLE_ENABLE = yes # Console for debug(+400) #COMMAND_ENABLE = yes # Commands for debug and configuration #SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend -NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA -#BACKLIGHT_ENABLE = yes +NKRO_ENABLE = yes # USB Nkey Rollover + # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/keymap_common.c b/keymap_common.c deleted file mode 100644 index fdb1769..0000000 --- a/keymap_common.c +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright 2012,2013 Jun Wako - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "keymap_common.h" - - -/* translates key to keycode */ -uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) -{ - return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); -} - -/* translates Fn keycode to action */ -action_t keymap_fn_to_action(uint8_t keycode) -{ - return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; -} diff --git a/keymap_common.h b/keymap_common.h index c9423df..9ac5722 100644 --- a/keymap_common.h +++ b/keymap_common.h @@ -19,7 +19,6 @@ along with this program. If not, see . #include #include -#include #include "keycode.h" #include "action.h" #include "action_macro.h" @@ -30,11 +29,7 @@ along with this program. If not, see . #include "keymap.h" -extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; -extern const uint16_t fn_actions[]; - - -/* KC60 keymap definition macro +/* GH60 keymap definition macro * K2C, K31 and K3C are extra keys for ISO */ #define KEYMAP( \ @@ -51,7 +46,7 @@ extern const uint16_t fn_actions[]; { KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D } \ } -/* ANSI valiant. No extra keys for ISO */ +/* ANSI variant. No extra keys for ISO */ #define KEYMAP_ANSI( \ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ diff --git a/keymap_default.c b/keymap_default.c index da005fd..3403924 100644 --- a/keymap_default.c +++ b/keymap_default.c @@ -62,7 +62,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* * Fn action definition */ -const uint16_t PROGMEM fn_actions[] = { +const action_t PROGMEM fn_actions[] = { [0] = ACTION_LAYER_MOMENTARY(1), /* Monentary layout 1 */ [1] = ACTION_LAYER_TOGGLE(1), /* Toggle layout */ [2] = ACTION_MODS_KEY(MOD_LSFT, KC_DEL), /* Cut */ diff --git a/keymap_spacefn.c b/keymap_spacefn.c index 6e1e898..b15995e 100644 --- a/keymap_spacefn.c +++ b/keymap_spacefn.c @@ -62,7 +62,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* * Fn action definition */ -const uint16_t PROGMEM fn_actions[] = { +const action_t PROGMEM fn_actions[] = { [0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE), /* SpaceFn layout 1 */ [1] = ACTION_LAYER_MOMENTARY(1), /* Momentary layout 1 */ [2] = ACTION_MODS_KEY(MOD_LSFT, KC_DEL), /* Cut */ diff --git a/matrix.c b/matrix.c index aee299a..716caf0 100644 --- a/matrix.c +++ b/matrix.c @@ -25,13 +25,16 @@ along with this program. If not, see . #include "print.h" #include "debug.h" #include "util.h" +#include "timer.h" #include "matrix.h" #ifndef DEBOUNCE -# define DEBOUNCE 5 +# define DEBOUNCE 5 #endif -static uint8_t debouncing = DEBOUNCE; +static bool debouncing = false; +static uint16_t debouncing_time = 0; + /* matrix state(1:on, 0:off) */ static matrix_row_t matrix[MATRIX_ROWS]; @@ -43,24 +46,8 @@ static void unselect_rows(void); static void select_row(uint8_t row); -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} - void matrix_init(void) { - // disable JTAG - MCUCR = (1<= DEBOUNCE) { + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = matrix_debouncing[i]; } + debouncing = false; } return 1; } -bool matrix_is_modified(void) -{ - if (debouncing) return false; - return true; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & ((matrix_row_t)1< Date: Fri, 19 Jun 2020 17:17:26 -0400 Subject: [PATCH 4/4] Re-apply KC60 patch This was derived from @jpec's work in: https://github.com/jpec/kc60/commit/92b6ec101d9ad8f733e3b483d6cea1448896ca9c --- Makefile | 1 + keymap_common.h | 2 +- matrix.c | 74 +++++++++++++++++++++++++------------------------ 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 68a446c..e58a5ce 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,7 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450) #COMMAND_ENABLE = yes # Commands for debug and configuration #SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend NKRO_ENABLE = yes # USB Nkey Rollover +#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality # Optimize size but this may cause error "relocation truncated to fit" diff --git a/keymap_common.h b/keymap_common.h index 9ac5722..5f4352b 100644 --- a/keymap_common.h +++ b/keymap_common.h @@ -29,7 +29,7 @@ along with this program. If not, see . #include "keymap.h" -/* GH60 keymap definition macro +/* KC60 keymap definition macro * K2C, K31 and K3C are extra keys for ISO */ #define KEYMAP( \ diff --git a/matrix.c b/matrix.c index 716caf0..de64f07 100644 --- a/matrix.c +++ b/matrix.c @@ -48,6 +48,10 @@ static void select_row(uint8_t row); void matrix_init(void) { + // disable JTAG + MCUCR = (1<