From 44e4320b2ea508d75f28cb6796f6cf414164564b Mon Sep 17 00:00:00 2001 From: IBNobody Date: Thu, 14 Apr 2016 06:34:56 -0500 Subject: [PATCH 01/27] Nightly --- keyboard/planck/keymaps/pc.c | 71 +++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/keyboard/planck/keymaps/pc.c b/keyboard/planck/keymaps/pc.c index ed062609..20bb5d86 100644 --- a/keyboard/planck/keymaps/pc.c +++ b/keyboard/planck/keymaps/pc.c @@ -2,6 +2,8 @@ // this is the style you want to emulate. #include "planck.h" +#include "print.h" +#include "action_layer.h" #ifdef BACKLIGHT_ENABLE #include "backlight.h" #endif @@ -38,10 +40,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `-----------------------------------------------------------------------------------' */ [_QW] = { - {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, + {RESET, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT }, - {KC_LCTL, KC_LGUI, KC_LALT, KC_DEL, MO(_LW), KC_SPC, KC_SPC, MO(_RS), KC_SLSH, KC_LEFT, KC_DOWN, KC_RGHT} + {KC_LCTL, KC_LGUI, KC_LALT, KC_DEL, M(_LW), KC_SPC, KC_SPC, M(_RS), KC_SLSH, KC_LEFT, KC_DOWN, KC_RGHT} }, /* Colemak @@ -95,7 +97,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, {_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, XXXXXXX, RESET, _______}, - {_______, _______, _______, _______, MO(_FN), _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} + {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} }, /* Lower @@ -113,7 +115,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, {_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, XXXXXXX, MG_B, _______}, - {_______, _______, _______, _______, _______, _______, _______, MO(_FN), KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} + {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} }, /* Function @@ -139,20 +141,53 @@ const uint16_t PROGMEM fn_actions[] = { }; + +int tri_layer = 0; +void update_tri_layer(int layer) { + if (tri_layer > 1) { + layer_on(layer); + } else { + layer_off(layer); + } +} + + const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - // MACRODOWN only works in this function - switch(id) { - case 0: - if (record->event.pressed) { - register_code(KC_RSFT); - #ifdef BACKLIGHT_ENABLE - backlight_step(); - #endif - } else { - unregister_code(KC_RSFT); - } - break; - } - return MACRO_NONE; + // MACRODOWN only works in this function + switch(id) + { + case _RS: + if (record->event.pressed) { + print("RS_DN"); + layer_on(_RS); + tri_layer++; + update_tri_layer(_FN); + } else { + print("RS_UP"); + layer_off(_RS); + tri_layer--; + update_tri_layer(_FN); + phex(layer_state); + } + break; + + case _LW: + if (record->event.pressed) { + print("LW_DN"); + layer_on(_LW); + tri_layer++; + update_tri_layer(_FN); + } else { + print("LW_UP"); + layer_off(_LW); + tri_layer--; + update_tri_layer(_FN); + } + break; + + default: + break; + } + return MACRO_NONE; }; From 59e041672ccd35060aba75c7c05561a39c05d742 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Thu, 14 Apr 2016 08:20:55 -0500 Subject: [PATCH 02/27] Remapped magic bootloader key to B. --- keyboard/atomic/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboard/atomic/config.h b/keyboard/atomic/config.h index f30a9e6c..1b34decf 100644 --- a/keyboard/atomic/config.h +++ b/keyboard/atomic/config.h @@ -130,7 +130,7 @@ along with this program. If not, see . //#define MAGIC_KEY_LAYER7 7 //#define MAGIC_KEY_LAYER8 8 //#define MAGIC_KEY_LAYER9 9 -//#define MAGIC_KEY_BOOTLOADER PAUSE +#define MAGIC_KEY_BOOTLOADER B //#define MAGIC_KEY_LOCK CAPS //#define MAGIC_KEY_EEPROM E //#define MAGIC_KEY_NKRO N From 4b4d3069b4e71de370f0fea8a949f1ae39bb0993 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Thu, 14 Apr 2016 08:50:01 -0500 Subject: [PATCH 03/27] Update and rename pc_atomic.c to pvc_atomic.c Also removed unused FNs --- keyboard/atomic/keymaps/{pc_atomic.c => pvc_atomic.c} | 6 ------ 1 file changed, 6 deletions(-) rename keyboard/atomic/keymaps/{pc_atomic.c => pvc_atomic.c} (96%) diff --git a/keyboard/atomic/keymaps/pc_atomic.c b/keyboard/atomic/keymaps/pvc_atomic.c similarity index 96% rename from keyboard/atomic/keymaps/pc_atomic.c rename to keyboard/atomic/keymaps/pvc_atomic.c index bdf57504..b18e3a37 100644 --- a/keyboard/atomic/keymaps/pc_atomic.c +++ b/keyboard/atomic/keymaps/pvc_atomic.c @@ -55,12 +55,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; const uint16_t PROGMEM fn_actions[] = { - [1] = ACTION_LAYER_MOMENTARY(2), // to RAISE - [2] = ACTION_LAYER_MOMENTARY(3), // to LOWER - - [3] = ACTION_DEFAULT_LAYER_SET(0), - [4] = ACTION_DEFAULT_LAYER_SET(1), - }; const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) From 19061f2ff1283f756b162055bac776814caa2d84 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Thu, 14 Apr 2016 08:54:22 -0500 Subject: [PATCH 04/27] Update and rename pc_atomic.c to pvc_atomic.c --- keyboard/atomic/keymaps/{pc_atomic.c => pvc_atomic.c} | 6 ------ 1 file changed, 6 deletions(-) rename keyboard/atomic/keymaps/{pc_atomic.c => pvc_atomic.c} (96%) diff --git a/keyboard/atomic/keymaps/pc_atomic.c b/keyboard/atomic/keymaps/pvc_atomic.c similarity index 96% rename from keyboard/atomic/keymaps/pc_atomic.c rename to keyboard/atomic/keymaps/pvc_atomic.c index bdf57504..b18e3a37 100644 --- a/keyboard/atomic/keymaps/pc_atomic.c +++ b/keyboard/atomic/keymaps/pvc_atomic.c @@ -55,12 +55,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; const uint16_t PROGMEM fn_actions[] = { - [1] = ACTION_LAYER_MOMENTARY(2), // to RAISE - [2] = ACTION_LAYER_MOMENTARY(3), // to LOWER - - [3] = ACTION_DEFAULT_LAYER_SET(0), - [4] = ACTION_DEFAULT_LAYER_SET(1), - }; const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) From 3d601c1bce23cf31052b9a61818fd1343970499b Mon Sep 17 00:00:00 2001 From: IBNobody Date: Thu, 14 Apr 2016 08:56:27 -0500 Subject: [PATCH 05/27] Rename pc.c to pvc_planck.c --- keyboard/planck/keymaps/{pc.c => pvc_planck.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename keyboard/planck/keymaps/{pc.c => pvc_planck.c} (100%) diff --git a/keyboard/planck/keymaps/pc.c b/keyboard/planck/keymaps/pvc_planck.c similarity index 100% rename from keyboard/planck/keymaps/pc.c rename to keyboard/planck/keymaps/pvc_planck.c From 3dd20f2b6c16ea56bacc5e1581db3fbc1cfc5444 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Thu, 14 Apr 2016 11:35:49 -0500 Subject: [PATCH 06/27] Rename pc.c to pvc_planck.c --- keyboard/planck/keymaps/{pc.c => pvc_planck.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename keyboard/planck/keymaps/{pc.c => pvc_planck.c} (100%) diff --git a/keyboard/planck/keymaps/pc.c b/keyboard/planck/keymaps/pvc_planck.c similarity index 100% rename from keyboard/planck/keymaps/pc.c rename to keyboard/planck/keymaps/pvc_planck.c From cf17687f29820b6bf9b8feb3b23dec6e271572c5 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Thu, 14 Apr 2016 12:59:16 -0500 Subject: [PATCH 07/27] Adding personal build file settings --- keyboard/atomic/Makefile | 4 ++-- keyboard/planck/Makefile | 4 ++-- keyboard/planck/config.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/keyboard/atomic/Makefile b/keyboard/atomic/Makefile index 20cf4fff..f95b2350 100644 --- a/keyboard/atomic/Makefile +++ b/keyboard/atomic/Makefile @@ -119,8 +119,8 @@ MOUSEKEY_ENABLE = yes # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration -#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA +#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality #MIDI_ENABLE = yes # MIDI controls #UNICODE_ENABLE = yes # Unicode #BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index ae637fc2..5271c279 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile @@ -135,8 +135,8 @@ MOUSEKEY_ENABLE = yes # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration -# NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality # MIDI_ENABLE = yes # MIDI controls # AUDIO_ENABLE = yes # Audio output on port C6 # UNICODE_ENABLE = yes # Unicode diff --git a/keyboard/planck/config.h b/keyboard/planck/config.h index d3719e0c..7d64f097 100644 --- a/keyboard/planck/config.h +++ b/keyboard/planck/config.h @@ -73,10 +73,10 @@ along with this program. If not, see . */ /* disable debug print */ -#define NO_DEBUG +//#define NO_DEBUG /* disable print */ -#define NO_PRINT +//#define NO_PRINT /* disable action features */ //#define NO_ACTION_LAYER From f051496f1343259f4da8c5d917b9c9e47b97e38c Mon Sep 17 00:00:00 2001 From: IBNobody Date: Thu, 14 Apr 2016 18:01:29 -0500 Subject: [PATCH 08/27] Checkin --- keyboard/atomic/Makefile | 7 ++ keyboard/atomic/keymaps/pvc_atomic.c | 170 +++++++++++++++++++++++++-- tmk_core/common/action_layer.h | 1 + 3 files changed, 169 insertions(+), 9 deletions(-) diff --git a/keyboard/atomic/Makefile b/keyboard/atomic/Makefile index f95b2350..206b5f11 100644 --- a/keyboard/atomic/Makefile +++ b/keyboard/atomic/Makefile @@ -136,4 +136,11 @@ VPATH += $(TARGET_DIR) VPATH += $(TOP_DIR) VPATH += $(TMK_DIR) +debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION +debug-on: all + +debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT +debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS)) +debug-off: all + include $(TOP_DIR)/quantum/quantum.mk diff --git a/keyboard/atomic/keymaps/pvc_atomic.c b/keyboard/atomic/keymaps/pvc_atomic.c index b18e3a37..3ddd3e32 100644 --- a/keyboard/atomic/keymaps/pvc_atomic.c +++ b/keyboard/atomic/keymaps/pvc_atomic.c @@ -1,9 +1,12 @@ #include "atomic.h" +#include "action_layer.h" #define _QW 0 #define _LW 1 #define _RS 2 #define _FN 3 +#define _F1 4 +#define _F2 5 #define _______ KC_TRNS #define ___T___ KC_TRNS @@ -29,7 +32,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL }, { KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, XXXXXXX, KC_PGUP }, { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, XXXXXXX, KC_UP, KC_PGDN }, - { KC_LCTL, KC_LGUI, MO(_FN), KC_LALT, MO(_RS), KC_SPC, XXXXXXX, MO(_LW), KC_RALT, KC_HOME, KC_END, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT }, + { KC_LCTL, KC_LGUI, M(_FN), KC_LALT, M(_RS), KC_SPC, XXXXXXX, M(_LW), KC_RALT, KC_HOME, KC_END, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT }, }, [_LW] = { /* LOWERED */ { KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, @@ -52,18 +55,167 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, }, + [_F1] = { /* FUNCTION */ + { KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, + { KC_SLCK, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_PAUS, KC_PSCR }, + { KC_CAPS, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, KC_ACL0, KC_ACL2, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, ___T___, ___T___, KC_WH_U }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, + { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, + }, + [_F2] = { /* FUNCTION */ + { KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, + { KC_SLCK, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_PAUS, KC_PSCR }, + { KC_CAPS, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, KC_ACL0, KC_ACL2, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, ___T___, ___T___, KC_WH_U }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, + { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, + }, }; +#define IS_LAYER_ON(layer) ((layer_state) & (1<<(layer))) +#define IS_LAYER_OFF(layer) ((!layer_state) & (1<<(layer))) + +void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) +{ + if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) + { + layer_on(layer3); + } + else + { + layer_off(layer3); + } +} + +void update_quad_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3, uint8_t layer4, bool order) +{ + if (order) + { + if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) + { + layer_on(layer3); + } + else + { + layer_off(layer3); + layer_off(layer4); + } + } + else + { + if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) + { + layer_on(layer4); + } + else + { + layer_off(layer3); + layer_off(layer4); + } + } +} + +/* ignore me +void change_quad_layer(uint8_t focus_layer, bool desired_focus_layer_state, uint8_t pair_layer, uint8_t layer3, uint8_t layer4) +{ + + // If desired focus layer state == 1 and current focus layer state == 1 + if ((desired_focus_layer_state) && IS_LAYER_ON(layer1)) + { + // Do Nothing + } + // If desired focus layer state == 0 and current focus layer state == 1 + else if ((desired_focus_layer_state) && IS_LAYER_ON(layer1)) + { + // If + layer_off(layer3); + layer_off(layer4); + } + } + else + { + if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) + { + layer_on(layer4); + } + else + { + layer_off(layer3); + layer_off(layer4); + } + } +} +*/ + const uint16_t PROGMEM fn_actions[] = { }; -const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - // MACRODOWN only works in this function - switch(id) { - case 0: - return MACRODOWN(TYPE(KC_T), END); - break; - } - return MACRO_NONE; + + // MACRODOWN only works in this function + switch(id) + { + case _FN: + if (record->event.pressed) { + print("FN_DN\n"); + print_val_bin32(layer_state); + layer_on(_FN); + print_val_bin32(layer_state); + } else { + print("FN_UP\n"); + print_val_bin32(layer_state); + layer_off(_FN); + print_val_bin32(layer_state); + } + break; + + case _RS: + if (record->event.pressed) { + print("RS_DN\n"); + print_val_bin32(layer_state); + layer_on(_RS); + //tri_layer++; + print_val_bin32(layer_state); + //update_tri_layer(_RS, _LW, _FN); + update_quad_layer(_RS, _LW, _F1, _F2, 0); + print_val_bin32(layer_state); + } else { + print("RS_UP\n"); + print_val_bin32(layer_state); + layer_off(_RS); + //tri_layer--; + print_val_bin32(layer_state); + //update_tri_layer(_RS, _LW, _FN); + update_quad_layer(_RS, _LW, _F1, _F2, 0); + print_val_bin32(layer_state); + } + break; + + case _LW: + if (record->event.pressed) { + print("LW_DN\n"); + print_val_bin32(layer_state); + layer_on(_LW); + //tri_layer++; + print_val_bin32(layer_state); + //update_tri_layer(_RS, _LW, _FN); + update_quad_layer(_RS, _LW, _F1, _F2, 1); + print_val_bin32(layer_state); + } else { + print("LW_UP\n"); + print_val_bin32(layer_state); + layer_off(_LW); + //tri_layer--; + print_val_bin32(layer_state); + //update_tri_layer(_RS, _LW, _FN); + update_quad_layer(_RS, _LW, _F1, _F2, 1); + print_val_bin32(layer_state); + } + break; + + default: + break; + } + return MACRO_NONE; }; diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h index 3a4b1e33..025cf542 100644 --- a/tmk_core/common/action_layer.h +++ b/tmk_core/common/action_layer.h @@ -68,6 +68,7 @@ void layer_xor(uint32_t state); #define layer_and(state) #define layer_xor(state) #define layer_debug() + #endif /* pressed actions cache */ From ddbe4307789b6087c3e6f146a5e02f1084f3cecc Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Thu, 14 Apr 2016 19:13:24 -0400 Subject: [PATCH 09/27] new defaults --- keyboard/planck/Makefile | 2 +- keyboard/planck/keymaps/default/keymap.c | 146 ++++++++++++++++++++--- 2 files changed, 133 insertions(+), 15 deletions(-) diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index ae637fc2..ee1c60fe 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile @@ -138,7 +138,7 @@ COMMAND_ENABLE = yes # Commands for debug and configuration # NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality # MIDI_ENABLE = yes # MIDI controls -# AUDIO_ENABLE = yes # Audio output on port C6 +AUDIO_ENABLE = yes # Audio output on port C6 # UNICODE_ENABLE = yes # Unicode # BLUETOOTH_ENABLE = ye # Enable Bluetooth with the Adafruit EZ-Key HID # RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. diff --git a/keyboard/planck/keymaps/default/keymap.c b/keyboard/planck/keymaps/default/keymap.c index 30ad8776..e0656733 100644 --- a/keyboard/planck/keymaps/default/keymap.c +++ b/keyboard/planck/keymaps/default/keymap.c @@ -5,6 +5,10 @@ #ifdef BACKLIGHT_ENABLE #include "backlight.h" #endif +#include "action_layer.h" +#ifdef AUDIO_ENABLE + #include "audio.h" +#endif // Each layer gets a name for readability, which is then used in the keymap matrix below. // The underscores don't mean anything - you can have a layer called STUFF or any other name. @@ -15,6 +19,15 @@ #define _DV 2 #define _LW 3 #define _RS 4 +#define _AD 5 + +// Macro name shortcuts +#define M_QW 0 +#define M_CM 1 +#define M_DV 2 +#define M_LW 3 +#define M_RS 4 +#define M_BL 5 // Fillers to make layering more clear #define _______ KC_TRNS @@ -37,7 +50,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, - {M(0), KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC, KC_SPC, MO(_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} + {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, M(M_LW), KC_SPC, KC_SPC, M(M_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} }, /* Colemak @@ -55,7 +68,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, - {M(0), KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC, KC_SPC, MO(_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} + {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, M(M_LW), KC_SPC, KC_SPC, M(M_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} }, /* Dvorak @@ -73,24 +86,24 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, - {M(0), KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC, KC_SPC, MO(_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} + {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, M(M_LW), KC_SPC, KC_SPC, M(M_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} }, /* Raise * ,-----------------------------------------------------------------------------------. * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | * |------+------+------+------+------+-------------+------+------+------+------+------| - * | Esc | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | + * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | * |------+------+------+------+------+------|------+------+------+------+------+------| - * | Shift| F7 | F8 | F9 | F10 | F11 | F12 |Qwerty|Colemk|Dvorak| Reset|Enter | + * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | * |------+------+------+------+------+------+------+------+------+------+------+------| - * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Next | Vol- | Vol+ | Play | + * | | | | | | | | Next | Vol- | Vol+ | Play | * `-----------------------------------------------------------------------------------' */ [_RS] = { {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, - {_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, - {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, DF(_QW), DF(_CM), DF(_DV), RESET, _______}, + {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} }, @@ -98,18 +111,36 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * ,-----------------------------------------------------------------------------------. * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | * |------+------+------+------+------+-------------+------+------+------+------+------| - * | Esc | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | + * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | * |------+------+------+------+------+------|------+------+------+------+------+------| - * | Shift| F7 | F8 | F9 | F10 | F11 | F12 |Qwerty|Colemk|Dvorak| Reset|Enter | + * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | * |------+------+------+------+------+------+------+------+------+------+------+------| - * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Next | Vol- | Vol+ | Play | + * | | | | | | | | Next | Vol- | Vol+ | Play | * `-----------------------------------------------------------------------------------' */ [_LW] = { {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, - {_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, - {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, DF(_QW), DF(_CM), DF(_DV), RESET, _______}, + {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} +}, + +/* Adjust (Lower + Raise) + * ,-----------------------------------------------------------------------------------. + * | | Reset| | | | | | | | | | Del | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | | | | | | |Qwerty|Colemk|Dvorak| | | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | | | | | | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | | | | | + * `-----------------------------------------------------------------------------------' + */ +[_AD] = { + {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, + {_______, _______, _______, _______, _______, _______, _______, M(M_QW), M(M_CM), M(M_DV), _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} } }; @@ -117,11 +148,85 @@ const uint16_t PROGMEM fn_actions[] = { }; +float tone_qw[][2] = { + {440.0*pow(2.0,(67)/12.0), 400}, + {440.0*pow(2.0,(60)/12.0), 400}, + {0, 400}, + {440.0*pow(2.0,(67)/12.0), 1600} +}; + +float tone_cm[][2] = { + {440.0*pow(2.0,(67)/12.0), 400}, + {440.0*pow(2.0,(60)/12.0), 400}, + {0, 400}, + {440.0*pow(2.0,(67)/12.0), 1000}, + {0, 200}, + {440.0*pow(2.0,(67)/12.0), 1000} +}; + +float tone_dv[][2] = { + {440.0*pow(2.0,(67)/12.0), 400}, + {440.0*pow(2.0,(60)/12.0), 400}, + {0, 400}, + {440.0*pow(2.0,(67)/12.0), 800}, + {0, 200}, + {440.0*pow(2.0,(67)/12.0), 800}, + {0, 200}, + {440.0*pow(2.0,(67)/12.0), 800} +}; + + +#define IS_LAYER_ON(layer) ((layer_state) & (1<<(layer))) +#define IS_LAYER_OFF(layer) ((!layer_state) & (1<<(layer))) + +void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { + if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { + layer_on(layer3); + } else { + layer_off(layer3); + } +} const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { // MACRODOWN only works in this function switch(id) { - case 0: + case M_QW: + if (record->event.pressed) { + play_notes(&tone_qw, 4, false); + default_layer_set(1UL<<_QW); + } + break; + case M_CM: + if (record->event.pressed) { + play_notes(&tone_cm, 6, false); + default_layer_set(1UL<<_CM); + } + break; + case M_DV: + if (record->event.pressed) { + play_notes(&tone_dv, 8, false); + default_layer_set(1UL<<_DV); + } + break; + case M_LW: + if (record->event.pressed) { + layer_on(_LW); + update_tri_layer(_LW, _RS, _AD); + } else { + layer_off(_LW); + update_tri_layer(_LW, _RS, _AD); + } + break; + case M_RS: + if (record->event.pressed) { + layer_on(_RS); + update_tri_layer(_LW, _RS, _AD); + } else { + layer_off(_RS); + update_tri_layer(_LW, _RS, _AD); + } + break; + case M_BL: if (record->event.pressed) { register_code(KC_RSFT); #ifdef BACKLIGHT_ENABLE @@ -134,3 +239,16 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) } return MACRO_NONE; }; + +float start_up[][2] = { + {440.0*pow(2.0,(67)/12.0), 650}, + {440.0*pow(2.0,(64)/12.0), 450}, + {440.0*pow(2.0,(55)/12.0), 450}, + {440.0*pow(2.0,(60)/12.0), 450}, + {440.0*pow(2.0,(64)/12.0), 1000} +}; + +void matrix_init_user(void) { + init_notes(); + play_notes(&start_up, 5, false); +} From 63462bf8c12cea1c13ca1bd1f105fe53f556806e Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Thu, 14 Apr 2016 20:42:14 -0400 Subject: [PATCH 10/27] changing up the makefile a bit --- keyboard/planck/Makefile | 56 +++++++++++++-------- keyboard/planck/keymaps/default/keymap.c | 49 +++++++++++------- keyboard/planck/keymaps/default/makefile.mk | 1 + quantum/quantum.mk | 8 +-- tmk_core/common.mk | 26 +++++----- tmk_core/protocol/lufa.mk | 4 +- 6 files changed, 84 insertions(+), 60 deletions(-) create mode 100644 keyboard/planck/keymaps/default/makefile.mk diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index ee1c60fe..dc6e46df 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile @@ -38,6 +38,27 @@ # To rebuild project do "make clean" then "make all". #---------------------------------------------------------------------------- +# Build Options +# change to "no" to disable the options, or define them in the makefile.mk in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = yes # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: + # https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. + +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + # Target file name (without extension). TARGET = planck @@ -62,17 +83,28 @@ ifneq ("$(wildcard keymaps/$(KEYMAP).c)","") else ifneq ("$(wildcard keymaps/$(KEYMAP)/keymap.c)","") KEYMAP_FILE = keymaps/$(KEYMAP)/keymap.c +ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","") + include keymaps/$(KEYMAP)/makefile.mk +endif else $(error Keymap file does not exist) +endif endif -endif + else + ifneq ("$(wildcard keymaps/default.c)","") KEYMAP_FILE = keymaps/default.c else KEYMAP_FILE = keymaps/default/keymap.c endif + +ifneq ("$(wildcard keymaps/default/makefile.mk)","") + include keymaps/default/makefile.mk endif + +endif + SRC := $(KEYMAP_FILE) $(SRC) CONFIG_H = config.h @@ -127,27 +159,7 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT OPT_DEFS += -DBOOTLOADER_SIZE=4096 -# Build Options -# comment out to disable the options. -# -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -# NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -# MIDI_ENABLE = yes # MIDI controls -AUDIO_ENABLE = yes # Audio output on port C6 -# UNICODE_ENABLE = yes # Unicode -# BLUETOOTH_ENABLE = ye # Enable Bluetooth with the Adafruit EZ-Key HID -# RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend - - -ifdef BACKLIGHT_ENABLE +ifeq ($(BACKLIGHT_ENABLE), yes) SRC += backlight.c endif diff --git a/keyboard/planck/keymaps/default/keymap.c b/keyboard/planck/keymaps/default/keymap.c index e0656733..97ba5d28 100644 --- a/keyboard/planck/keymaps/default/keymap.c +++ b/keyboard/planck/keymaps/default/keymap.c @@ -89,38 +89,38 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, M(M_LW), KC_SPC, KC_SPC, M(M_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} }, -/* Raise +/* Lower * ,-----------------------------------------------------------------------------------. - * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | + * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | * |------+------+------+------+------+-------------+------+------+------+------+------| - * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | + * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | * |------+------+------+------+------+------|------+------+------+------+------+------| * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | * |------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | Next | Vol- | Vol+ | Play | * `-----------------------------------------------------------------------------------' */ -[_RS] = { - {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, - {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, +[_LW] = { + {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, + {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} }, -/* Lower +/* Raise * ,-----------------------------------------------------------------------------------. - * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | + * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | * |------+------+------+------+------+-------------+------+------+------+------+------| - * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | + * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | * |------+------+------+------+------+------|------+------+------+------+------+------| * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | * |------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | Next | Vol- | Vol+ | Play | * `-----------------------------------------------------------------------------------' */ -[_LW] = { - {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, - {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, +[_RS] = { + {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, + {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} }, @@ -148,17 +148,18 @@ const uint16_t PROGMEM fn_actions[] = { }; +#ifdef AUDIO_ENABLE float tone_qw[][2] = { {440.0*pow(2.0,(67)/12.0), 400}, {440.0*pow(2.0,(60)/12.0), 400}, - {0, 400}, + {0, 800}, {440.0*pow(2.0,(67)/12.0), 1600} }; float tone_cm[][2] = { {440.0*pow(2.0,(67)/12.0), 400}, {440.0*pow(2.0,(60)/12.0), 400}, - {0, 400}, + {0, 800}, {440.0*pow(2.0,(67)/12.0), 1000}, {0, 200}, {440.0*pow(2.0,(67)/12.0), 1000} @@ -167,14 +168,14 @@ float tone_cm[][2] = { float tone_dv[][2] = { {440.0*pow(2.0,(67)/12.0), 400}, {440.0*pow(2.0,(60)/12.0), 400}, - {0, 400}, + {0, 800}, {440.0*pow(2.0,(67)/12.0), 800}, {0, 200}, {440.0*pow(2.0,(67)/12.0), 800}, {0, 200}, {440.0*pow(2.0,(67)/12.0), 800} }; - +#endif #define IS_LAYER_ON(layer) ((layer_state) & (1<<(layer))) #define IS_LAYER_OFF(layer) ((!layer_state) & (1<<(layer))) @@ -192,19 +193,25 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) switch(id) { case M_QW: if (record->event.pressed) { - play_notes(&tone_qw, 4, false); + #ifdef AUDIO_ENABLE + play_notes(&tone_qw, 4, false); + #endif default_layer_set(1UL<<_QW); } break; case M_CM: if (record->event.pressed) { - play_notes(&tone_cm, 6, false); + #ifdef AUDIO_ENABLE + play_notes(&tone_cm, 6, false); + #endif default_layer_set(1UL<<_CM); } break; case M_DV: if (record->event.pressed) { - play_notes(&tone_dv, 8, false); + #ifdef AUDIO_ENABLE + play_notes(&tone_dv, 8, false); + #endif default_layer_set(1UL<<_DV); } break; @@ -240,6 +247,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) return MACRO_NONE; }; +#ifdef AUDIO_ENABLE float start_up[][2] = { {440.0*pow(2.0,(67)/12.0), 650}, {440.0*pow(2.0,(64)/12.0), 450}, @@ -247,8 +255,11 @@ float start_up[][2] = { {440.0*pow(2.0,(60)/12.0), 450}, {440.0*pow(2.0,(64)/12.0), 1000} }; +#endif void matrix_init_user(void) { + #ifdef AUDIO_ENABLE init_notes(); play_notes(&start_up, 5, false); + #endif } diff --git a/keyboard/planck/keymaps/default/makefile.mk b/keyboard/planck/keymaps/default/makefile.mk new file mode 100644 index 00000000..628167ff --- /dev/null +++ b/keyboard/planck/keymaps/default/makefile.mk @@ -0,0 +1 @@ +AUDIO_ENABLE = yes \ No newline at end of file diff --git a/quantum/quantum.mk b/quantum/quantum.mk index de93af7e..3069f582 100644 --- a/quantum/quantum.mk +++ b/quantum/quantum.mk @@ -23,19 +23,19 @@ ifndef CUSTOM_MATRIX SRC += $(QUANTUM_DIR)/matrix.c endif -ifdef MIDI_ENABLE +ifeq ($(MIDI_ENABLE), yes) SRC += $(QUANTUM_DIR)/keymap_midi.c endif -ifdef AUDIO_ENABLE +ifeq ($(AUDIO_ENABLE), yes) SRC += $(QUANTUM_DIR)/audio.c endif -ifdef UNICODE_ENABLE +ifeq ($(UNICODE_ENABLE), yes) SRC += $(QUANTUM_DIR)/keymap_unicode.c endif -ifdef RGBLIGHT_ENABLE +ifeq ($(RGBLIGHT_ENABLE), yes) SRC += $(QUANTUM_DIR)/light_ws2812.c SRC += $(QUANTUM_DIR)/rgblight.c OPT_DEFS += -DRGBLIGHT_ENABLE diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 89c366f5..8d028d52 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -17,66 +17,66 @@ SRC += $(COMMON_DIR)/host.c \ # Option modules -ifdef BOOTMAGIC_ENABLE +ifeq ($(BOOTMAGIC_ENABLE), yes) SRC += $(COMMON_DIR)/bootmagic.c SRC += $(COMMON_DIR)/avr/eeconfig.c OPT_DEFS += -DBOOTMAGIC_ENABLE endif -ifdef MOUSEKEY_ENABLE +ifeq ($(MOUSEKEY_ENABLE), yes) SRC += $(COMMON_DIR)/mousekey.c OPT_DEFS += -DMOUSEKEY_ENABLE OPT_DEFS += -DMOUSE_ENABLE endif -ifdef EXTRAKEY_ENABLE +ifeq ($(EXTRAKEY_ENABLE), yes) OPT_DEFS += -DEXTRAKEY_ENABLE endif -ifdef CONSOLE_ENABLE +ifeq ($(CONSOLE_ENABLE), yes) OPT_DEFS += -DCONSOLE_ENABLE else OPT_DEFS += -DNO_PRINT OPT_DEFS += -DNO_DEBUG endif -ifdef COMMAND_ENABLE +ifeq ($(COMMAND_ENABLE), yes) SRC += $(COMMON_DIR)/command.c OPT_DEFS += -DCOMMAND_ENABLE endif -ifdef NKRO_ENABLE +ifeq ($(NKRO_ENABLE), yes) OPT_DEFS += -DNKRO_ENABLE endif -ifdef MIDI_ENABLE +ifeq ($(MIDI_ENABLE), yes) OPT_DEFS += -DMIDI_ENABLE endif -ifdef AUDIO_ENABLE +ifeq ($(AUDIO_ENABLE), yes) OPT_DEFS += -DAUDIO_ENABLE endif -ifdef USB_6KRO_ENABLE +ifeq ($(USB_6KRO_ENABLE), yes) OPT_DEFS += -DUSB_6KRO_ENABLE endif -ifdef SLEEP_LED_ENABLE +ifeq ($(SLEEP_LED_ENABLE), yes) SRC += $(COMMON_DIR)/sleep_led.c OPT_DEFS += -DSLEEP_LED_ENABLE OPT_DEFS += -DNO_SUSPEND_POWER_DOWN endif -ifdef BACKLIGHT_ENABLE +ifeq ($(BACKLIGHT_ENABLE), yes) SRC += $(COMMON_DIR)/backlight.c OPT_DEFS += -DBACKLIGHT_ENABLE endif -ifdef BLUETOOTH_ENABLE +ifeq ($(BLUETOOTH_ENABLE), yes) OPT_DEFS += -DBLUETOOTH_ENABLE endif -ifdef KEYMAP_SECTION_ENABLE +ifeq ($(KEYMAP_SECTION_ENABLE), yes) OPT_DEFS += -DKEYMAP_SECTION_ENABLE ifeq ($(strip $(MCU)),atmega32u2) diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk index 4905760b..f3209c22 100644 --- a/tmk_core/protocol/lufa.mk +++ b/tmk_core/protocol/lufa.mk @@ -17,7 +17,7 @@ LUFA_SRC = $(LUFA_DIR)/lufa.c \ $(LUFA_DIR)/descriptor.c \ $(LUFA_SRC_USB) -ifdef MIDI_ENABLE +ifeq ($(MIDI_ENABLE), yes) LUFA_SRC += $(LUFA_DIR)/midi/midi.c \ $(LUFA_DIR)/midi/midi_device.c \ $(LUFA_DIR)/midi/bytequeue/bytequeue.c \ @@ -25,7 +25,7 @@ ifdef MIDI_ENABLE $(LUFA_SRC_USBCLASS) endif -ifdef BLUETOOTH_ENABLE +ifeq ($(BLUETOOTH_ENABLE), yes) LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ $(TMK_DIR)/protocol/serial_uart.c endif From 3993afbb2e022f4e6371c729ac6a025f16bc734e Mon Sep 17 00:00:00 2001 From: IBNobody Date: Thu, 14 Apr 2016 22:27:28 -0500 Subject: [PATCH 11/27] adding new per-keymap makefile --- keyboard/atomic/Makefile | 85 +++++++++++++------ keyboard/atomic/keymaps/pvc/makefile.mk | 16 ++++ .../atomic/keymaps/{ => pvc}/pvc_atomic.c | 0 3 files changed, 73 insertions(+), 28 deletions(-) create mode 100644 keyboard/atomic/keymaps/pvc/makefile.mk rename keyboard/atomic/keymaps/{ => pvc}/pvc_atomic.c (100%) diff --git a/keyboard/atomic/Makefile b/keyboard/atomic/Makefile index 206b5f11..364efa3f 100644 --- a/keyboard/atomic/Makefile +++ b/keyboard/atomic/Makefile @@ -27,7 +27,7 @@ # make flip-ee = Download the eeprom file to the device, using Atmel FLIP # (must have Atmel FLIP installed). # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -38,6 +38,27 @@ # To rebuild project do "make clean" then "make all". #---------------------------------------------------------------------------- +# Build Options +# change to "no" to disable the options, or define them in the makefile.mk in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = yes # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: + # https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. + +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + # Target file name (without extension). TARGET = atomic @@ -50,15 +71,42 @@ TMK_DIR = ../../tmk_core TARGET_DIR = . # # project specific files -SRC = atomic.c \ - backlight.c +SRC = atomic.c + +ifdef keymap + KEYMAP = $(keymap) +endif ifdef KEYMAP - SRC := keymaps/$(KEYMAP).c $(SRC) +ifneq ("$(wildcard keymaps/$(KEYMAP).c)","") + KEYMAP_FILE = keymaps/$(KEYMAP).c +else +ifneq ("$(wildcard keymaps/$(KEYMAP)/keymap.c)","") + KEYMAP_FILE = keymaps/$(KEYMAP)/keymap.c +ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","") + include keymaps/$(KEYMAP)/makefile.mk +endif +else +$(error Keymap file does not exist) +endif +endif + else - SRC := keymaps/default.c $(SRC) + +ifneq ("$(wildcard keymaps/default.c)","") + KEYMAP_FILE = keymaps/default.c +else + KEYMAP_FILE = keymaps/default/keymap.c +endif + +ifneq ("$(wildcard keymaps/default/makefile.mk)","") + include keymaps/default/makefile.mk +endif + endif +SRC := $(KEYMAP_FILE) $(SRC) + CONFIG_H = config.h # MCU name @@ -111,22 +159,10 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT OPT_DEFS += -DBOOTLOADER_SIZE=4096 -# Build Options -# comment out to disable the options. -# -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA -#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -#MIDI_ENABLE = yes # MIDI controls -#UNICODE_ENABLE = yes # Unicode -#BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID +ifeq ($(BACKLIGHT_ENABLE), yes) + SRC += backlight.c +endif -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax @@ -136,11 +172,4 @@ VPATH += $(TARGET_DIR) VPATH += $(TOP_DIR) VPATH += $(TMK_DIR) -debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION -debug-on: all - -debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT -debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS)) -debug-off: all - -include $(TOP_DIR)/quantum/quantum.mk +include $(TOP_DIR)/quantum/quantum.mk \ No newline at end of file diff --git a/keyboard/atomic/keymaps/pvc/makefile.mk b/keyboard/atomic/keymaps/pvc/makefile.mk new file mode 100644 index 00000000..ff0a9c33 --- /dev/null +++ b/keyboard/atomic/keymaps/pvc/makefile.mk @@ -0,0 +1,16 @@ +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: + # https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. + +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend diff --git a/keyboard/atomic/keymaps/pvc_atomic.c b/keyboard/atomic/keymaps/pvc/pvc_atomic.c similarity index 100% rename from keyboard/atomic/keymaps/pvc_atomic.c rename to keyboard/atomic/keymaps/pvc/pvc_atomic.c From 2597fb7c508cf36704291cd48b2c752dd21f2b0d Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Thu, 14 Apr 2016 23:33:46 -0400 Subject: [PATCH 12/27] might have broken something --- keyboard/planck/config.h | 4 ++-- keyboard/planck/keymaps/default/makefile.mk | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/keyboard/planck/config.h b/keyboard/planck/config.h index d3719e0c..7d64f097 100644 --- a/keyboard/planck/config.h +++ b/keyboard/planck/config.h @@ -73,10 +73,10 @@ along with this program. If not, see . */ /* disable debug print */ -#define NO_DEBUG +//#define NO_DEBUG /* disable print */ -#define NO_PRINT +//#define NO_PRINT /* disable action features */ //#define NO_ACTION_LAYER diff --git a/keyboard/planck/keymaps/default/makefile.mk b/keyboard/planck/keymaps/default/makefile.mk index 628167ff..e1c5bd2e 100644 --- a/keyboard/planck/keymaps/default/makefile.mk +++ b/keyboard/planck/keymaps/default/makefile.mk @@ -1 +1,2 @@ -AUDIO_ENABLE = yes \ No newline at end of file +AUDIO_ENABLE = yes +BACKLIGHT_ENABLE = yes \ No newline at end of file From 43a4ffc25971b2aea94b65ca1db66371e653ec5f Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Thu, 14 Apr 2016 23:53:35 -0400 Subject: [PATCH 13/27] bootmagic somehow not getting enabled, so adding eeconfig to backlight src include cond --- keyboard/planck/Makefile | 11 ++++------- keyboard/planck/keymaps/default/keymap.c | 3 --- tmk_core/common.mk | 1 + 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index dc6e46df..693e9c8a 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile @@ -107,6 +107,10 @@ endif SRC := $(KEYMAP_FILE) $(SRC) +ifeq ($(BACKLIGHT_ENABLE), yes) + SRC := backlight.c $(SRC) +endif + CONFIG_H = config.h # MCU name @@ -126,7 +130,6 @@ MCU = atmega32u4 # software delays. F_CPU = 16000000 - # # LUFA specific # @@ -158,12 +161,6 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT # USBaspLoader 2048 OPT_DEFS += -DBOOTLOADER_SIZE=4096 - -ifeq ($(BACKLIGHT_ENABLE), yes) - SRC += backlight.c -endif - - # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/keyboard/planck/keymaps/default/keymap.c b/keyboard/planck/keymaps/default/keymap.c index 97ba5d28..151a6b4f 100644 --- a/keyboard/planck/keymaps/default/keymap.c +++ b/keyboard/planck/keymaps/default/keymap.c @@ -2,9 +2,6 @@ // this is the style you want to emulate. #include "planck.h" -#ifdef BACKLIGHT_ENABLE - #include "backlight.h" -#endif #include "action_layer.h" #ifdef AUDIO_ENABLE #include "audio.h" diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 8d028d52..030767cc 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -69,6 +69,7 @@ endif ifeq ($(BACKLIGHT_ENABLE), yes) SRC += $(COMMON_DIR)/backlight.c + SRC += $(COMMON_DIR)/avr/eeconfig.c OPT_DEFS += -DBACKLIGHT_ENABLE endif From bb0836c62016f482f517771a9f5a8dbc68bd0a1c Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 15 Apr 2016 00:26:22 -0400 Subject: [PATCH 14/27] the spacessss --- keyboard/planck/Makefile | 66 +++++++++++++-------- keyboard/planck/keymaps/default/makefile.mk | 3 +- quantum/quantum.mk | 8 +-- tmk_core/common.mk | 26 ++++---- tmk_core/protocol/lufa.mk | 4 +- 5 files changed, 60 insertions(+), 47 deletions(-) diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index 693e9c8a..8d4e7787 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile @@ -38,31 +38,9 @@ # To rebuild project do "make clean" then "make all". #---------------------------------------------------------------------------- -# Build Options -# change to "no" to disable the options, or define them in the makefile.mk in -# the appropriate keymap folder that will get included automatically -# -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: - # https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - # Target file name (without extension). TARGET = planck - # Directory common source filess exist TOP_DIR = ../.. TMK_DIR = ../../tmk_core @@ -107,10 +85,6 @@ endif SRC := $(KEYMAP_FILE) $(SRC) -ifeq ($(BACKLIGHT_ENABLE), yes) - SRC := backlight.c $(SRC) -endif - CONFIG_H = config.h # MCU name @@ -161,6 +135,46 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT # USBaspLoader 2048 OPT_DEFS += -DBOOTLOADER_SIZE=4096 +# Build Options +# change to "no" to disable the options, or define them in the makefile.mk in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = yes # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. + +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + +ifdef KEYMAP + +ifeq ("$(wildcard keymaps/$(KEYMAP).c)","") +ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","") + include keymaps/$(KEYMAP)/makefile.mk +endif +endif + +else + +ifneq ("$(wildcard keymaps/default/makefile.mk)","") + include keymaps/default/makefile.mk +endif + +endif + +ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) + SRC := backlight.c $(SRC) +endif + # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/keyboard/planck/keymaps/default/makefile.mk b/keyboard/planck/keymaps/default/makefile.mk index e1c5bd2e..8cbec4a1 100644 --- a/keyboard/planck/keymaps/default/makefile.mk +++ b/keyboard/planck/keymaps/default/makefile.mk @@ -1,2 +1 @@ -AUDIO_ENABLE = yes -BACKLIGHT_ENABLE = yes \ No newline at end of file +AUDIO_ENABLE = yes \ No newline at end of file diff --git a/quantum/quantum.mk b/quantum/quantum.mk index 3069f582..17bb5017 100644 --- a/quantum/quantum.mk +++ b/quantum/quantum.mk @@ -23,19 +23,19 @@ ifndef CUSTOM_MATRIX SRC += $(QUANTUM_DIR)/matrix.c endif -ifeq ($(MIDI_ENABLE), yes) +ifeq ($(strip $(MIDI_ENABLE)), yes) SRC += $(QUANTUM_DIR)/keymap_midi.c endif -ifeq ($(AUDIO_ENABLE), yes) +ifeq ($(strip $(AUDIO_ENABLE)), yes) SRC += $(QUANTUM_DIR)/audio.c endif -ifeq ($(UNICODE_ENABLE), yes) +ifeq ($(strip $(UNICODE_ENABLE)), yes) SRC += $(QUANTUM_DIR)/keymap_unicode.c endif -ifeq ($(RGBLIGHT_ENABLE), yes) +ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) SRC += $(QUANTUM_DIR)/light_ws2812.c SRC += $(QUANTUM_DIR)/rgblight.c OPT_DEFS += -DRGBLIGHT_ENABLE diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 030767cc..f8006c67 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -17,67 +17,67 @@ SRC += $(COMMON_DIR)/host.c \ # Option modules -ifeq ($(BOOTMAGIC_ENABLE), yes) +ifeq ($(strip $(BOOTMAGIC_ENABLE)), yes) SRC += $(COMMON_DIR)/bootmagic.c SRC += $(COMMON_DIR)/avr/eeconfig.c OPT_DEFS += -DBOOTMAGIC_ENABLE endif -ifeq ($(MOUSEKEY_ENABLE), yes) +ifeq ($(strip $(MOUSEKEY_ENABLE)), yes) SRC += $(COMMON_DIR)/mousekey.c OPT_DEFS += -DMOUSEKEY_ENABLE OPT_DEFS += -DMOUSE_ENABLE endif -ifeq ($(EXTRAKEY_ENABLE), yes) +ifeq ($(strip $(EXTRAKEY_ENABLE)), yes) OPT_DEFS += -DEXTRAKEY_ENABLE endif -ifeq ($(CONSOLE_ENABLE), yes) +ifeq ($(strip $(CONSOLE_ENABLE)), yes) OPT_DEFS += -DCONSOLE_ENABLE else OPT_DEFS += -DNO_PRINT OPT_DEFS += -DNO_DEBUG endif -ifeq ($(COMMAND_ENABLE), yes) +ifeq ($(strip $(COMMAND_ENABLE)), yes) SRC += $(COMMON_DIR)/command.c OPT_DEFS += -DCOMMAND_ENABLE endif -ifeq ($(NKRO_ENABLE), yes) +ifeq ($(strip $(NKRO_ENABLE)), yes) OPT_DEFS += -DNKRO_ENABLE endif -ifeq ($(MIDI_ENABLE), yes) +ifeq ($(strip $(MIDI_ENABLE)), yes) OPT_DEFS += -DMIDI_ENABLE endif -ifeq ($(AUDIO_ENABLE), yes) +ifeq ($(strip $(AUDIO_ENABLE)), yes) OPT_DEFS += -DAUDIO_ENABLE endif -ifeq ($(USB_6KRO_ENABLE), yes) +ifeq ($(strip $(USB_6KRO_ENABLE)), yes) OPT_DEFS += -DUSB_6KRO_ENABLE endif -ifeq ($(SLEEP_LED_ENABLE), yes) +ifeq ($(strip $(SLEEP_LED_ENABLE)), yes) SRC += $(COMMON_DIR)/sleep_led.c OPT_DEFS += -DSLEEP_LED_ENABLE OPT_DEFS += -DNO_SUSPEND_POWER_DOWN endif -ifeq ($(BACKLIGHT_ENABLE), yes) +ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) SRC += $(COMMON_DIR)/backlight.c SRC += $(COMMON_DIR)/avr/eeconfig.c OPT_DEFS += -DBACKLIGHT_ENABLE endif -ifeq ($(BLUETOOTH_ENABLE), yes) +ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) OPT_DEFS += -DBLUETOOTH_ENABLE endif -ifeq ($(KEYMAP_SECTION_ENABLE), yes) +ifeq ($(strip $(KEYMAP_SECTION_ENABLE)), yes) OPT_DEFS += -DKEYMAP_SECTION_ENABLE ifeq ($(strip $(MCU)),atmega32u2) diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk index f3209c22..9ac6298f 100644 --- a/tmk_core/protocol/lufa.mk +++ b/tmk_core/protocol/lufa.mk @@ -17,7 +17,7 @@ LUFA_SRC = $(LUFA_DIR)/lufa.c \ $(LUFA_DIR)/descriptor.c \ $(LUFA_SRC_USB) -ifeq ($(MIDI_ENABLE), yes) +ifeq ($(strip $(MIDI_ENABLE)), yes) LUFA_SRC += $(LUFA_DIR)/midi/midi.c \ $(LUFA_DIR)/midi/midi_device.c \ $(LUFA_DIR)/midi/bytequeue/bytequeue.c \ @@ -25,7 +25,7 @@ ifeq ($(MIDI_ENABLE), yes) $(LUFA_SRC_USBCLASS) endif -ifeq ($(BLUETOOTH_ENABLE), yes) +ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ $(TMK_DIR)/protocol/serial_uart.c endif From ee2ee7f4f049dda385a9db7dddd8e7e91681315b Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 15 Apr 2016 13:44:07 -0400 Subject: [PATCH 15/27] audio note length fixes --- keyboard/planck/keymaps/default/keymap.c | 46 ++++++++++++------------ quantum/audio.c | 7 +++- quantum/keymap_common.c | 10 +++--- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/keyboard/planck/keymaps/default/keymap.c b/keyboard/planck/keymaps/default/keymap.c index 151a6b4f..dee2840f 100644 --- a/keyboard/planck/keymaps/default/keymap.c +++ b/keyboard/planck/keymaps/default/keymap.c @@ -147,30 +147,30 @@ const uint16_t PROGMEM fn_actions[] = { #ifdef AUDIO_ENABLE float tone_qw[][2] = { - {440.0*pow(2.0,(67)/12.0), 400}, - {440.0*pow(2.0,(60)/12.0), 400}, - {0, 800}, - {440.0*pow(2.0,(67)/12.0), 1600} + {440.0*pow(2.0,(59)/12.0), 8}, + {440.0*pow(2.0,(60)/12.0), 8}, + {0, 4}, + {440.0*pow(2.0,(67)/12.0), 16} }; float tone_cm[][2] = { - {440.0*pow(2.0,(67)/12.0), 400}, - {440.0*pow(2.0,(60)/12.0), 400}, - {0, 800}, - {440.0*pow(2.0,(67)/12.0), 1000}, - {0, 200}, - {440.0*pow(2.0,(67)/12.0), 1000} + {440.0*pow(2.0,(59)/12.0), 8}, + {440.0*pow(2.0,(60)/12.0), 8}, + {0, 4}, + {440.0*pow(2.0,(67)/12.0), 16}, + {0, 4}, + {440.0*pow(2.0,(71)/12.0), 16} }; float tone_dv[][2] = { - {440.0*pow(2.0,(67)/12.0), 400}, - {440.0*pow(2.0,(60)/12.0), 400}, - {0, 800}, - {440.0*pow(2.0,(67)/12.0), 800}, - {0, 200}, - {440.0*pow(2.0,(67)/12.0), 800}, - {0, 200}, - {440.0*pow(2.0,(67)/12.0), 800} + {440.0*pow(2.0,(59)/12.0), 8}, + {440.0*pow(2.0,(60)/12.0), 8}, + {0, 4}, + {440.0*pow(2.0,(67)/12.0), 16}, + {0, 4}, + {440.0*pow(2.0,(69)/12.0), 16}, + {0, 4}, + {440.0*pow(2.0,(67)/12.0), 16} }; #endif @@ -246,11 +246,11 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) #ifdef AUDIO_ENABLE float start_up[][2] = { - {440.0*pow(2.0,(67)/12.0), 650}, - {440.0*pow(2.0,(64)/12.0), 450}, - {440.0*pow(2.0,(55)/12.0), 450}, - {440.0*pow(2.0,(60)/12.0), 450}, - {440.0*pow(2.0,(64)/12.0), 1000} + {440.0*pow(2.0,(67)/12.0), 12}, + {440.0*pow(2.0,(64)/12.0), 8}, + {440.0*pow(2.0,(55)/12.0), 8}, + {440.0*pow(2.0,(60)/12.0), 8}, + {440.0*pow(2.0,(64)/12.0), 20} }; #endif diff --git a/quantum/audio.c b/quantum/audio.c index f29d941d..50e5505f 100644 --- a/quantum/audio.c +++ b/quantum/audio.c @@ -255,7 +255,12 @@ ISR(TIMER3_COMPA_vect) { note_position++; - if (note_position >= note_length) { + bool end_of_note = false; + if (ICR3 > 0) + end_of_note = (note_position >= (note_length / ICR3 * 0xFFFF)); + else + end_of_note = (note_position >= (note_length * 0x7FF)); + if (end_of_note) { current_note++; if (current_note >= notes_length) { if (notes_repeat) { diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index ae6cddb3..e3030a88 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -33,11 +33,9 @@ along with this program. If not, see . #include "audio.h" float goodbye[][2] = { - {440.0*pow(2.0,(67)/12.0), 400}, - {0, 50}, - {440.0*pow(2.0,(60)/12.0), 400}, - {0, 50}, - {440.0*pow(2.0,(55)/12.0), 600}, + {440.0*pow(2.0,(67)/12.0), 8}, + {440.0*pow(2.0,(60)/12.0), 8}, + {440.0*pow(2.0,(55)/12.0), 12}, }; #endif @@ -90,7 +88,7 @@ action_t action_for_key(uint8_t layer, keypos_t key) action_t action; clear_keyboard(); #ifdef AUDIO_ENABLE - play_notes(&goodbye, 5, false); + play_notes(&goodbye, 3, false); #endif _delay_ms(250); #ifdef ATREUS_ASTAR From 8f85117aa9e060371177e3b523bc89dc7aad19e8 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Fri, 15 Apr 2016 14:42:50 -0500 Subject: [PATCH 16/27] Added Audio to my Atomic --- keyboard/atomic/Makefile | 67 +++--- keyboard/atomic/keymaps/pvc/config.h | 157 +++++++++++++ .../keymaps/pvc/{pvc_atomic.c => keymap.c} | 207 ++++++++---------- keyboard/atomic/keymaps/pvc/makefile.mk | 6 +- keyboard/planck/Makefile | 31 +-- quantum/audio.h | 4 +- 6 files changed, 297 insertions(+), 175 deletions(-) create mode 100644 keyboard/atomic/keymaps/pvc/config.h rename keyboard/atomic/keymaps/pvc/{pvc_atomic.c => keymap.c} (59%) diff --git a/keyboard/atomic/Makefile b/keyboard/atomic/Makefile index 364efa3f..1203cf6a 100644 --- a/keyboard/atomic/Makefile +++ b/keyboard/atomic/Makefile @@ -38,31 +38,9 @@ # To rebuild project do "make clean" then "make all". #---------------------------------------------------------------------------- -# Build Options -# change to "no" to disable the options, or define them in the makefile.mk in -# the appropriate keymap folder that will get included automatically -# -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: - # https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - # Target file name (without extension). TARGET = atomic - # Directory common source filess exist TOP_DIR = ../.. TMK_DIR = ../../tmk_core @@ -73,6 +51,8 @@ TARGET_DIR = . # # project specific files SRC = atomic.c +CONFIG_H = config.h + ifdef keymap KEYMAP = $(keymap) endif @@ -88,7 +68,7 @@ ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","") endif else $(error Keymap file does not exist) -endif +endif endif else @@ -107,8 +87,6 @@ endif SRC := $(KEYMAP_FILE) $(SRC) -CONFIG_H = config.h - # MCU name #MCU = at90usb1287 MCU = atmega32u4 @@ -126,7 +104,6 @@ MCU = atmega32u4 # software delays. F_CPU = 16000000 - # # LUFA specific # @@ -158,11 +135,45 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT # USBaspLoader 2048 OPT_DEFS += -DBOOTLOADER_SIZE=4096 +# Build Options +# change to "no" to disable the options, or define them in the makefile.mk in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = yes # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. + +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + +ifdef KEYMAP + +ifeq ("$(wildcard keymaps/$(KEYMAP).c)","") +ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","") + include keymaps/$(KEYMAP)/makefile.mk +endif +endif + +else + +ifneq ("$(wildcard keymaps/default/makefile.mk)","") + include keymaps/default/makefile.mk +endif -ifeq ($(BACKLIGHT_ENABLE), yes) - SRC += backlight.c endif +ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) + SRC := backlight.c $(SRC) +endif # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/keyboard/atomic/keymaps/pvc/config.h b/keyboard/atomic/keymaps/pvc/config.h new file mode 100644 index 00000000..8449fa06 --- /dev/null +++ b/keyboard/atomic/keymaps/pvc/config.h @@ -0,0 +1,157 @@ +/* +Copyright 2012 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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define DEVICE_VER 0x0001 +#define MANUFACTURER Ortholinear Keyboards +#define PRODUCT The Atomic Keyboard +#define DESCRIPTION A compact ortholinear keyboard + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 15 + +/* + * Keyboard Matrix Assignments + * + * Change this to how you wired your keyboard + * COLS: AVR pins used for columns, left to right + * ROWS: AVR pins used for rows, top to bottom + * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) + * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) + * +*/ +#define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7, D3, D2, D1 } +#define ROWS (int []){ D0, D5, B5, B6, B3 } + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* define if matrix has ghost (lacks anti-ghosting diodes) */ +//#define MATRIX_HAS_GHOST + +/* number of backlight levels */ +#define BACKLIGHT_LEVELS 3 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* + * Force NKRO + * + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the + * makefile for this to work.) + * + * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) + * until the next keyboard reset. + * + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * fully operational during normal computer usage. + * + * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) + * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by + * bootmagic, NKRO mode will always be enabled until it is toggled again during a + * power-up. + * + */ +//#define FORCE_NKRO + +/* + * Magic Key Options + * + * Magic keys are hotkey commands that allow control over firmware functions of + * the keyboard. They are best used in combination with the HID Listen program, + * found here: https://www.pjrc.com/teensy/hid_listen.html + * + * The options below allow the magic key functionality to be changed. This is + * useful if your keyboard/keypad is missing keys and you want magic key support. + * + */ + +/* key combination for magic key command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +/* control how magic key switches layers */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false + +/* override magic key keymap */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM +//#define MAGIC_KEY_HELP1 H +//#define MAGIC_KEY_HELP2 SLASH +//#define MAGIC_KEY_DEBUG D +//#define MAGIC_KEY_DEBUG_MATRIX X +//#define MAGIC_KEY_DEBUG_KBD K +//#define MAGIC_KEY_DEBUG_MOUSE M +//#define MAGIC_KEY_VERSION V +//#define MAGIC_KEY_STATUS S +//#define MAGIC_KEY_CONSOLE C +//#define MAGIC_KEY_LAYER0_ALT1 ESC +//#define MAGIC_KEY_LAYER0_ALT2 GRAVE +//#define MAGIC_KEY_LAYER0 0 +//#define MAGIC_KEY_LAYER1 1 +//#define MAGIC_KEY_LAYER2 2 +//#define MAGIC_KEY_LAYER3 3 +//#define MAGIC_KEY_LAYER4 4 +//#define MAGIC_KEY_LAYER5 5 +//#define MAGIC_KEY_LAYER6 6 +//#define MAGIC_KEY_LAYER7 7 +//#define MAGIC_KEY_LAYER8 8 +//#define MAGIC_KEY_LAYER9 9 +#define MAGIC_KEY_BOOTLOADER B +//#define MAGIC_KEY_LOCK CAPS +//#define MAGIC_KEY_EEPROM E +//#define MAGIC_KEY_NKRO N +//#define MAGIC_KEY_SLEEP_LED Z + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboard/atomic/keymaps/pvc/pvc_atomic.c b/keyboard/atomic/keymaps/pvc/keymap.c similarity index 59% rename from keyboard/atomic/keymaps/pvc/pvc_atomic.c rename to keyboard/atomic/keymaps/pvc/keymap.c index 3ddd3e32..627f57ff 100644 --- a/keyboard/atomic/keymaps/pvc/pvc_atomic.c +++ b/keyboard/atomic/keymaps/pvc/keymap.c @@ -1,12 +1,19 @@ #include "atomic.h" #include "action_layer.h" +#ifdef AUDIO_ENABLE + #include "audio.h" +#endif #define _QW 0 #define _LW 1 #define _RS 2 #define _FN 3 -#define _F1 4 -#define _F2 5 + +#define M_QW 0 +#define M_LW 1 +#define M_RS 2 +#define M_FN 3 + #define _______ KC_TRNS #define ___T___ KC_TRNS @@ -32,7 +39,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL }, { KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, XXXXXXX, KC_PGUP }, { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, XXXXXXX, KC_UP, KC_PGDN }, - { KC_LCTL, KC_LGUI, M(_FN), KC_LALT, M(_RS), KC_SPC, XXXXXXX, M(_LW), KC_RALT, KC_HOME, KC_END, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT }, + { KC_LCTL, KC_LGUI, M(M_FN), KC_LALT, M(M_RS), KC_SPC, XXXXXXX, M(M_LW), KC_RALT, KC_HOME, KC_END, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT }, }, [_LW] = { /* LOWERED */ { KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, @@ -55,29 +62,50 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, }, - [_F1] = { /* FUNCTION */ - { KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, - { KC_SLCK, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_PAUS, KC_PSCR }, - { KC_CAPS, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, KC_ACL0, KC_ACL2, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, ___T___, ___T___, KC_WH_U }, - { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, - { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, - }, - [_F2] = { /* FUNCTION */ - { KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, - { KC_SLCK, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_PAUS, KC_PSCR }, - { KC_CAPS, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, KC_ACL0, KC_ACL2, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, ___T___, ___T___, KC_WH_U }, - { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, - { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, - }, }; #define IS_LAYER_ON(layer) ((layer_state) & (1<<(layer))) #define IS_LAYER_OFF(layer) ((!layer_state) & (1<<(layer))) + +#ifdef AUDIO_ENABLE +float tone_lw[][2] = { + {440.0*pow(2.0,(59)/12.0), 8}, + {440.0*pow(2.0,(60)/12.0), 8}, + {0, 4}, + {440.0*pow(2.0,(67)/12.0), 16} +}; + +float tone_rs[][2] = { + {440.0*pow(2.0,(59)/12.0), 8}, + {440.0*pow(2.0,(60)/12.0), 8}, + {0, 4}, + {440.0*pow(2.0,(67)/12.0), 16}, + {0, 4}, + {440.0*pow(2.0,(71)/12.0), 16} +}; + +float tone_fn[][2] = { + {440.0*pow(2.0,(59)/12.0), 8}, + {440.0*pow(2.0,(60)/12.0), 8}, + {0, 4}, + {440.0*pow(2.0,(67)/12.0), 16}, + {0, 4}, + {440.0*pow(2.0,(69)/12.0), 16}, + {0, 4}, + {440.0*pow(2.0,(67)/12.0), 16} +}; +#endif + + void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { + #ifdef AUDIO_ENABLE + println("PlayNotes FN"); + play_notes(&tone_fn, 8, false); + #endif layer_on(layer3); } else @@ -114,37 +142,6 @@ void update_quad_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3, uint8_t l } } -/* ignore me -void change_quad_layer(uint8_t focus_layer, bool desired_focus_layer_state, uint8_t pair_layer, uint8_t layer3, uint8_t layer4) -{ - - // If desired focus layer state == 1 and current focus layer state == 1 - if ((desired_focus_layer_state) && IS_LAYER_ON(layer1)) - { - // Do Nothing - } - // If desired focus layer state == 0 and current focus layer state == 1 - else if ((desired_focus_layer_state) && IS_LAYER_ON(layer1)) - { - // If - layer_off(layer3); - layer_off(layer4); - } - } - else - { - if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) - { - layer_on(layer4); - } - else - { - layer_off(layer3); - layer_off(layer4); - } - } -} -*/ const uint16_t PROGMEM fn_actions[] = { }; @@ -152,70 +149,54 @@ const uint16_t PROGMEM fn_actions[] = { const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - - // MACRODOWN only works in this function - switch(id) - { - case _FN: - if (record->event.pressed) { - print("FN_DN\n"); - print_val_bin32(layer_state); - layer_on(_FN); - print_val_bin32(layer_state); - } else { - print("FN_UP\n"); - print_val_bin32(layer_state); - layer_off(_FN); - print_val_bin32(layer_state); - } - break; - - case _RS: - if (record->event.pressed) { - print("RS_DN\n"); - print_val_bin32(layer_state); - layer_on(_RS); - //tri_layer++; - print_val_bin32(layer_state); - //update_tri_layer(_RS, _LW, _FN); - update_quad_layer(_RS, _LW, _F1, _F2, 0); - print_val_bin32(layer_state); - } else { - print("RS_UP\n"); - print_val_bin32(layer_state); - layer_off(_RS); - //tri_layer--; - print_val_bin32(layer_state); - //update_tri_layer(_RS, _LW, _FN); - update_quad_layer(_RS, _LW, _F1, _F2, 0); - print_val_bin32(layer_state); - } - break; - - case _LW: - if (record->event.pressed) { - print("LW_DN\n"); - print_val_bin32(layer_state); - layer_on(_LW); - //tri_layer++; - print_val_bin32(layer_state); - //update_tri_layer(_RS, _LW, _FN); - update_quad_layer(_RS, _LW, _F1, _F2, 1); - print_val_bin32(layer_state); - } else { - print("LW_UP\n"); - print_val_bin32(layer_state); - layer_off(_LW); - //tri_layer--; - print_val_bin32(layer_state); - //update_tri_layer(_RS, _LW, _FN); - update_quad_layer(_RS, _LW, _F1, _F2, 1); - print_val_bin32(layer_state); - } - break; - + // MACRODOWN only works in this function + switch(id) { + case M_LW: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + println("PlayNotes LW"); + play_notes(&tone_lw, 4, false); + #endif + layer_on(_LW); + update_tri_layer(_LW, _RS, _FN); + } else { + layer_off(_LW); + update_tri_layer(_LW, _RS, _FN); + } + break; + case M_RS: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + println("PlayNotes RS"); + play_notes(&tone_rs, 6, false); + #endif + layer_on(_RS); + update_tri_layer(_LW, _RS, _FN); + } else { + layer_off(_RS); + update_tri_layer(_LW, _RS, _FN); + } + break; default: - break; - } - return MACRO_NONE; + break; + } + return MACRO_NONE; +}; + +#ifdef AUDIO_ENABLE +float start_up[][2] = { + {440.0*pow(2.0,(67)/12.0), 12}, + {440.0*pow(2.0,(64)/12.0), 8}, + {440.0*pow(2.0,(55)/12.0), 8}, + {440.0*pow(2.0,(60)/12.0), 8}, + {440.0*pow(2.0,(64)/12.0), 20} }; +#endif + +void matrix_init_user(void) { + #ifdef AUDIO_ENABLE + init_notes(); + play_notes(&start_up, 5, false); + println("Matrix Init"); + #endif +} diff --git a/keyboard/atomic/keymaps/pvc/makefile.mk b/keyboard/atomic/keymaps/pvc/makefile.mk index ff0a9c33..c41102f5 100644 --- a/keyboard/atomic/keymaps/pvc/makefile.mk +++ b/keyboard/atomic/keymaps/pvc/makefile.mk @@ -1,16 +1,18 @@ BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = yes # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) +CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: # https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 +AUDIO_ENABLE = yes # Audio output on port C6 UNICODE_ENABLE = no # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + +CONFIG_H = keymaps/$(KEYMAP)/config.h \ No newline at end of file diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index c8517e75..83b8303b 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile @@ -157,39 +157,10 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend ifdef KEYMAP -<<<<<<< HEAD -<<<<<<< HEAD -# Build Options -# comment out to disable the options. -# -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -# MIDI_ENABLE = yes # MIDI controls -# AUDIO_ENABLE = yes # Audio output on port C6 -# UNICODE_ENABLE = yes # Unicode -# BLUETOOTH_ENABLE = ye # Enable Bluetooth with the Adafruit EZ-Key HID -# RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend - - -ifdef BACKLIGHT_ENABLE -======= -ifeq ($(BACKLIGHT_ENABLE), yes) ->>>>>>> master - SRC += backlight.c -======= ifeq ("$(wildcard keymaps/$(KEYMAP).c)","") ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","") include keymaps/$(KEYMAP)/makefile.mk endif ->>>>>>> remotes/jackhumbert/new_defaults endif else @@ -212,4 +183,4 @@ VPATH += $(TARGET_DIR) VPATH += $(TOP_DIR) VPATH += $(TMK_DIR) -include $(TOP_DIR)/quantum/quantum.mk +include $(TOP_DIR)/quantum/quantum.mk \ No newline at end of file diff --git a/quantum/audio.h b/quantum/audio.h index 99203cea..31f9a357 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -6,6 +6,6 @@ void play_sample(uint8_t * s, uint16_t l, bool r); void play_note(double freq, int vol); void stop_note(double freq); -void stop_all_notes(); -void init_notes(); +void stop_all_notes(void); +void init_notes(void); void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat); \ No newline at end of file From 2aa51e4416b65317b16660c0676696974b2dcfc5 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Fri, 15 Apr 2016 16:32:44 -0500 Subject: [PATCH 17/27] Tweaking PVC atomic layout --- keyboard/atomic/Makefile | 30 ++++++++++++------------- keyboard/atomic/keymaps/pvc/keymap.c | 13 +++++++++-- keyboard/atomic/keymaps/pvc/makefile.mk | 27 +++++++++++----------- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/keyboard/atomic/Makefile b/keyboard/atomic/Makefile index 1203cf6a..3f066aeb 100644 --- a/keyboard/atomic/Makefile +++ b/keyboard/atomic/Makefile @@ -51,8 +51,6 @@ TARGET_DIR = . # # project specific files SRC = atomic.c -CONFIG_H = config.h - ifdef keymap KEYMAP = $(keymap) endif @@ -87,6 +85,8 @@ endif SRC := $(KEYMAP_FILE) $(SRC) +CONFIG_H = config.h + # MCU name #MCU = at90usb1287 MCU = atmega32u4 @@ -139,21 +139,21 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # change to "no" to disable the options, or define them in the makefile.mk in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = yes # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend ifdef KEYMAP diff --git a/keyboard/atomic/keymaps/pvc/keymap.c b/keyboard/atomic/keymaps/pvc/keymap.c index 627f57ff..7bfd910a 100644 --- a/keyboard/atomic/keymaps/pvc/keymap.c +++ b/keyboard/atomic/keymaps/pvc/keymap.c @@ -1,13 +1,15 @@ #include "atomic.h" #include "action_layer.h" + #ifdef AUDIO_ENABLE - #include "audio.h" +#include "audio.h" #endif #define _QW 0 #define _LW 1 #define _RS 2 -#define _FN 3 +#define _AD 3 +#define _FN 4 #define M_QW 0 #define M_LW 1 @@ -62,6 +64,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, }, + [_ADJ] = { /* ADJUST */ + { KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, + { KC_SLCK, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_PAUS, KC_PSCR }, + { KC_CAPS, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, KC_ACL0, KC_ACL2, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, ___T___, ___T___, KC_WH_U }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, + { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, + }, }; #define IS_LAYER_ON(layer) ((layer_state) & (1<<(layer))) diff --git a/keyboard/atomic/keymaps/pvc/makefile.mk b/keyboard/atomic/keymaps/pvc/makefile.mk index c41102f5..d4699665 100644 --- a/keyboard/atomic/keymaps/pvc/makefile.mk +++ b/keyboard/atomic/keymaps/pvc/makefile.mk @@ -1,18 +1,17 @@ -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: - # https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = yes # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = yes # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = yes # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend CONFIG_H = keymaps/$(KEYMAP)/config.h \ No newline at end of file From 9d4bfc1bcf9a93b25ce4f7c32d8f3db12c85c23b Mon Sep 17 00:00:00 2001 From: IBNobody Date: Fri, 15 Apr 2016 22:40:07 -0500 Subject: [PATCH 18/27] Corrected layer macros --- keyboard/atomic/keymaps/pvc/keymap.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/keyboard/atomic/keymaps/pvc/keymap.c b/keyboard/atomic/keymaps/pvc/keymap.c index 7bfd910a..7abd7f4f 100644 --- a/keyboard/atomic/keymaps/pvc/keymap.c +++ b/keyboard/atomic/keymaps/pvc/keymap.c @@ -64,20 +64,23 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, }, - [_ADJ] = { /* ADJUST */ - { KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, - { KC_SLCK, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_PAUS, KC_PSCR }, - { KC_CAPS, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, KC_ACL0, KC_ACL2, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, ___T___, ___T___, KC_WH_U }, - { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, - { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, + [_AD] = { /* ADJUST */ + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___ }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ }, }, }; -#define IS_LAYER_ON(layer) ((layer_state) & (1<<(layer))) -#define IS_LAYER_OFF(layer) ((!layer_state) & (1<<(layer))) - +#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer))) +#define IS_LAYER_OFF(layer) (!IS_LAYER_ON(layer)) #ifdef AUDIO_ENABLE + + + + float tone_lw[][2] = { {440.0*pow(2.0,(59)/12.0), 8}, {440.0*pow(2.0,(60)/12.0), 8}, From ab19ebd08a8b955775e6fa94cdf6b8d128d8b43c Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 16 Apr 2016 18:51:58 -0400 Subject: [PATCH 19/27] MAGIC functionality, AG swap in default layout --- keyboard/planck/keymaps/default/README.md | 32 --- keyboard/preonic/Makefile | 2 +- keyboard/preonic/keymaps/default/keymap.c | 19 +- quantum/keymap_common.c | 250 ++++++++++++---------- quantum/keymap_common.h | 28 ++- tmk_core/common.mk | 3 + tmk_core/common/keyboard.c | 8 +- tmk_core/common/keymap.h | 3 - tmk_core/common/magic.c | 36 ++++ tmk_core/common/magic.h | 6 + 10 files changed, 226 insertions(+), 161 deletions(-) create mode 100644 tmk_core/common/magic.c create mode 100644 tmk_core/common/magic.h diff --git a/keyboard/planck/keymaps/default/README.md b/keyboard/planck/keymaps/default/README.md index d2f43bbd..de9680b4 100644 --- a/keyboard/planck/keymaps/default/README.md +++ b/keyboard/planck/keymaps/default/README.md @@ -1,34 +1,2 @@ # The Default Planck Layout - const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_QW] = { /* Qwerty */ - {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, - {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, - {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, - {M(0), KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC, KC_SPC, MO(_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} - }, - [_CM] = { /* Colemak */ - {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, - {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, - {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, - {M(0), KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC, KC_SPC, MO(_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} - }, - [_DV] = { /* Dvorak */ - {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, - {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, - {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, - {M(0), KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC, KC_SPC, MO(_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} - }, - [_RS] = { /* RAISE */ - {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, - {KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, - {KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, DF(_QW), DF(_CM), DF(_DV), RESET, KC_TRNS}, - {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} - }, - [_LW] = { /* LOWER */ - {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, - {KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, - {KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, DF(_QW), DF(_CM), DF(_DV), RESET, KC_TRNS}, - {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} - } - }; \ No newline at end of file diff --git a/keyboard/preonic/Makefile b/keyboard/preonic/Makefile index eaf9ef92..9199968c 100644 --- a/keyboard/preonic/Makefile +++ b/keyboard/preonic/Makefile @@ -130,7 +130,7 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # change to "no" to disable the options, or define them in the makefile.mk in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = yes # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = yes # Console for debug(+400) diff --git a/keyboard/preonic/keymaps/default/keymap.c b/keyboard/preonic/keymaps/default/keymap.c index 6824f68b..e1f9b620 100644 --- a/keyboard/preonic/keymaps/default/keymap.c +++ b/keyboard/preonic/keymaps/default/keymap.c @@ -153,9 +153,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |------+------+------+------+------+------+------+------+------+------+------+------| * | | Reset| | | | | | | | | | Del | * |------+------+------+------+------+-------------+------+------+------+------+------| - * | | | |Audoff|Aud on| | |Qwerty|Colemk|Dvorak| | | + * | | | |Audoff|Aud on|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | | * |------+------+------+------+------+------|------+------+------+------+------+------| - * | | | | | | | | | | | | | + * | | | |Musoff|Mus on| | | | | | | | * |------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | | | | | * `-----------------------------------------------------------------------------------' @@ -163,7 +163,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_ADJUST] = { {KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12}, {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, - {_______, _______, _______, AUD_ON, AUD_OFF, _______, _______, QWERTY, COLEMAK, DVORAK, _______, _______}, + {_______, _______, _______, AUD_ON, AUD_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______}, {_______, _______, _______, MUS_ON, MUS_OFF, _______, _______, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} }, @@ -231,6 +231,10 @@ float tone_music[][2] = { }; #endif +void persistant_default_layer_set(uint16_t default_layer) { + eeconfig_write_default_layer(default_layer); + default_layer_set(default_layer); +} const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { @@ -240,8 +244,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) #ifdef AUDIO_ENABLE play_notes(&tone_qwerty, 4, false); #endif - eeconfig_write_default_layer(1UL<<_QWERTY); - default_layer_set(1UL<<_QWERTY); + persistant_default_layer_set(1UL<<_QWERTY); } break; case _COLEMAK: @@ -249,8 +252,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) #ifdef AUDIO_ENABLE play_notes(&tone_colemak, 6, false); #endif - eeconfig_write_default_layer(1UL<<_COLEMAK); - default_layer_set(1UL<<_COLEMAK); + persistant_default_layer_set(1UL<<_COLEMAK); } break; case _DVORAK: @@ -258,8 +260,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) #ifdef AUDIO_ENABLE play_notes(&tone_dvorak, 8, false); #endif - eeconfig_write_default_layer(1UL<<_DVORAK); - default_layer_set(1UL<<_DVORAK); + persistant_default_layer_set(1UL<<_DVORAK); } break; case _LOWER: diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 3a00d36f..b9191668 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -27,6 +27,8 @@ along with this program. If not, see . #include "keymap_midi.h" #include "bootloader.h" +extern keymap_config_t keymap_config; + #include #include #ifdef AUDIO_ENABLE @@ -47,120 +49,9 @@ action_t action_for_key(uint8_t layer, keypos_t key) // 16bit keycodes - important uint16_t keycode = keymap_key_to_keycode(layer, key); - if (keycode >= 0x0100 && keycode < 0x2000) { - // Has a modifier - action_t action; - // Split it up - action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key - return action; - } else if (keycode >= 0x2000 && keycode < 0x3000) { - // Is a shortcut for function layer, pull last 12bits - // This means we have 4,096 FN macros at our disposal - return keymap_func_to_action(keycode & 0xFFF); - } else if (keycode >= 0x3000 && keycode < 0x4000) { - // When the code starts with 3, it's an action macro. - action_t action; - action.code = ACTION_MACRO(keycode & 0xFF); - return action; -#ifdef BACKLIGHT_ENABLE - } else if (keycode >= BL_0 && keycode <= BL_15) { - action_t action; - action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F); - return action; - } else if (keycode == BL_DEC) { - action_t action; - action.code = ACTION_BACKLIGHT_DECREASE(); - return action; - } else if (keycode == BL_INC) { - action_t action; - action.code = ACTION_BACKLIGHT_INCREASE(); - return action; - } else if (keycode == BL_TOGG) { - action_t action; - action.code = ACTION_BACKLIGHT_TOGGLE(); - return action; - } else if (keycode == BL_STEP) { - action_t action; - action.code = ACTION_BACKLIGHT_STEP(); - return action; -#endif - } else if (keycode == RESET) { // RESET is 0x5000, which is why this is here - action_t action; - clear_keyboard(); - #ifdef AUDIO_ENABLE - play_notes(&goodbye, 3, false); - #endif - _delay_ms(250); - #ifdef ATREUS_ASTAR - *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific - #endif - bootloader_jump(); - return action; - } else if (keycode == DEBUG) { // DEBUG is 0x5001 - // TODO: Does this actually work? - action_t action; - print("\nDEBUG: enabled.\n"); - debug_enable = true; - return action; - } else if (keycode >= 0x5000 && keycode < 0x6000) { - // Layer movement shortcuts - // See .h to see constraints/usage - int type = (keycode >> 0x8) & 0xF; - if (type == 0x1) { - // Layer set "GOTO" - int when = (keycode >> 0x4) & 0x3; - int layer = keycode & 0xF; - action_t action; - action.code = ACTION_LAYER_SET(layer, when); - return action; - } else if (type == 0x2) { - // Momentary layer - int layer = keycode & 0xFF; - action_t action; - action.code = ACTION_LAYER_MOMENTARY(layer); - return action; - } else if (type == 0x3) { - // Set default layer - int layer = keycode & 0xFF; - action_t action; - action.code = ACTION_DEFAULT_LAYER_SET(layer); - return action; - } else if (type == 0x4) { - // Set default layer - int layer = keycode & 0xFF; - action_t action; - action.code = ACTION_LAYER_TOGGLE(layer); - return action; - } -#ifdef MIDI_ENABLE - } else if (keycode >= 0x6000 && keycode < 0x7000) { - action_t action; - action.code = ACTION_FUNCTION_OPT(keycode & 0xFF, (keycode & 0x0F00) >> 8); - return action; -#endif - } else if (keycode >= 0x7000 && keycode < 0x8000) { - action_t action; - action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); - return action; - } else if (keycode >= 0x8000 && keycode < 0x9000) { - action_t action; - action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); - return action; -#ifdef UNICODE_ENABLE - } else if (keycode >= 0x8000000) { - action_t action; - uint16_t unicode = keycode & ~(0x8000); - action.code = ACTION_FUNCTION_OPT(unicode & 0xFF, (unicode & 0xFF00) >> 8); - return action; -#endif - } else { - - } - switch (keycode) { case KC_FN0 ... KC_FN31: return keymap_fn_to_action(keycode); -#ifdef BOOTMAGIC_ENABLE case KC_CAPSLOCK: case KC_LOCKING_CAPS: if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) { @@ -224,7 +115,6 @@ action_t action_for_key(uint8_t layer, keypos_t key) return keycode_to_action(KC_BSLASH); } return keycode_to_action(KC_BSPACE); -#endif default: return keycode_to_action(keycode); } @@ -265,6 +155,142 @@ static action_t keycode_to_action(uint16_t keycode) case KC_TRNS: action.code = ACTION_TRANSPARENT; break; + case 0x0100 ... 0x1FFF: ; + // Has a modifier + // Split it up + action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key + break; + case 0x2000 ... 0x2FFF: + // Is a shortcut for function layer, pull last 12bits + // This means we have 4,096 FN macros at our disposal + return keymap_func_to_action(keycode & 0xFFF); + break; + case 0x3000 ... 0x3FFF: ; + // When the code starts with 3, it's an action macro. + action.code = ACTION_MACRO(keycode & 0xFF); + break; + #ifdef BACKLIGHT_ENABLE + case BL_0 ... BL_15: + action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F); + break; + case BL_DEC: + action.code = ACTION_BACKLIGHT_DECREASE(); + break; + case BL_INC: + action.code = ACTION_BACKLIGHT_INCREASE(); + break; + case BL_TOGG: + action.code = ACTION_BACKLIGHT_TOGGLE(); + break; + case BL_STEP: + action.code = ACTION_BACKLIGHT_STEP(); + break; + #endif + case RESET: ; // RESET is 0x5000, which is why this is here + clear_keyboard(); + #ifdef AUDIO_ENABLE + play_notes(&goodbye, 3, false); + #endif + _delay_ms(250); + #ifdef ATREUS_ASTAR + *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific + #endif + bootloader_jump(); + break; + case DEBUG: ; // DEBUG is 0x5001 + print("\nDEBUG: enabled.\n"); + debug_enable = true; + break; + case 0x5002 ... 0x50FF: + // MAGIC actions (BOOTMAGIC without the boot) + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } + /* keymap config */ + keymap_config.raw = eeconfig_read_keymap(); + if (keycode == MAGIC_SWAP_CONTROL_CAPSLOCK) { + keymap_config.swap_control_capslock = 1; + } else if (keycode == MAGIC_CAPSLOCK_TO_CONTROL) { + keymap_config.capslock_to_control = 1; + } else if (keycode == MAGIC_SWAP_LALT_LGUI) { + keymap_config.swap_lalt_lgui = 1; + } else if (keycode == MAGIC_SWAP_RALT_RGUI) { + keymap_config.swap_ralt_rgui = 1; + } else if (keycode == MAGIC_NO_GUI) { + keymap_config.no_gui = 1; + } else if (keycode == MAGIC_SWAP_GRAVE_ESC) { + keymap_config.swap_grave_esc = 1; + } else if (keycode == MAGIC_SWAP_BACKSLASH_BACKSPACE) { + keymap_config.swap_backslash_backspace = 1; + } else if (keycode == MAGIC_HOST_NKRO) { + keymap_config.nkro = 1; + } else if (keycode == MAGIC_SWAP_ALT_GUI) { + keymap_config.swap_lalt_lgui = 1; + keymap_config.swap_ralt_rgui = 1; + } + /* UNs */ + else if (keycode == MAGIC_UNSWAP_CONTROL_CAPSLOCK) { + keymap_config.swap_control_capslock = 0; + } else if (keycode == MAGIC_UNCAPSLOCK_TO_CONTROL) { + keymap_config.capslock_to_control = 0; + } else if (keycode == MAGIC_UNSWAP_LALT_LGUI) { + keymap_config.swap_lalt_lgui = 0; + } else if (keycode == MAGIC_UNSWAP_RALT_RGUI) { + keymap_config.swap_ralt_rgui = 0; + } else if (keycode == MAGIC_UNNO_GUI) { + keymap_config.no_gui = 0; + } else if (keycode == MAGIC_UNSWAP_GRAVE_ESC) { + keymap_config.swap_grave_esc = 0; + } else if (keycode == MAGIC_UNSWAP_BACKSLASH_BACKSPACE) { + keymap_config.swap_backslash_backspace = 0; + } else if (keycode == MAGIC_UNHOST_NKRO) { + keymap_config.nkro = 0; + } else if (keycode == MAGIC_UNSWAP_ALT_GUI) { + keymap_config.swap_lalt_lgui = 0; + keymap_config.swap_ralt_rgui = 0; + } + eeconfig_write_keymap(keymap_config.raw); + break; + case 0x5100 ... 0x5FFF: ; + // Layer movement shortcuts + // See .h to see constraints/usage + int type = (keycode >> 0x8) & 0xF; + if (type == 0x1) { + // Layer set "GOTO" + int when = (keycode >> 0x4) & 0x3; + int layer = keycode & 0xF; + action.code = ACTION_LAYER_SET(layer, when); + } else if (type == 0x2) { + // Momentary layer + int layer = keycode & 0xFF; + action.code = ACTION_LAYER_MOMENTARY(layer); + } else if (type == 0x3) { + // Set default layer + int layer = keycode & 0xFF; + action.code = ACTION_DEFAULT_LAYER_SET(layer); + } else if (type == 0x4) { + // Set default layer + int layer = keycode & 0xFF; + action.code = ACTION_LAYER_TOGGLE(layer); + } + break; + #ifdef MIDI_ENABLE + case 0x6000 ... 0x6FFF: + action.code = ACTION_FUNCTION_OPT(keycode & 0xFF, (keycode & 0x0F00) >> 8); + break; + #endif + case 0x7000 ... 0x7FFF: + action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); + break; + case 0x8000 ... 0x8FFF: + action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); + break; + #ifdef UNICODE_ENABLE + case 0x8000000 ... 0x8FFFFFF: + uint16_t unicode = keycode & ~(0x8000); + action.code = ACTION_FUNCTION_OPT(unicode & 0xFF, (unicode & 0xFF00) >> 8); + break; + #endif default: action.code = ACTION_NO; break; diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h index 7452a1ff..ce87e477 100644 --- a/quantum/keymap_common.h +++ b/quantum/keymap_common.h @@ -30,7 +30,6 @@ along with this program. If not, see . // #include "print.h" #include "debug.h" -#ifdef BOOTMAGIC_ENABLE /* NOTE: Not portable. Bit field order depends on implementation */ typedef union { uint16_t raw; @@ -45,8 +44,6 @@ typedef union { bool nkro:1; }; } keymap_config_t; -keymap_config_t keymap_config; -#endif /* translates key to keycode */ @@ -168,6 +165,30 @@ extern const uint16_t fn_actions[]; #define RESET 0x5000 #define DEBUG 0x5001 +// MAGIC keycodes +#define MAGIC_SWAP_CONTROL_CAPSLOCK 0x5002 +#define MAGIC_UNSWAP_CONTROL_CAPSLOCK 0x5003 +#define MAGIC_CAPSLOCK_TO_CONTROL 0x5004 +#define MAGIC_UNCAPSLOCK_TO_CONTROL 0x5005 +#define MAGIC_SWAP_LALT_LGUI 0x5006 +#define MAGIC_UNSWAP_LALT_LGUI 0x5007 +#define MAGIC_SWAP_RALT_RGUI 0x5008 +#define MAGIC_UNSWAP_RALT_RGUI 0x5009 +#define MAGIC_NO_GUI 0x500a +#define MAGIC_UNNO_GUI 0x500b +#define MAGIC_SWAP_GRAVE_ESC 0x500c +#define MAGIC_UNSWAP_GRAVE_ESC 0x500d +#define MAGIC_SWAP_BACKSLASH_BACKSPACE 0x500e +#define MAGIC_UNSWAP_BACKSLASH_BACKSPACE 0x500f +#define MAGIC_HOST_NKRO 0x5010 +#define MAGIC_UNHOST_NKRO 0x5011 +#define MAGIC_SWAP_ALT_GUI 0x5012 +#define MAGIC_UNSWAP_ALT_GUI 0x5013 + +#define AG_SWAP MAGIC_SWAP_ALT_GUI +#define AG_NORM MAGIC_UNSWAP_ALT_GUI + + // GOTO layer - 16 layers max // when: // ON_PRESS = 1 @@ -213,4 +234,5 @@ void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); #define IS_LAYER_ON(layer) ((layer_state) & (1UL<<(layer))) #define IS_LAYER_OFF(layer) ((!layer_state) & (1UL<<(layer))) + #endif diff --git a/tmk_core/common.mk b/tmk_core/common.mk index f8006c67..9cb2eb8e 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -21,6 +21,9 @@ ifeq ($(strip $(BOOTMAGIC_ENABLE)), yes) SRC += $(COMMON_DIR)/bootmagic.c SRC += $(COMMON_DIR)/avr/eeconfig.c OPT_DEFS += -DBOOTMAGIC_ENABLE +else + SRC += $(COMMON_DIR)/magic.c + SRC += $(COMMON_DIR)/avr/eeconfig.c endif ifeq ($(strip $(MOUSEKEY_ENABLE)), yes) diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 302b3ec8..1d998184 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -27,7 +27,11 @@ along with this program. If not, see . #include "command.h" #include "util.h" #include "sendchar.h" -#include "bootmagic.h" +#ifdef BOOTMAGIC_ENABLE + #include "bootmagic.h" +#else + #include "magic.h" +#endif #include "eeconfig.h" #include "backlight.h" #ifdef MOUSEKEY_ENABLE @@ -86,6 +90,8 @@ void keyboard_init(void) #ifdef BOOTMAGIC_ENABLE bootmagic(); +#else + magic(); #endif #ifdef BACKLIGHT_ENABLE diff --git a/tmk_core/common/keymap.h b/tmk_core/common/keymap.h index e1a6f992..abc9bdb3 100644 --- a/tmk_core/common/keymap.h +++ b/tmk_core/common/keymap.h @@ -22,8 +22,6 @@ along with this program. If not, see . #include #include "action.h" - -#ifdef BOOTMAGIC_ENABLE /* NOTE: Not portable. Bit field order depends on implementation */ typedef union { uint8_t raw; @@ -39,7 +37,6 @@ typedef union { }; } keymap_config_t; keymap_config_t keymap_config; -#endif /* translates key to keycode */ diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c new file mode 100644 index 00000000..f21d1346 --- /dev/null +++ b/tmk_core/common/magic.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include "matrix.h" +#include "bootloader.h" +#include "debug.h" +#include "keymap.h" +#include "host.h" +#include "action_layer.h" +#include "eeconfig.h" +#include "magic.h" + +keymap_config_t keymap_config; + +void magic(void) +{ + /* check signature */ + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } + + /* debug enable */ + debug_config.raw = eeconfig_read_debug(); + + /* keymap config */ + keymap_config.raw = eeconfig_read_keymap(); + +#ifdef NKRO_ENABLE + keyboard_nkro = keymap_config.nkro; +#endif + + uint8_t default_layer = 0; + default_layer = eeconfig_read_default_layer(); + default_layer_set((uint32_t)default_layer); + +} \ No newline at end of file diff --git a/tmk_core/common/magic.h b/tmk_core/common/magic.h new file mode 100644 index 00000000..3fa2d8b8 --- /dev/null +++ b/tmk_core/common/magic.h @@ -0,0 +1,6 @@ +#ifndef MAGIC_H +#define MAGIC_H + +void magic(void); + +#endif From b8d2e66638409066661e7dd3c66473d583256ec5 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 16 Apr 2016 19:30:15 -0400 Subject: [PATCH 20/27] readme clarity for rgbleds --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 613bdcf4..6e1ab9bc 100644 --- a/README.md +++ b/README.md @@ -304,7 +304,7 @@ For this mod, you need an unused pin wiring to DI of WS2812 strip. After wiring Please note that the underglow is not compatible with audio output. So you cannot enable both of them at the same time. -Please add the following options into your config.h, and set them up according your hardware configuration. +Please add the following options into your config.h, and set them up according your hardware configuration. These settings are for the F4 by default: #define ws2812_PORTREG PORTF #define ws2812_DDRREG DDRF @@ -314,6 +314,12 @@ Please add the following options into your config.h, and set them up according y #define RGBLIGHT_SAT_STEP 17 #define RGBLIGHT_VAL_STEP 17 +You'll need to edit `PORTF`, `DDRF`, and `PF4` on the first three lines to the port/pin you have your LED(s) wired to, eg for B3 change things to: + + #define ws2812_PORTREG PORTB + #define ws2812_DDRREG DDRB + #define ws2812_pin PB3 + The firmware supports 5 different light effects, and the color (hue, saturation, brightness) can be customized in most effects. To control the underglow, you need to modify your keymap file to assign those functions to some keys/key combinations. For details, please check this keymap. `keyboard/planck/keymaps/yang/keymap.c` ### WS2812 Wiring From c83aa16f1d614c1c10f7597a67ffb9f2ae871951 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 16 Apr 2016 20:26:02 -0400 Subject: [PATCH 21/27] fixes audio prescaler to emit correct freq --- keyboard/preonic/keymaps/default/keymap.c | 52 +++++++++++------------ quantum/audio.c | 12 +++--- quantum/keymap_common.c | 6 +-- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/keyboard/preonic/keymaps/default/keymap.c b/keyboard/preonic/keymaps/default/keymap.c index e1f9b620..6b626231 100644 --- a/keyboard/preonic/keymaps/default/keymap.c +++ b/keyboard/preonic/keymaps/default/keymap.c @@ -186,48 +186,48 @@ const uint16_t PROGMEM fn_actions[] = { #ifdef AUDIO_ENABLE float start_up[][2] = { - {440.0*pow(2.0,(50)/12.0), 20}, - {440.0*pow(2.0,(62)/12.0), 8}, - {440.0*pow(2.0,(54)/12.0), 20}, - {440.0*pow(2.0,(62)/12.0), 8} + {440.0*pow(2.0,(14)/12.0), 20}, + {440.0*pow(2.0,(26)/12.0), 8}, + {440.0*pow(2.0,(18)/12.0), 20}, + {440.0*pow(2.0,(26)/12.0), 8} }; float tone_qwerty[][2] = { - {440.0*pow(2.0,(59)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, + {440.0*pow(2.0,(23)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, {0, 4}, - {440.0*pow(2.0,(67)/12.0), 16} + {440.0*pow(2.0,(31)/12.0), 16} }; float tone_colemak[][2] = { - {440.0*pow(2.0,(59)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, + {440.0*pow(2.0,(23)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, {0, 4}, - {440.0*pow(2.0,(67)/12.0), 12}, + {440.0*pow(2.0,(31)/12.0), 12}, {0, 4}, - {440.0*pow(2.0,(71)/12.0), 12} + {440.0*pow(2.0,(35)/12.0), 12} }; float tone_dvorak[][2] = { - {440.0*pow(2.0,(59)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, + {440.0*pow(2.0,(23)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, {0, 4}, - {440.0*pow(2.0,(67)/12.0), 8}, + {440.0*pow(2.0,(31)/12.0), 8}, {0, 4}, - {440.0*pow(2.0,(69)/12.0), 8}, + {440.0*pow(2.0,(33)/12.0), 8}, {0, 4}, - {440.0*pow(2.0,(67)/12.0), 8} + {440.0*pow(2.0,(31)/12.0), 8} }; float tone_music[][2] = { - {440.0*pow(2.0,(48)/12.0), 8}, - {440.0*pow(2.0,(50)/12.0), 8}, - {440.0*pow(2.0,(52)/12.0), 8}, - {440.0*pow(2.0,(53)/12.0), 8}, - {440.0*pow(2.0,(55)/12.0), 8}, - {440.0*pow(2.0,(57)/12.0), 8}, - {440.0*pow(2.0,(59)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8} + {440.0*pow(2.0,(12)/12.0), 8}, + {440.0*pow(2.0,(14)/12.0), 8}, + {440.0*pow(2.0,(16)/12.0), 8}, + {440.0*pow(2.0,(17)/12.0), 8}, + {440.0*pow(2.0,(19)/12.0), 8}, + {440.0*pow(2.0,(21)/12.0), 8}, + {440.0*pow(2.0,(23)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8} }; #endif @@ -333,9 +333,9 @@ void process_action_user(keyrecord_t *record) { if (IS_LAYER_ON(_MUSIC)) { if (record->event.pressed) { - play_note(((double)261.626)*pow(2.0, -2.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); + play_note(((double)261.626)*pow(2.0, -3.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); } else { - stop_note(((double)261.626)*pow(2.0, -2.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); + stop_note(((double)261.626)*pow(2.0, -3.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); } } diff --git a/quantum/audio.c b/quantum/audio.c index 5edcccdb..470dc8e0 100644 --- a/quantum/audio.c +++ b/quantum/audio.c @@ -12,6 +12,8 @@ #define PI 3.14159265 +#define CPU_PRESCALER 8 + // #define PWM_AUDIO #ifdef PWM_AUDIO @@ -244,12 +246,12 @@ ISR(TIMER3_COMPA_vect) { // ICR3 = (int)(((double)F_CPU) / frequency); // Set max to the period // OCR3A = (int)(((double)F_CPU) / frequency) >> 1; // Set compare to half the period voice_place %= voices; - if (place > (frequencies[voice_place] / 500)) { + if (place > (frequencies[voice_place] / 50)) { voice_place = (voice_place + 1) % voices; place = 0.0; } - ICR3 = (int)(((double)F_CPU) / frequencies[voice_place]); // Set max to the period - OCR3A = (int)(((double)F_CPU) / frequencies[voice_place]) >> 1 * duty_place; // Set compare to half the period + ICR3 = (int)(((double)F_CPU) / (frequencies[voice_place] * CPU_PRESCALER)); // Set max to the period + OCR3A = (int)(((double)F_CPU) / (frequencies[voice_place] * CPU_PRESCALER)) >> 1 * duty_place; // Set compare to half the period place++; // if (duty_counter > (frequencies[voice_place] / 500)) { // duty_place = (duty_place % 3) + 1; @@ -281,8 +283,8 @@ ISR(TIMER3_COMPA_vect) { place -= SINE_LENGTH; #else if (note_frequency > 0) { - ICR3 = (int)(((double)F_CPU) / note_frequency); // Set max to the period - OCR3A = (int)(((double)F_CPU) / note_frequency) >> 1; // Set compare to half the period + ICR3 = (int)(((double)F_CPU) / (note_frequency * CPU_PRESCALER)); // Set max to the period + OCR3A = (int)(((double)F_CPU) / (note_frequency * CPU_PRESCALER)) >> 1; // Set compare to half the period } else { ICR3 = 0; OCR3A = 0; diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index b9191668..899437f4 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -35,9 +35,9 @@ extern keymap_config_t keymap_config; #include "audio.h" float goodbye[][2] = { - {440.0*pow(2.0,(67)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, - {440.0*pow(2.0,(55)/12.0), 12}, + {440.0*pow(2.0,(31)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, + {440.0*pow(2.0,(19)/12.0), 12}, }; #endif From b5c22ab5b5b77d5e21cc4145831608eed6756ad7 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Sat, 16 Apr 2016 19:27:21 -0500 Subject: [PATCH 22/27] Merging with QMK main to fix audio issues --- keyboard/atomic/keymaps/pvc/keymap.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/keyboard/atomic/keymaps/pvc/keymap.c b/keyboard/atomic/keymaps/pvc/keymap.c index 7abd7f4f..189da16c 100644 --- a/keyboard/atomic/keymaps/pvc/keymap.c +++ b/keyboard/atomic/keymaps/pvc/keymap.c @@ -3,8 +3,10 @@ #ifdef AUDIO_ENABLE #include "audio.h" +#include "musical_notes.h" #endif + #define _QW 0 #define _LW 1 #define _RS 2 @@ -82,10 +84,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { float tone_lw[][2] = { - {440.0*pow(2.0,(59)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, - {0, 4}, - {440.0*pow(2.0,(67)/12.0), 16} +Q_NOTE(_C4 ) , +Q_NOTE(_CS4 ) , +Q_NOTE(_D4 ) , +Q_NOTE(_DS4 ) , +Q_NOTE(_E4 ) , +Q_NOTE(_F4 ) , +Q_NOTE(_FS4 ) , +Q_NOTE(_G4 ) , +Q_NOTE(_GS4 ) , +Q_NOTE(_A4 ) , +Q_NOTE(_AS4 ) , +Q_NOTE(_B4 ) , }; float tone_rs[][2] = { @@ -158,6 +168,7 @@ void update_quad_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3, uint8_t l const uint16_t PROGMEM fn_actions[] = { }; +#define ARRAY_SIZE(x) ((sizeof x) / (sizeof *x)) const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { @@ -167,7 +178,8 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { #ifdef AUDIO_ENABLE println("PlayNotes LW"); - play_notes(&tone_lw, 4, false); + print_val_hex32(ARRAY_SIZE(tone_lw)); + play_notes(&tone_lw, 12, false); #endif layer_on(_LW); update_tri_layer(_LW, _RS, _FN); From 41cc35425ab32c9a9492006da8b667d01d32dfa6 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 16 Apr 2016 21:31:40 -0400 Subject: [PATCH 23/27] rests between notes as an argument --- keyboard/planck/keymaps/default/keymap.c | 10 ++++---- keyboard/preonic/keymaps/default/keymap.c | 16 ++++++------- quantum/audio.c | 29 ++++++++++++++++------- quantum/audio.h | 3 ++- quantum/keymap_common.c | 2 +- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/keyboard/planck/keymaps/default/keymap.c b/keyboard/planck/keymaps/default/keymap.c index ede08ad7..a6edefef 100644 --- a/keyboard/planck/keymaps/default/keymap.c +++ b/keyboard/planck/keymaps/default/keymap.c @@ -194,7 +194,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _QW: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_qw, 4, false); + play_notes(&tone_qw, 4, false, 0); #endif default_layer_set(1UL<<_QW); } @@ -202,7 +202,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _CM: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_cm, 6, false); + play_notes(&tone_cm, 6, false, 0); #endif default_layer_set(1UL<<_CM); } @@ -210,7 +210,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _DV: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_dv, 8, false); + play_notes(&tone_dv, 8, false, 0); #endif default_layer_set(1UL<<_DV); } @@ -254,7 +254,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { #ifdef AUDIO_ENABLE audio_on(); - play_notes(&start_up, 5, false); + play_notes(&start_up, 5, false, 0); #endif } break; @@ -265,6 +265,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) void matrix_init_user(void) { #ifdef AUDIO_ENABLE init_notes(); - play_notes(&start_up, 5, false); + play_notes(&start_up, 5, false, 0); #endif } diff --git a/keyboard/preonic/keymaps/default/keymap.c b/keyboard/preonic/keymaps/default/keymap.c index 6b626231..1223793c 100644 --- a/keyboard/preonic/keymaps/default/keymap.c +++ b/keyboard/preonic/keymaps/default/keymap.c @@ -242,7 +242,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _QWERTY: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_qwerty, 4, false); + play_notes(&tone_qwerty, 4, false, 0); #endif persistant_default_layer_set(1UL<<_QWERTY); } @@ -250,7 +250,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _COLEMAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_colemak, 6, false); + play_notes(&tone_colemak, 6, false, 1); #endif persistant_default_layer_set(1UL<<_COLEMAK); } @@ -258,7 +258,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _DVORAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_dvorak, 8, false); + play_notes(&tone_dvorak, 8, false, 10); #endif persistant_default_layer_set(1UL<<_DVORAK); } @@ -302,7 +302,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { #ifdef AUDIO_ENABLE audio_on(); - play_notes(&start_up, 4, false); + play_notes(&start_up, 4, false, 0); #endif } break; @@ -317,7 +317,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case 9: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_music, 8, false); + play_notes(&tone_music, 8, false, 0); layer_on(_MUSIC); #endif } @@ -333,9 +333,9 @@ void process_action_user(keyrecord_t *record) { if (IS_LAYER_ON(_MUSIC)) { if (record->event.pressed) { - play_note(((double)261.626)*pow(2.0, -3.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); + play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); } else { - stop_note(((double)261.626)*pow(2.0, -3.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); + stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); } } @@ -344,6 +344,6 @@ void process_action_user(keyrecord_t *record) { void matrix_init_user(void) { #ifdef AUDIO_ENABLE init_notes(); - play_notes(&start_up, 4, false); + play_notes(&start_up, 4, false, 0); #endif } diff --git a/quantum/audio.c b/quantum/audio.c index 470dc8e0..40d09d62 100644 --- a/quantum/audio.c +++ b/quantum/audio.c @@ -61,7 +61,11 @@ uint16_t note_position = 0; float (* notes_pointer)[][2]; uint8_t notes_length; bool notes_repeat; +float notes_rest; +bool note_resting = false; + uint8_t current_note = 0; +uint8_t rest_counter = 0; audio_config_t audio_config; @@ -314,13 +318,21 @@ ISR(TIMER3_COMPA_vect) { return; } } - #ifdef PWM_AUDIO - note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; - note_length = (*notes_pointer)[current_note][1]; - #else - note_frequency = (*notes_pointer)[current_note][0]; - note_length = (*notes_pointer)[current_note][1] / 4; - #endif + if (!note_resting && ((int)notes_rest != 0)) { + note_resting = true; + note_frequency = 0; + note_length = notes_rest; + current_note--; + } else { + note_resting = false; + #ifdef PWM_AUDIO + note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; + note_length = (*notes_pointer)[current_note][1]; + #else + note_frequency = (*notes_pointer)[current_note][0]; + note_length = (*notes_pointer)[current_note][1] / 4; + #endif + } note_position = 0; } @@ -332,7 +344,7 @@ ISR(TIMER3_COMPA_vect) { } } -void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat) { +void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat, float n_rest) { if (audio_config.enable) { @@ -343,6 +355,7 @@ if (audio_config.enable) { notes_pointer = np; notes_length = n_length; notes_repeat = n_repeat; + notes_rest = n_rest; place = 0; current_note = 0; diff --git a/quantum/audio.h b/quantum/audio.h index 58270015..65a6f943 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -2,6 +2,7 @@ #include #include #include +#include "musical_notes.h" typedef union { uint8_t raw; @@ -20,4 +21,4 @@ void play_note(double freq, int vol); void stop_note(double freq); void stop_all_notes(); void init_notes(); -void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat); +void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat, float n_rest); diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 899437f4..457f70a4 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -189,7 +189,7 @@ static action_t keycode_to_action(uint16_t keycode) case RESET: ; // RESET is 0x5000, which is why this is here clear_keyboard(); #ifdef AUDIO_ENABLE - play_notes(&goodbye, 3, false); + play_notes(&goodbye, 3, false, 0); #endif _delay_ms(250); #ifdef ATREUS_ASTAR From a87522033d6385ecd2422f26f5bb6bdad9d44676 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Sat, 16 Apr 2016 20:37:22 -0500 Subject: [PATCH 24/27] Merging with QMK main to fix rest issues --- keyboard/atomic/keymaps/pvc/keymap.c | 169 ++++++++++++++++++++++----- 1 file changed, 139 insertions(+), 30 deletions(-) diff --git a/keyboard/atomic/keymaps/pvc/keymap.c b/keyboard/atomic/keymaps/pvc/keymap.c index 189da16c..22970834 100644 --- a/keyboard/atomic/keymaps/pvc/keymap.c +++ b/keyboard/atomic/keymaps/pvc/keymap.c @@ -84,6 +84,59 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { float tone_lw[][2] = { +/* +Q_NOTE(_C1 ) , +Q_NOTE(_CS1 ) , +Q_NOTE(_D1 ) , +Q_NOTE(_DS1 ) , +Q_NOTE(_E1 ) , +Q_NOTE(_F1 ) , +Q_NOTE(_FS1 ) , +Q_NOTE(_G1 ) , +Q_NOTE(_GS1 ) , +Q_NOTE(_A1 ) , +Q_NOTE(_AS1 ) , +Q_NOTE(_B1 ) , +*/ + +Q_NOTE(_C4 ) , +Q_NOTE(_CS4 ) , +Q_NOTE(_D4 ) , +Q_NOTE(_DS4 ) , +Q_NOTE(_E4 ) , +Q_NOTE(_F4 ) , +Q_NOTE(_FS4 ) , +Q_NOTE(_G4 ) , +Q_NOTE(_GS4 ) , +Q_NOTE(_A4 ) , +Q_NOTE(_AS4 ) , +Q_NOTE(_B1 ) , + + +Q_NOTE(_C2 ) , +Q_NOTE(_CS2 ) , +Q_NOTE(_D2 ) , +Q_NOTE(_DS2 ) , +Q_NOTE(_E2 ) , +Q_NOTE(_F2 ) , +Q_NOTE(_FS2 ) , +Q_NOTE(_G2 ) , +Q_NOTE(_GS2 ) , +Q_NOTE(_A2 ) , +Q_NOTE(_AS2 ) , +Q_NOTE(_B2 ) , +Q_NOTE(_C3 ) , +Q_NOTE(_CS3 ) , +Q_NOTE(_D3 ) , +Q_NOTE(_DS3 ) , +Q_NOTE(_E3 ) , +Q_NOTE(_F3 ) , +Q_NOTE(_FS3 ) , +Q_NOTE(_G3 ) , +Q_NOTE(_GS3 ) , +Q_NOTE(_A3 ) , +Q_NOTE(_AS3 ) , +Q_NOTE(_B3 ) , Q_NOTE(_C4 ) , Q_NOTE(_CS4 ) , Q_NOTE(_D4 ) , @@ -96,15 +149,64 @@ Q_NOTE(_GS4 ) , Q_NOTE(_A4 ) , Q_NOTE(_AS4 ) , Q_NOTE(_B4 ) , +Q_NOTE(_C5 ) , +Q_NOTE(_CS5 ) , +Q_NOTE(_D5 ) , +Q_NOTE(_DS5 ) , +Q_NOTE(_E5 ) , +Q_NOTE(_F5 ) , +Q_NOTE(_FS5 ) , +Q_NOTE(_G5 ) , +Q_NOTE(_GS5 ) , +Q_NOTE(_A5 ) , +Q_NOTE(_AS5 ) , +Q_NOTE(_B5 ) , +Q_NOTE(_C6 ) , +Q_NOTE(_CS6 ) , +Q_NOTE(_D6 ) , +Q_NOTE(_DS6 ) , +Q_NOTE(_E6 ) , +Q_NOTE(_F6 ) , +Q_NOTE(_FS6 ) , +Q_NOTE(_G6 ) , +Q_NOTE(_GS6 ) , +Q_NOTE(_A6 ) , +Q_NOTE(_AS6 ) , +Q_NOTE(_B6 ) , +Q_NOTE(_C7 ) , +Q_NOTE(_CS7 ) , +Q_NOTE(_D7 ) , +Q_NOTE(_DS7 ) , +Q_NOTE(_E7 ) , +Q_NOTE(_F7 ) , +Q_NOTE(_FS7 ) , +Q_NOTE(_G7 ) , +Q_NOTE(_GS7 ) , +Q_NOTE(_A7 ) , +Q_NOTE(_AS7 ) , +Q_NOTE(_B7 ) , +Q_NOTE(_C8 ) , +Q_NOTE(_CS8 ) , +Q_NOTE(_D8 ) , +Q_NOTE(_DS8 ) , +Q_NOTE(_E8 ) , +Q_NOTE(_F8 ) , +Q_NOTE(_FS8 ) , +Q_NOTE(_G8 ) , +Q_NOTE(_GS8 ) , +Q_NOTE(_A8 ) , +Q_NOTE(_AS8 ) , +Q_NOTE(_B8 ) , + }; float tone_rs[][2] = { - {440.0*pow(2.0,(59)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, - {0, 4}, - {440.0*pow(2.0,(67)/12.0), 16}, - {0, 4}, - {440.0*pow(2.0,(71)/12.0), 16} +Q_NOTE(_F8 ) , +Q_NOTE(_G8 ) , +Q_NOTE(_GS8 ) , +Q_NOTE(_A8 ) , +Q_NOTE(_AS8 ) , +Q_NOTE(_B8 ) , }; float tone_fn[][2] = { @@ -119,23 +221,6 @@ float tone_fn[][2] = { }; #endif - -void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) -{ - if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) - { - #ifdef AUDIO_ENABLE - println("PlayNotes FN"); - play_notes(&tone_fn, 8, false); - #endif - layer_on(layer3); - } - else - { - layer_off(layer3); - } -} - void update_quad_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3, uint8_t layer4, bool order) { if (order) @@ -179,7 +264,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) #ifdef AUDIO_ENABLE println("PlayNotes LW"); print_val_hex32(ARRAY_SIZE(tone_lw)); - play_notes(&tone_lw, 12, false); + play_notes(&tone_lw, 96, false); #endif layer_on(_LW); update_tri_layer(_LW, _RS, _FN); @@ -209,18 +294,42 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) #ifdef AUDIO_ENABLE float start_up[][2] = { - {440.0*pow(2.0,(67)/12.0), 12}, - {440.0*pow(2.0,(64)/12.0), 8}, - {440.0*pow(2.0,(55)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, - {440.0*pow(2.0,(64)/12.0), 20} +Q_NOTE(_E4 ) , +{0,1} , +Q_NOTE(_E4 ) , +{0,1} , +Q_NOTE(_F4 ) , +{0,1} , +Q_NOTE(_G4 ) , +{0,1} , +Q_NOTE(_G4 ) , +{0,1} , +Q_NOTE(_F4 ) , +{0,1} , +Q_NOTE(_E4 ) , +{0,1} , +Q_NOTE(_D4 ) , +{0,1} , +Q_NOTE(_C4 ) , +{0,1} , +Q_NOTE(_C4 ) , +{0,1} , +Q_NOTE(_D4 ) , +{0,1} , +Q_NOTE(_E4 ) , +{0,1} , +H_NOTE(_E4 ) , +{0,1} , +Q_NOTE(_D4 ) , +{0,1} , +H_NOTE(_D4 ) , }; #endif void matrix_init_user(void) { #ifdef AUDIO_ENABLE init_notes(); - play_notes(&start_up, 5, false); + play_notes(&start_up, 29, false); println("Matrix Init"); #endif } From 8bbd064cf52a76508589579f19595607a1f3af21 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 16 Apr 2016 23:07:50 -0400 Subject: [PATCH 25/27] changes to play_notes, goodbye --- keyboard/planck/keymaps/default/keymap.c | 10 +++++----- keyboard/preonic/Makefile | 2 +- keyboard/preonic/config.h | 4 ++-- keyboard/preonic/keymaps/default/keymap.c | 12 ++++++------ quantum/audio.c | 2 +- quantum/keymap_common.c | 16 +++++++++------- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/keyboard/planck/keymaps/default/keymap.c b/keyboard/planck/keymaps/default/keymap.c index a6edefef..5591b337 100644 --- a/keyboard/planck/keymaps/default/keymap.c +++ b/keyboard/planck/keymaps/default/keymap.c @@ -194,7 +194,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _QW: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_qw, 4, false, 0); + play_notes(&tone_qw, false, 0); #endif default_layer_set(1UL<<_QW); } @@ -202,7 +202,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _CM: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_cm, 6, false, 0); + play_notes(&tone_cm, false, 0); #endif default_layer_set(1UL<<_CM); } @@ -210,7 +210,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _DV: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_dv, 8, false, 0); + play_notes(&tone_dv, false, 0); #endif default_layer_set(1UL<<_DV); } @@ -254,7 +254,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { #ifdef AUDIO_ENABLE audio_on(); - play_notes(&start_up, 5, false, 0); + play_notes(&start_up, false, 0); #endif } break; @@ -265,6 +265,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) void matrix_init_user(void) { #ifdef AUDIO_ENABLE init_notes(); - play_notes(&start_up, 5, false, 0); + play_notes(&start_up, false, 0); #endif } diff --git a/keyboard/preonic/Makefile b/keyboard/preonic/Makefile index 9199968c..3504e272 100644 --- a/keyboard/preonic/Makefile +++ b/keyboard/preonic/Makefile @@ -133,7 +133,7 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = yes # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) +CONSOLE_ENABLE = no # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality diff --git a/keyboard/preonic/config.h b/keyboard/preonic/config.h index 5528667f..bb9d29da 100644 --- a/keyboard/preonic/config.h +++ b/keyboard/preonic/config.h @@ -73,10 +73,10 @@ along with this program. If not, see . */ /* disable debug print */ -#define NO_DEBUG +// #define NO_DEBUG /* disable print */ -#define NO_PRINT +// #define NO_PRINT /* disable action features */ //#define NO_ACTION_LAYER diff --git a/keyboard/preonic/keymaps/default/keymap.c b/keyboard/preonic/keymaps/default/keymap.c index 1223793c..c7b6b89f 100644 --- a/keyboard/preonic/keymaps/default/keymap.c +++ b/keyboard/preonic/keymaps/default/keymap.c @@ -242,7 +242,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _QWERTY: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_qwerty, 4, false, 0); + play_notes(&tone_qwerty, false, 0); #endif persistant_default_layer_set(1UL<<_QWERTY); } @@ -250,7 +250,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _COLEMAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_colemak, 6, false, 1); + play_notes(&tone_colemak, false, 0); #endif persistant_default_layer_set(1UL<<_COLEMAK); } @@ -258,7 +258,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case _DVORAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_dvorak, 8, false, 10); + play_notes(&tone_dvorak, false, 0); #endif persistant_default_layer_set(1UL<<_DVORAK); } @@ -302,7 +302,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { #ifdef AUDIO_ENABLE audio_on(); - play_notes(&start_up, 4, false, 0); + play_notes(&start_up, false, 0); #endif } break; @@ -317,7 +317,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case 9: if (record->event.pressed) { #ifdef AUDIO_ENABLE - play_notes(&tone_music, 8, false, 0); + play_notes(&tone_music, false, 0); layer_on(_MUSIC); #endif } @@ -344,6 +344,6 @@ void process_action_user(keyrecord_t *record) { void matrix_init_user(void) { #ifdef AUDIO_ENABLE init_notes(); - play_notes(&start_up, 4, false, 0); + play_notes(&start_up, false, 0); #endif } diff --git a/quantum/audio.c b/quantum/audio.c index 40d09d62..773edfd8 100644 --- a/quantum/audio.c +++ b/quantum/audio.c @@ -318,7 +318,7 @@ ISR(TIMER3_COMPA_vect) { return; } } - if (!note_resting && ((int)notes_rest != 0)) { + if (!note_resting && (notes_rest > 0)) { note_resting = true; note_frequency = 0; note_length = notes_rest; diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 457f70a4..8f35521a 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -33,12 +33,14 @@ extern keymap_config_t keymap_config; #include #ifdef AUDIO_ENABLE #include "audio.h" - - float goodbye[][2] = { - {440.0*pow(2.0,(31)/12.0), 8}, - {440.0*pow(2.0,(24)/12.0), 8}, - {440.0*pow(2.0,(19)/12.0), 12}, - }; + #ifndef GOODBYE_TUNE + #define GOODBYE_TUNE { \ + {440.0*pow(2.0,(31)/12.0), 8}, \ + {440.0*pow(2.0,(24)/12.0), 8}, \ + {440.0*pow(2.0,(19)/12.0), 12}, \ + } + #endif + float goodbye_tune[][2] = GOODBYE_TUNE; #endif static action_t keycode_to_action(uint16_t keycode); @@ -189,7 +191,7 @@ static action_t keycode_to_action(uint16_t keycode) case RESET: ; // RESET is 0x5000, which is why this is here clear_keyboard(); #ifdef AUDIO_ENABLE - play_notes(&goodbye, 3, false, 0); + play_notes(&goodbye_tune, false, 0); #endif _delay_ms(250); #ifdef ATREUS_ASTAR From 45f10b4c4b308226fa1568277654a13853a03ab4 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Sat, 16 Apr 2016 22:10:18 -0500 Subject: [PATCH 26/27] Fixed how note arrays are used. --- keyboard/atomic/keymaps/pvc/keymap.c | 44 ++++++---------------------- quantum/audio.c | 14 ++++----- quantum/audio.h | 17 +++++++++-- quantum/keymap_common.c | 4 +-- quantum/musical_notes.h | 7 ++++- 5 files changed, 39 insertions(+), 47 deletions(-) diff --git a/keyboard/atomic/keymaps/pvc/keymap.c b/keyboard/atomic/keymaps/pvc/keymap.c index 22970834..c2081f52 100644 --- a/keyboard/atomic/keymaps/pvc/keymap.c +++ b/keyboard/atomic/keymaps/pvc/keymap.c @@ -75,8 +75,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }, }; -#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer))) -#define IS_LAYER_OFF(layer) (!IS_LAYER_ON(layer)) #ifdef AUDIO_ENABLE @@ -201,24 +199,14 @@ Q_NOTE(_B8 ) , }; float tone_rs[][2] = { -Q_NOTE(_F8 ) , -Q_NOTE(_G8 ) , -Q_NOTE(_GS8 ) , -Q_NOTE(_A8 ) , +Q_NOTE(_A4 ) , +Q_NOTE(_A4 ) , +Q_NOTE(_A4 ) , +Q_NOTE(_A4 ) , Q_NOTE(_AS8 ) , Q_NOTE(_B8 ) , }; -float tone_fn[][2] = { - {440.0*pow(2.0,(59)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, - {0, 4}, - {440.0*pow(2.0,(67)/12.0), 16}, - {0, 4}, - {440.0*pow(2.0,(69)/12.0), 16}, - {0, 4}, - {440.0*pow(2.0,(67)/12.0), 16} -}; #endif void update_quad_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3, uint8_t layer4, bool order) @@ -253,18 +241,18 @@ void update_quad_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3, uint8_t l const uint16_t PROGMEM fn_actions[] = { }; -#define ARRAY_SIZE(x) ((sizeof x) / (sizeof *x)) +//#define MUSIC_ARRAY_SIZE(x) (((int)(sizeof(x) / (sizeof(x[0][0])))) / 2) const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { + // MACRODOWN only works in this function switch(id) { case M_LW: if (record->event.pressed) { #ifdef AUDIO_ENABLE println("PlayNotes LW"); - print_val_hex32(ARRAY_SIZE(tone_lw)); - play_notes(&tone_lw, 96, false); + PLAY_NOTE_ARRAY(tone_lw, false, STACCATO); #endif layer_on(_LW); update_tri_layer(_LW, _RS, _FN); @@ -277,7 +265,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { #ifdef AUDIO_ENABLE println("PlayNotes RS"); - play_notes(&tone_rs, 6, false); + PLAY_NOTE_ARRAY(tone_rs, false, LEGATO); #endif layer_on(_RS); update_tri_layer(_LW, _RS, _FN); @@ -295,33 +283,19 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) #ifdef AUDIO_ENABLE float start_up[][2] = { Q_NOTE(_E4 ) , -{0,1} , Q_NOTE(_E4 ) , -{0,1} , Q_NOTE(_F4 ) , -{0,1} , Q_NOTE(_G4 ) , -{0,1} , Q_NOTE(_G4 ) , -{0,1} , Q_NOTE(_F4 ) , -{0,1} , Q_NOTE(_E4 ) , -{0,1} , Q_NOTE(_D4 ) , -{0,1} , Q_NOTE(_C4 ) , -{0,1} , Q_NOTE(_C4 ) , -{0,1} , Q_NOTE(_D4 ) , -{0,1} , Q_NOTE(_E4 ) , -{0,1} , H_NOTE(_E4 ) , -{0,1} , Q_NOTE(_D4 ) , -{0,1} , H_NOTE(_D4 ) , }; #endif @@ -329,7 +303,7 @@ H_NOTE(_D4 ) , void matrix_init_user(void) { #ifdef AUDIO_ENABLE init_notes(); - play_notes(&start_up, 29, false); + PLAY_NOTE_ARRAY(start_up, false, STACCATO); println("Matrix Init"); #endif } diff --git a/quantum/audio.c b/quantum/audio.c index 40d09d62..90f3c5a1 100644 --- a/quantum/audio.c +++ b/quantum/audio.c @@ -181,7 +181,7 @@ void init_notes() { DDRC |= _BV(PORTC6); TIMSK3 &= ~_BV(OCIE3A); // Turn off 3A interputs - + TCCR3A = 0x0; // Options not needed TCCR3B = _BV(CS31) | _BV(CS30) | _BV(WGM32); // 64th prescaling and CTC OCR3A = SAMPLE_DIVIDER - 1; // Correct count/compare, related to sample playback @@ -202,14 +202,14 @@ ISR(TIMER3_COMPA_vect) { if (voices == 1) { // SINE OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 2; - + // SQUARE // if (((int)place) >= 1024){ // OCR4A = 0xFF >> 2; // } else { // OCR4A = 0x00; // } - + // SAWTOOTH // OCR4A = (int)place / 4; @@ -298,9 +298,9 @@ ISR(TIMER3_COMPA_vect) { note_position++; bool end_of_note = false; - if (ICR3 > 0) + if (ICR3 > 0) end_of_note = (note_position >= (note_length / ICR3 * 0xFFFF)); - else + else end_of_note = (note_position >= (note_length * 0x7FF)); if (end_of_note) { current_note++; @@ -318,7 +318,7 @@ ISR(TIMER3_COMPA_vect) { return; } } - if (!note_resting && ((int)notes_rest != 0)) { + if (!note_resting && (notes_rest > 0)) { note_resting = true; note_frequency = 0; note_length = notes_rest; @@ -412,7 +412,7 @@ if (audio_config.enable && voices < 8) { if (frequency != 0) { double starting_f = frequency; if (frequency < freq) { - for (double f = starting_f; f <= freq; f += ((freq - starting_f) / 2000.0)) { + for (double f = starting_f; f <= freq; f += ((freq - starting_f) / 2000.0)) { frequency = f; } } else if (frequency > freq) { diff --git a/quantum/audio.h b/quantum/audio.h index 65a6f943..762c9806 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -4,6 +4,9 @@ #include #include "musical_notes.h" +#ifndef AUDIO_H +#define AUDIO_H + typedef union { uint8_t raw; struct { @@ -19,6 +22,16 @@ void audio_off(void); void play_sample(uint8_t * s, uint16_t l, bool r); void play_note(double freq, int vol); void stop_note(double freq); -void stop_all_notes(); -void init_notes(); +void stop_all_notes(void); +void init_notes(void); void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat, float n_rest); + + +// These macros are used to allow play_notes to play an array of indeterminate +// length. This works around the limitation of C's sizeof operation on pointers. +// The global float array for the song must be used here. +#define NOTE_ARRAY_SIZE(x) ((int)(sizeof(x) / (sizeof(x[0])))) +#define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style)); + + +#endif \ No newline at end of file diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 457f70a4..61a51aed 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -189,7 +189,7 @@ static action_t keycode_to_action(uint16_t keycode) case RESET: ; // RESET is 0x5000, which is why this is here clear_keyboard(); #ifdef AUDIO_ENABLE - play_notes(&goodbye, 3, false, 0); + PLAY_NOTE_ARRAY(goodbye, false, 0); #endif _delay_ms(250); #ifdef ATREUS_ASTAR @@ -202,7 +202,7 @@ static action_t keycode_to_action(uint16_t keycode) debug_enable = true; break; case 0x5002 ... 0x50FF: - // MAGIC actions (BOOTMAGIC without the boot) + // MAGIC actions (BOOTMAGIC without the boot) if (!eeconfig_is_enabled()) { eeconfig_init(); } diff --git a/quantum/musical_notes.h b/quantum/musical_notes.h index 79f04fd9..837f6a06 100644 --- a/quantum/musical_notes.h +++ b/quantum/musical_notes.h @@ -9,7 +9,7 @@ #define WHOLE_NOTE(note) {(NOTE##note), 64} #define HALF_NOTE(note) {(NOTE##note), 32} #define QUARTER_NOTE(note) {(NOTE##note), 16} -#define EIGTH_NOTE(note) {(NOTE##note), 8} +#define EIGHTH_NOTE(note) {(NOTE##note), 8} #define SIXTEENTH_NOTE(note) {(NOTE##note), 4} // Note Types Short @@ -19,6 +19,11 @@ #define E_NOTE(n) EIGTH_NOTE(n) #define S_NOTE(n) SIXTEENTH_NOTE(n) +// Note Styles +// Staccato makes sure there is a rest between each note. Think: TA TA TA +// Legato makes notes flow together. Think: TAAA +#define STACCATO 0.01 +#define LEGATO 0 // Notes - # = Octave #define NOTE_REST 0.00 From a67d425f4d5278595e7ab785a0f246b83fb1a09f Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sun, 17 Apr 2016 01:00:39 -0400 Subject: [PATCH 27/27] planck default layout updates --- keyboard/planck/Makefile | 4 +- keyboard/planck/keymaps/default/keymap.c | 183 +++++++++++++++-------- quantum/audio.c | 5 +- quantum/keymap_common.c | 8 +- 4 files changed, 130 insertions(+), 70 deletions(-) diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index 83b8303b..01d9e3ce 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile @@ -139,10 +139,10 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # change to "no" to disable the options, or define them in the makefile.mk in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = yes # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) +CONSOLE_ENABLE = no # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality diff --git a/keyboard/planck/keymaps/default/keymap.c b/keyboard/planck/keymaps/default/keymap.c index 207af2a1..aecddec4 100644 --- a/keyboard/planck/keymaps/default/keymap.c +++ b/keyboard/planck/keymaps/default/keymap.c @@ -11,24 +11,27 @@ // The underscores don't mean anything - you can have a layer called STUFF or any other name. // Layer names don't all need to be of the same length, obviously, and you can also skip them // entirely and just use numbers. -#define _QW 0 -#define _CM 1 -#define _DV 2 -#define _LW 3 -#define _RS 4 -#define _AD 5 +#define _QWERTY 0 +#define _COLEMAK 1 +#define _DVORAK 2 +#define _LOWER 3 +#define _RAISE 4 +#define _ADJUST 5 +#define _MUSIC 6 // Macro name shortcuts -#define QWERTY M(_QW) -#define COLEMAK M(_CM) -#define DVORAK M(_DV) -#define LOWER M(_LW) -#define RAISE M(_RS) +#define QWERTY M(_QWERTY) +#define COLEMAK M(_COLEMAK) +#define DVORAK M(_DVORAK) +#define LOWER M(_LOWER) +#define RAISE M(_RAISE) #define M_BL 5 #ifdef AUDIO_ENABLE #define AUD_OFF M(6) #define AUD_ON M(7) #endif +#define MUS_OFF M(8) +#define MUS_ON M(9) // Fillers to make layering more clear #define _______ KC_TRNS @@ -47,7 +50,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | * `-----------------------------------------------------------------------------------' */ -[_QW] = { +[_QWERTY] = { {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, @@ -65,7 +68,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | * `-----------------------------------------------------------------------------------' */ -[_CM] = { +[_COLEMAK] = { {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, @@ -83,7 +86,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | * `-----------------------------------------------------------------------------------' */ -[_DV] = { +[_DVORAK] = { {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, @@ -101,7 +104,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * | | | | | | | | Next | Vol- | Vol+ | Play | * `-----------------------------------------------------------------------------------' */ -[_LW] = { +[_LOWER] = { {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, @@ -119,7 +122,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * | | | | | | | | Next | Vol- | Vol+ | Play | * `-----------------------------------------------------------------------------------' */ -[_RS] = { +[_RAISE] = { {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, @@ -130,16 +133,26 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * ,-----------------------------------------------------------------------------------. * | | Reset| | | | | | | | | | Del | * |------+------+------+------+------+-------------+------+------+------+------+------| - * | | | |Aud on|Audoff| | |Qwerty|Colemk|Dvorak| | | + * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | | * |------+------+------+------+------+------|------+------+------+------+------+------| * | | | | | | | | | | | | | * |------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | | | | | * `-----------------------------------------------------------------------------------' */ -[_AD] = { +[_ADJUST] = { {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, - {_______, _______, _______, AUD_ON, AUD_OFF, _______, _______, QWERTY, COLEMAK, DVORAK, _______, _______}, + {_______, _______, _______, AUD_ON, AUD_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______}, + {_______, _______, _______, MUS_ON, MUS_OFF, _______, _______, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} +}, + +/* Music (reserved for process_action_user) + * + */ +[_MUSIC] = { + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} } @@ -150,87 +163,102 @@ const uint16_t PROGMEM fn_actions[] = { }; #ifdef AUDIO_ENABLE -float start_up[][2] = { - {440.0*pow(2.0,(67)/12.0), 12}, - {440.0*pow(2.0,(64)/12.0), 8}, - {440.0*pow(2.0,(55)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, - {440.0*pow(2.0,(64)/12.0), 20} +float tone_startup[][2] = { + {440.0*pow(2.0,(31)/12.0), 12}, + {440.0*pow(2.0,(28)/12.0), 8}, + {440.0*pow(2.0,(19)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, + {440.0*pow(2.0,(28)/12.0), 20} }; -float tone_qw[][2] = { - {440.0*pow(2.0,(59)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, +float tone_qwerty[][2] = { + {440.0*pow(2.0,(23)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, {0, 4}, - {440.0*pow(2.0,(67)/12.0), 16} + {440.0*pow(2.0,(31)/12.0), 16} }; -float tone_cm[][2] = { - {440.0*pow(2.0,(59)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, +float tone_colemak[][2] = { + {440.0*pow(2.0,(23)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, {0, 4}, - {440.0*pow(2.0,(67)/12.0), 12}, + {440.0*pow(2.0,(31)/12.0), 12}, {0, 4}, - {440.0*pow(2.0,(71)/12.0), 12} + {440.0*pow(2.0,(35)/12.0), 12} }; -float tone_dv[][2] = { - {440.0*pow(2.0,(59)/12.0), 8}, - {440.0*pow(2.0,(60)/12.0), 8}, +float tone_dvorak[][2] = { + {440.0*pow(2.0,(23)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, {0, 4}, - {440.0*pow(2.0,(67)/12.0), 8}, + {440.0*pow(2.0,(31)/12.0), 8}, {0, 4}, - {440.0*pow(2.0,(69)/12.0), 8}, + {440.0*pow(2.0,(33)/12.0), 8}, {0, 4}, - {440.0*pow(2.0,(67)/12.0), 8} + {440.0*pow(2.0,(31)/12.0), 8} +}; + +float tone_music[][2] = { + {440.0*pow(2.0,(12)/12.0), 8}, + {440.0*pow(2.0,(14)/12.0), 8}, + {440.0*pow(2.0,(16)/12.0), 8}, + {440.0*pow(2.0,(17)/12.0), 8}, + {440.0*pow(2.0,(19)/12.0), 8}, + {440.0*pow(2.0,(21)/12.0), 8}, + {440.0*pow(2.0,(23)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8} }; #endif +void persistant_default_layer_set(uint16_t default_layer) { + eeconfig_write_default_layer(default_layer); + default_layer_set(default_layer); +} + const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - // MACRODOWN only works in this function switch(id) { - case _QW: + case _QWERTY: if (record->event.pressed) { #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_qw, false, 0); + PLAY_NOTE_ARRAY(tone_qwerty, false, 0); #endif - default_layer_set(1UL<<_QW); + persistant_default_layer_set(1UL<<_QWERTY); } break; - case _CM: + case _COLEMAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_cm, false, 0); + PLAY_NOTE_ARRAY(tone_colemak, false, 0); #endif - default_layer_set(1UL<<_CM); + persistant_default_layer_set(1UL<<_COLEMAK); } break; - case _DV: + case _DVORAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_dv, false, 0); + PLAY_NOTE_ARRAY(tone_dvorak, false, 0); #endif - default_layer_set(1UL<<_DV); + persistant_default_layer_set(1UL<<_DVORAK); } break; - case _LW: + case _LOWER: if (record->event.pressed) { - layer_on(_LW); - update_tri_layer(_LW, _RS, _AD); + layer_on(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); } else { - layer_off(_LW); - update_tri_layer(_LW, _RS, _AD); + layer_off(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); } break; - case _RS: + case _RAISE: if (record->event.pressed) { - layer_on(_RS); - update_tri_layer(_LW, _RS, _AD); + layer_on(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); } else { - layer_off(_RS); - update_tri_layer(_LW, _RS, _AD); + layer_off(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); } break; case M_BL: @@ -254,7 +282,23 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { #ifdef AUDIO_ENABLE audio_on(); - PLAY_NOTE_ARRAY(start_up, false, 0); + PLAY_NOTE_ARRAY(tone_startup, false, 0); + #endif + } + break; + case 8: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + layer_off(_MUSIC); + stop_all_notes(); + #endif + } + break; + case 9: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_music, false, 0); + layer_on(_MUSIC); #endif } break; @@ -262,9 +306,24 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) return MACRO_NONE; }; +uint8_t starting_note = 0x0C; +int offset = 7; + +void process_action_user(keyrecord_t *record) { + + if (IS_LAYER_ON(_MUSIC)) { + if (record->event.pressed) { + play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); + } else { + stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); + } + } + +} + void matrix_init_user(void) { #ifdef AUDIO_ENABLE init_notes(); - PLAY_NOTE_ARRAY(start_up, false, 0); + PLAY_NOTE_ARRAY(tone_startup, false, 0); #endif } diff --git a/quantum/audio.c b/quantum/audio.c index 90f3c5a1..6bd6532a 100644 --- a/quantum/audio.c +++ b/quantum/audio.c @@ -350,7 +350,6 @@ if (audio_config.enable) { if (note) stop_all_notes(); - notes = true; notes_pointer = np; notes_length = n_length; @@ -375,6 +374,8 @@ if (audio_config.enable) { TIMSK3 |= _BV(OCIE3A); TCCR3A |= _BV(COM3A1); #endif + + notes = true; } } @@ -404,7 +405,6 @@ if (audio_config.enable && voices < 8) { if (notes) stop_all_notes(); - note = true; #ifdef PWM_AUDIO freq = freq / SAMPLE_RATE; #endif @@ -436,6 +436,7 @@ if (audio_config.enable && voices < 8) { TCCR3A |= _BV(COM3A1); #endif + note = true; } } \ No newline at end of file diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 02d3c74b..d38e6fdb 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -33,14 +33,14 @@ extern keymap_config_t keymap_config; #include #ifdef AUDIO_ENABLE #include "audio.h" - #ifndef GOODBYE_TUNE - #define GOODBYE_TUNE { \ + #ifndef TONE_GOODBYE + #define TONE_GOODBYE { \ {440.0*pow(2.0,(31)/12.0), 8}, \ {440.0*pow(2.0,(24)/12.0), 8}, \ {440.0*pow(2.0,(19)/12.0), 12}, \ } #endif - float goodbye_tune[][2] = GOODBYE_TUNE; + float tone_goodbye[][2] = TONE_GOODBYE; #endif static action_t keycode_to_action(uint16_t keycode); @@ -191,7 +191,7 @@ static action_t keycode_to_action(uint16_t keycode) case RESET: ; // RESET is 0x5000, which is why this is here clear_keyboard(); #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(goodbye_tune, false, 0); + PLAY_NOTE_ARRAY(tone_goodbye, false, 0); #endif _delay_ms(250); #ifdef ATREUS_ASTAR