diff options
| -rw-r--r-- | keyboard/planck/Makefile | 4 | ||||
| -rw-r--r-- | keyboard/planck/keymaps/default/keymap.c | 183 | ||||
| -rw-r--r-- | keyboard/preonic/Makefile | 2 | ||||
| -rw-r--r-- | keyboard/preonic/config.h | 4 | ||||
| -rw-r--r-- | keyboard/preonic/keymaps/default/keymap.c | 17 | ||||
| -rw-r--r-- | quantum/audio.c | 5 | ||||
| -rw-r--r-- | quantum/audio.h | 6 | ||||
| -rw-r--r-- | quantum/keymap_common.c | 16 |
8 files changed, 150 insertions, 87 deletions
diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index 83b8303b0..01d9e3ce9 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile | |||
| @@ -139,10 +139,10 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||
| 139 | # change to "no" to disable the options, or define them in the makefile.mk in | 139 | # change to "no" to disable the options, or define them in the makefile.mk in |
| 140 | # the appropriate keymap folder that will get included automatically | 140 | # the appropriate keymap folder that will get included automatically |
| 141 | # | 141 | # |
| 142 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) | 142 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) |
| 143 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | 143 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) |
| 144 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | 144 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) |
| 145 | CONSOLE_ENABLE = yes # Console for debug(+400) | 145 | CONSOLE_ENABLE = no # Console for debug(+400) |
| 146 | COMMAND_ENABLE = yes # Commands for debug and configuration | 146 | COMMAND_ENABLE = yes # Commands for debug and configuration |
| 147 | NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 147 | NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 148 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality | 148 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality |
diff --git a/keyboard/planck/keymaps/default/keymap.c b/keyboard/planck/keymaps/default/keymap.c index a6edefefd..aecddec4a 100644 --- a/keyboard/planck/keymaps/default/keymap.c +++ b/keyboard/planck/keymaps/default/keymap.c | |||
| @@ -11,24 +11,27 @@ | |||
| 11 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | 11 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. |
| 12 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | 12 | // Layer names don't all need to be of the same length, obviously, and you can also skip them |
| 13 | // entirely and just use numbers. | 13 | // entirely and just use numbers. |
| 14 | #define _QW 0 | 14 | #define _QWERTY 0 |
| 15 | #define _CM 1 | 15 | #define _COLEMAK 1 |
| 16 | #define _DV 2 | 16 | #define _DVORAK 2 |
| 17 | #define _LW 3 | 17 | #define _LOWER 3 |
| 18 | #define _RS 4 | 18 | #define _RAISE 4 |
| 19 | #define _AD 5 | 19 | #define _ADJUST 5 |
| 20 | #define _MUSIC 6 | ||
| 20 | 21 | ||
| 21 | // Macro name shortcuts | 22 | // Macro name shortcuts |
| 22 | #define QWERTY M(_QW) | 23 | #define QWERTY M(_QWERTY) |
| 23 | #define COLEMAK M(_CM) | 24 | #define COLEMAK M(_COLEMAK) |
| 24 | #define DVORAK M(_DV) | 25 | #define DVORAK M(_DVORAK) |
| 25 | #define LOWER M(_LW) | 26 | #define LOWER M(_LOWER) |
| 26 | #define RAISE M(_RS) | 27 | #define RAISE M(_RAISE) |
| 27 | #define M_BL 5 | 28 | #define M_BL 5 |
| 28 | #ifdef AUDIO_ENABLE | 29 | #ifdef AUDIO_ENABLE |
| 29 | #define AUD_OFF M(6) | 30 | #define AUD_OFF M(6) |
| 30 | #define AUD_ON M(7) | 31 | #define AUD_ON M(7) |
| 31 | #endif | 32 | #endif |
| 33 | #define MUS_OFF M(8) | ||
| 34 | #define MUS_ON M(9) | ||
| 32 | 35 | ||
| 33 | // Fillers to make layering more clear | 36 | // Fillers to make layering more clear |
| 34 | #define _______ KC_TRNS | 37 | #define _______ KC_TRNS |
| @@ -47,7 +50,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 47 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | 50 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | |
| 48 | * `-----------------------------------------------------------------------------------' | 51 | * `-----------------------------------------------------------------------------------' |
| 49 | */ | 52 | */ |
| 50 | [_QW] = { | 53 | [_QWERTY] = { |
| 51 | {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, | 54 | {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, |
| 52 | {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, | 55 | {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, |
| 53 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, | 56 | {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] = { | |||
| 65 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | 68 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | |
| 66 | * `-----------------------------------------------------------------------------------' | 69 | * `-----------------------------------------------------------------------------------' |
| 67 | */ | 70 | */ |
| 68 | [_CM] = { | 71 | [_COLEMAK] = { |
| 69 | {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, | 72 | {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, |
| 70 | {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, | 73 | {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, |
| 71 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, | 74 | {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] = { | |||
| 83 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | 86 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | |
| 84 | * `-----------------------------------------------------------------------------------' | 87 | * `-----------------------------------------------------------------------------------' |
| 85 | */ | 88 | */ |
| 86 | [_DV] = { | 89 | [_DVORAK] = { |
| 87 | {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, | 90 | {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, |
| 88 | {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, | 91 | {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, |
| 89 | {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, | 92 | {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] = { | |||
| 101 | * | | | | | | | | Next | Vol- | Vol+ | Play | | 104 | * | | | | | | | | Next | Vol- | Vol+ | Play | |
| 102 | * `-----------------------------------------------------------------------------------' | 105 | * `-----------------------------------------------------------------------------------' |
| 103 | */ | 106 | */ |
| 104 | [_LW] = { | 107 | [_LOWER] = { |
| 105 | {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, | 108 | {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, |
| 106 | {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, | 109 | {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, |
| 107 | {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, | 110 | {_______, 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] = { | |||
| 119 | * | | | | | | | | Next | Vol- | Vol+ | Play | | 122 | * | | | | | | | | Next | Vol- | Vol+ | Play | |
| 120 | * `-----------------------------------------------------------------------------------' | 123 | * `-----------------------------------------------------------------------------------' |
| 121 | */ | 124 | */ |
| 122 | [_RS] = { | 125 | [_RAISE] = { |
| 123 | {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, | 126 | {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, |
| 124 | {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, | 127 | {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, |
| 125 | {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, | 128 | {_______, 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] = { | |||
| 130 | * ,-----------------------------------------------------------------------------------. | 133 | * ,-----------------------------------------------------------------------------------. |
| 131 | * | | Reset| | | | | | | | | | Del | | 134 | * | | Reset| | | | | | | | | | Del | |
| 132 | * |------+------+------+------+------+-------------+------+------+------+------+------| | 135 | * |------+------+------+------+------+-------------+------+------+------+------+------| |
| 133 | * | | | |Aud on|Audoff| | |Qwerty|Colemk|Dvorak| | | | 136 | * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | | |
| 134 | * |------+------+------+------+------+------|------+------+------+------+------+------| | 137 | * |------+------+------+------+------+------|------+------+------+------+------+------| |
| 135 | * | | | | | | | | | | | | | | 138 | * | | | | | | | | | | | | | |
| 136 | * |------+------+------+------+------+------+------+------+------+------+------+------| | 139 | * |------+------+------+------+------+------+------+------+------+------+------+------| |
| 137 | * | | | | | | | | | | | | | 140 | * | | | | | | | | | | | | |
| 138 | * `-----------------------------------------------------------------------------------' | 141 | * `-----------------------------------------------------------------------------------' |
| 139 | */ | 142 | */ |
| 140 | [_AD] = { | 143 | [_ADJUST] = { |
| 141 | {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, | 144 | {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, |
| 142 | {_______, _______, _______, AUD_ON, AUD_OFF, _______, _______, QWERTY, COLEMAK, DVORAK, _______, _______}, | 145 | {_______, _______, _______, AUD_ON, AUD_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______}, |
| 146 | {_______, _______, _______, MUS_ON, MUS_OFF, _______, _______, _______, _______, _______, _______, _______}, | ||
| 147 | {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} | ||
| 148 | }, | ||
| 149 | |||
| 150 | /* Music (reserved for process_action_user) | ||
| 151 | * | ||
| 152 | */ | ||
| 153 | [_MUSIC] = { | ||
| 154 | {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, | ||
| 155 | {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, | ||
| 143 | {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, | 156 | {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, |
| 144 | {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} | 157 | {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} |
| 145 | } | 158 | } |
| @@ -150,87 +163,102 @@ const uint16_t PROGMEM fn_actions[] = { | |||
| 150 | }; | 163 | }; |
| 151 | 164 | ||
| 152 | #ifdef AUDIO_ENABLE | 165 | #ifdef AUDIO_ENABLE |
| 153 | float start_up[][2] = { | 166 | float tone_startup[][2] = { |
| 154 | {440.0*pow(2.0,(67)/12.0), 12}, | 167 | {440.0*pow(2.0,(31)/12.0), 12}, |
| 155 | {440.0*pow(2.0,(64)/12.0), 8}, | 168 | {440.0*pow(2.0,(28)/12.0), 8}, |
| 156 | {440.0*pow(2.0,(55)/12.0), 8}, | 169 | {440.0*pow(2.0,(19)/12.0), 8}, |
| 157 | {440.0*pow(2.0,(60)/12.0), 8}, | 170 | {440.0*pow(2.0,(24)/12.0), 8}, |
| 158 | {440.0*pow(2.0,(64)/12.0), 20} | 171 | {440.0*pow(2.0,(28)/12.0), 20} |
| 159 | }; | 172 | }; |
| 160 | 173 | ||
| 161 | float tone_qw[][2] = { | 174 | float tone_qwerty[][2] = { |
| 162 | {440.0*pow(2.0,(59)/12.0), 8}, | 175 | {440.0*pow(2.0,(23)/12.0), 8}, |
| 163 | {440.0*pow(2.0,(60)/12.0), 8}, | 176 | {440.0*pow(2.0,(24)/12.0), 8}, |
| 164 | {0, 4}, | 177 | {0, 4}, |
| 165 | {440.0*pow(2.0,(67)/12.0), 16} | 178 | {440.0*pow(2.0,(31)/12.0), 16} |
| 166 | }; | 179 | }; |
| 167 | 180 | ||
| 168 | float tone_cm[][2] = { | 181 | float tone_colemak[][2] = { |
| 169 | {440.0*pow(2.0,(59)/12.0), 8}, | 182 | {440.0*pow(2.0,(23)/12.0), 8}, |
| 170 | {440.0*pow(2.0,(60)/12.0), 8}, | 183 | {440.0*pow(2.0,(24)/12.0), 8}, |
| 171 | {0, 4}, | 184 | {0, 4}, |
| 172 | {440.0*pow(2.0,(67)/12.0), 12}, | 185 | {440.0*pow(2.0,(31)/12.0), 12}, |
| 173 | {0, 4}, | 186 | {0, 4}, |
| 174 | {440.0*pow(2.0,(71)/12.0), 12} | 187 | {440.0*pow(2.0,(35)/12.0), 12} |
| 175 | }; | 188 | }; |
| 176 | 189 | ||
| 177 | float tone_dv[][2] = { | 190 | float tone_dvorak[][2] = { |
| 178 | {440.0*pow(2.0,(59)/12.0), 8}, | 191 | {440.0*pow(2.0,(23)/12.0), 8}, |
| 179 | {440.0*pow(2.0,(60)/12.0), 8}, | 192 | {440.0*pow(2.0,(24)/12.0), 8}, |
| 180 | {0, 4}, | 193 | {0, 4}, |
| 181 | {440.0*pow(2.0,(67)/12.0), 8}, | 194 | {440.0*pow(2.0,(31)/12.0), 8}, |
| 182 | {0, 4}, | 195 | {0, 4}, |
| 183 | {440.0*pow(2.0,(69)/12.0), 8}, | 196 | {440.0*pow(2.0,(33)/12.0), 8}, |
| 184 | {0, 4}, | 197 | {0, 4}, |
| 185 | {440.0*pow(2.0,(67)/12.0), 8} | 198 | {440.0*pow(2.0,(31)/12.0), 8} |
| 199 | }; | ||
| 200 | |||
| 201 | float tone_music[][2] = { | ||
| 202 | {440.0*pow(2.0,(12)/12.0), 8}, | ||
| 203 | {440.0*pow(2.0,(14)/12.0), 8}, | ||
| 204 | {440.0*pow(2.0,(16)/12.0), 8}, | ||
| 205 | {440.0*pow(2.0,(17)/12.0), 8}, | ||
| 206 | {440.0*pow(2.0,(19)/12.0), 8}, | ||
| 207 | {440.0*pow(2.0,(21)/12.0), 8}, | ||
| 208 | {440.0*pow(2.0,(23)/12.0), 8}, | ||
| 209 | {440.0*pow(2.0,(24)/12.0), 8} | ||
| 186 | }; | 210 | }; |
| 187 | #endif | 211 | #endif |
| 188 | 212 | ||
| 189 | 213 | ||
| 214 | void persistant_default_layer_set(uint16_t default_layer) { | ||
| 215 | eeconfig_write_default_layer(default_layer); | ||
| 216 | default_layer_set(default_layer); | ||
| 217 | } | ||
| 218 | |||
| 190 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | 219 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) |
| 191 | { | 220 | { |
| 192 | // MACRODOWN only works in this function | ||
| 193 | switch(id) { | 221 | switch(id) { |
| 194 | case _QW: | 222 | case _QWERTY: |
| 195 | if (record->event.pressed) { | 223 | if (record->event.pressed) { |
| 196 | #ifdef AUDIO_ENABLE | 224 | #ifdef AUDIO_ENABLE |
| 197 | play_notes(&tone_qw, 4, false, 0); | 225 | PLAY_NOTE_ARRAY(tone_qwerty, false, 0); |
| 198 | #endif | 226 | #endif |
| 199 | default_layer_set(1UL<<_QW); | 227 | persistant_default_layer_set(1UL<<_QWERTY); |
| 200 | } | 228 | } |
| 201 | break; | 229 | break; |
| 202 | case _CM: | 230 | case _COLEMAK: |
| 203 | if (record->event.pressed) { | 231 | if (record->event.pressed) { |
| 204 | #ifdef AUDIO_ENABLE | 232 | #ifdef AUDIO_ENABLE |
| 205 | play_notes(&tone_cm, 6, false, 0); | 233 | PLAY_NOTE_ARRAY(tone_colemak, false, 0); |
| 206 | #endif | 234 | #endif |
| 207 | default_layer_set(1UL<<_CM); | 235 | persistant_default_layer_set(1UL<<_COLEMAK); |
| 208 | } | 236 | } |
| 209 | break; | 237 | break; |
| 210 | case _DV: | 238 | case _DVORAK: |
| 211 | if (record->event.pressed) { | 239 | if (record->event.pressed) { |
| 212 | #ifdef AUDIO_ENABLE | 240 | #ifdef AUDIO_ENABLE |
| 213 | play_notes(&tone_dv, 8, false, 0); | 241 | PLAY_NOTE_ARRAY(tone_dvorak, false, 0); |
| 214 | #endif | 242 | #endif |
| 215 | default_layer_set(1UL<<_DV); | 243 | persistant_default_layer_set(1UL<<_DVORAK); |
| 216 | } | 244 | } |
| 217 | break; | 245 | break; |
| 218 | case _LW: | 246 | case _LOWER: |
| 219 | if (record->event.pressed) { | 247 | if (record->event.pressed) { |
| 220 | layer_on(_LW); | 248 | layer_on(_LOWER); |
| 221 | update_tri_layer(_LW, _RS, _AD); | 249 | update_tri_layer(_LOWER, _RAISE, _ADJUST); |
| 222 | } else { | 250 | } else { |
| 223 | layer_off(_LW); | 251 | layer_off(_LOWER); |
| 224 | update_tri_layer(_LW, _RS, _AD); | 252 | update_tri_layer(_LOWER, _RAISE, _ADJUST); |
| 225 | } | 253 | } |
| 226 | break; | 254 | break; |
| 227 | case _RS: | 255 | case _RAISE: |
| 228 | if (record->event.pressed) { | 256 | if (record->event.pressed) { |
| 229 | layer_on(_RS); | 257 | layer_on(_RAISE); |
| 230 | update_tri_layer(_LW, _RS, _AD); | 258 | update_tri_layer(_LOWER, _RAISE, _ADJUST); |
| 231 | } else { | 259 | } else { |
| 232 | layer_off(_RS); | 260 | layer_off(_RAISE); |
| 233 | update_tri_layer(_LW, _RS, _AD); | 261 | update_tri_layer(_LOWER, _RAISE, _ADJUST); |
| 234 | } | 262 | } |
| 235 | break; | 263 | break; |
| 236 | case M_BL: | 264 | case M_BL: |
| @@ -254,7 +282,23 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 254 | if (record->event.pressed) { | 282 | if (record->event.pressed) { |
| 255 | #ifdef AUDIO_ENABLE | 283 | #ifdef AUDIO_ENABLE |
| 256 | audio_on(); | 284 | audio_on(); |
| 257 | play_notes(&start_up, 5, false, 0); | 285 | PLAY_NOTE_ARRAY(tone_startup, false, 0); |
| 286 | #endif | ||
| 287 | } | ||
| 288 | break; | ||
| 289 | case 8: | ||
| 290 | if (record->event.pressed) { | ||
| 291 | #ifdef AUDIO_ENABLE | ||
| 292 | layer_off(_MUSIC); | ||
| 293 | stop_all_notes(); | ||
| 294 | #endif | ||
| 295 | } | ||
| 296 | break; | ||
| 297 | case 9: | ||
| 298 | if (record->event.pressed) { | ||
| 299 | #ifdef AUDIO_ENABLE | ||
| 300 | PLAY_NOTE_ARRAY(tone_music, false, 0); | ||
| 301 | layer_on(_MUSIC); | ||
| 258 | #endif | 302 | #endif |
| 259 | } | 303 | } |
| 260 | break; | 304 | break; |
| @@ -262,9 +306,24 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 262 | return MACRO_NONE; | 306 | return MACRO_NONE; |
| 263 | }; | 307 | }; |
| 264 | 308 | ||
| 309 | uint8_t starting_note = 0x0C; | ||
| 310 | int offset = 7; | ||
| 311 | |||
| 312 | void process_action_user(keyrecord_t *record) { | ||
| 313 | |||
| 314 | if (IS_LAYER_ON(_MUSIC)) { | ||
| 315 | if (record->event.pressed) { | ||
| 316 | 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); | ||
| 317 | } else { | ||
| 318 | 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))); | ||
| 319 | } | ||
| 320 | } | ||
| 321 | |||
| 322 | } | ||
| 323 | |||
| 265 | void matrix_init_user(void) { | 324 | void matrix_init_user(void) { |
| 266 | #ifdef AUDIO_ENABLE | 325 | #ifdef AUDIO_ENABLE |
| 267 | init_notes(); | 326 | init_notes(); |
| 268 | play_notes(&start_up, 5, false, 0); | 327 | PLAY_NOTE_ARRAY(tone_startup, false, 0); |
| 269 | #endif | 328 | #endif |
| 270 | } | 329 | } |
diff --git a/keyboard/preonic/Makefile b/keyboard/preonic/Makefile index 9199968c3..3504e2720 100644 --- a/keyboard/preonic/Makefile +++ b/keyboard/preonic/Makefile | |||
| @@ -133,7 +133,7 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||
| 133 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | 133 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) |
| 134 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | 134 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) |
| 135 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | 135 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) |
| 136 | CONSOLE_ENABLE = yes # Console for debug(+400) | 136 | CONSOLE_ENABLE = no # Console for debug(+400) |
| 137 | COMMAND_ENABLE = yes # Commands for debug and configuration | 137 | COMMAND_ENABLE = yes # Commands for debug and configuration |
| 138 | NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 138 | NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 139 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality | 139 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality |
diff --git a/keyboard/preonic/config.h b/keyboard/preonic/config.h index 5528667fa..bb9d29dab 100644 --- a/keyboard/preonic/config.h +++ b/keyboard/preonic/config.h | |||
| @@ -73,10 +73,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 73 | */ | 73 | */ |
| 74 | 74 | ||
| 75 | /* disable debug print */ | 75 | /* disable debug print */ |
| 76 | #define NO_DEBUG | 76 | // #define NO_DEBUG |
| 77 | 77 | ||
| 78 | /* disable print */ | 78 | /* disable print */ |
| 79 | #define NO_PRINT | 79 | // #define NO_PRINT |
| 80 | 80 | ||
| 81 | /* disable action features */ | 81 | /* disable action features */ |
| 82 | //#define NO_ACTION_LAYER | 82 | //#define NO_ACTION_LAYER |
diff --git a/keyboard/preonic/keymaps/default/keymap.c b/keyboard/preonic/keymaps/default/keymap.c index 1223793cf..48bc72dab 100644 --- a/keyboard/preonic/keymaps/default/keymap.c +++ b/keyboard/preonic/keymaps/default/keymap.c | |||
| @@ -3,11 +3,6 @@ | |||
| 3 | #include "eeconfig.h" | 3 | #include "eeconfig.h" |
| 4 | #ifdef AUDIO_ENABLE | 4 | #ifdef AUDIO_ENABLE |
| 5 | #include "audio.h" | 5 | #include "audio.h" |
| 6 | #define SCALE (int []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ | ||
| 7 | 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ | ||
| 8 | 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ | ||
| 9 | 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ | ||
| 10 | 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } | ||
| 11 | #endif | 6 | #endif |
| 12 | 7 | ||
| 13 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | 8 | // Each layer gets a name for readability, which is then used in the keymap matrix below. |
| @@ -242,7 +237,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 242 | case _QWERTY: | 237 | case _QWERTY: |
| 243 | if (record->event.pressed) { | 238 | if (record->event.pressed) { |
| 244 | #ifdef AUDIO_ENABLE | 239 | #ifdef AUDIO_ENABLE |
| 245 | play_notes(&tone_qwerty, 4, false, 0); | 240 | PLAY_NOTE_ARRAY(tone_qwerty, false, 0); |
| 246 | #endif | 241 | #endif |
| 247 | persistant_default_layer_set(1UL<<_QWERTY); | 242 | persistant_default_layer_set(1UL<<_QWERTY); |
| 248 | } | 243 | } |
| @@ -250,7 +245,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 250 | case _COLEMAK: | 245 | case _COLEMAK: |
| 251 | if (record->event.pressed) { | 246 | if (record->event.pressed) { |
| 252 | #ifdef AUDIO_ENABLE | 247 | #ifdef AUDIO_ENABLE |
| 253 | play_notes(&tone_colemak, 6, false, 1); | 248 | PLAY_NOTE_ARRAY(tone_colemak, false, 0); |
| 254 | #endif | 249 | #endif |
| 255 | persistant_default_layer_set(1UL<<_COLEMAK); | 250 | persistant_default_layer_set(1UL<<_COLEMAK); |
| 256 | } | 251 | } |
| @@ -258,7 +253,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 258 | case _DVORAK: | 253 | case _DVORAK: |
| 259 | if (record->event.pressed) { | 254 | if (record->event.pressed) { |
| 260 | #ifdef AUDIO_ENABLE | 255 | #ifdef AUDIO_ENABLE |
| 261 | play_notes(&tone_dvorak, 8, false, 10); | 256 | PLAY_NOTE_ARRAY(tone_dvorak, false, 0); |
| 262 | #endif | 257 | #endif |
| 263 | persistant_default_layer_set(1UL<<_DVORAK); | 258 | persistant_default_layer_set(1UL<<_DVORAK); |
| 264 | } | 259 | } |
| @@ -302,7 +297,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 302 | if (record->event.pressed) { | 297 | if (record->event.pressed) { |
| 303 | #ifdef AUDIO_ENABLE | 298 | #ifdef AUDIO_ENABLE |
| 304 | audio_on(); | 299 | audio_on(); |
| 305 | play_notes(&start_up, 4, false, 0); | 300 | PLAY_NOTE_ARRAY(start_up, false, 0); |
| 306 | #endif | 301 | #endif |
| 307 | } | 302 | } |
| 308 | break; | 303 | break; |
| @@ -317,7 +312,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 317 | case 9: | 312 | case 9: |
| 318 | if (record->event.pressed) { | 313 | if (record->event.pressed) { |
| 319 | #ifdef AUDIO_ENABLE | 314 | #ifdef AUDIO_ENABLE |
| 320 | play_notes(&tone_music, 8, false, 0); | 315 | PLAY_NOTE_ARRAY(tone_music, false, 0); |
| 321 | layer_on(_MUSIC); | 316 | layer_on(_MUSIC); |
| 322 | #endif | 317 | #endif |
| 323 | } | 318 | } |
| @@ -344,6 +339,6 @@ void process_action_user(keyrecord_t *record) { | |||
| 344 | void matrix_init_user(void) { | 339 | void matrix_init_user(void) { |
| 345 | #ifdef AUDIO_ENABLE | 340 | #ifdef AUDIO_ENABLE |
| 346 | init_notes(); | 341 | init_notes(); |
| 347 | play_notes(&start_up, 4, false, 0); | 342 | play_notes(&start_up, false, 0); |
| 348 | #endif | 343 | #endif |
| 349 | } | 344 | } |
diff --git a/quantum/audio.c b/quantum/audio.c index 58b9ab76b..3ccd5ab9b 100644 --- a/quantum/audio.c +++ b/quantum/audio.c | |||
| @@ -353,7 +353,6 @@ if (audio_config.enable) { | |||
| 353 | 353 | ||
| 354 | if (note) | 354 | if (note) |
| 355 | stop_all_notes(); | 355 | stop_all_notes(); |
| 356 | notes = true; | ||
| 357 | 356 | ||
| 358 | notes_pointer = np; | 357 | notes_pointer = np; |
| 359 | notes_count = n_count; | 358 | notes_count = n_count; |
| @@ -378,6 +377,8 @@ if (audio_config.enable) { | |||
| 378 | TIMSK3 |= _BV(OCIE3A); | 377 | TIMSK3 |= _BV(OCIE3A); |
| 379 | TCCR3A |= _BV(COM3A1); | 378 | TCCR3A |= _BV(COM3A1); |
| 380 | #endif | 379 | #endif |
| 380 | |||
| 381 | notes = true; | ||
| 381 | } | 382 | } |
| 382 | 383 | ||
| 383 | } | 384 | } |
| @@ -407,7 +408,6 @@ if (audio_config.enable && voices < 8) { | |||
| 407 | 408 | ||
| 408 | if (notes) | 409 | if (notes) |
| 409 | stop_all_notes(); | 410 | stop_all_notes(); |
| 410 | note = true; | ||
| 411 | #ifdef PWM_AUDIO | 411 | #ifdef PWM_AUDIO |
| 412 | freq = freq / SAMPLE_RATE; | 412 | freq = freq / SAMPLE_RATE; |
| 413 | #endif | 413 | #endif |
| @@ -439,6 +439,7 @@ if (audio_config.enable && voices < 8) { | |||
| 439 | TCCR3A |= _BV(COM3A1); | 439 | TCCR3A |= _BV(COM3A1); |
| 440 | #endif | 440 | #endif |
| 441 | 441 | ||
| 442 | note = true; | ||
| 442 | } | 443 | } |
| 443 | 444 | ||
| 444 | } | 445 | } |
diff --git a/quantum/audio.h b/quantum/audio.h index 8012aa6bf..3aba8370a 100644 --- a/quantum/audio.h +++ b/quantum/audio.h | |||
| @@ -31,6 +31,12 @@ void set_tempo(float tempo); | |||
| 31 | void increase_tempo(uint8_t tempo_change); | 31 | void increase_tempo(uint8_t tempo_change); |
| 32 | void decrease_tempo(uint8_t tempo_change); | 32 | void decrease_tempo(uint8_t tempo_change); |
| 33 | 33 | ||
| 34 | #define SCALE (int []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ | ||
| 35 | 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ | ||
| 36 | 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ | ||
| 37 | 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ | ||
| 38 | 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } | ||
| 39 | |||
| 34 | // These macros are used to allow play_notes to play an array of indeterminate | 40 | // These macros are used to allow play_notes to play an array of indeterminate |
| 35 | // length. This works around the limitation of C's sizeof operation on pointers. | 41 | // length. This works around the limitation of C's sizeof operation on pointers. |
| 36 | // The global float array for the song must be used here. | 42 | // The global float array for the song must be used here. |
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index ce1d007f3..c705b7a73 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -34,12 +34,14 @@ extern keymap_config_t keymap_config; | |||
| 34 | #include <inttypes.h> | 34 | #include <inttypes.h> |
| 35 | #ifdef AUDIO_ENABLE | 35 | #ifdef AUDIO_ENABLE |
| 36 | #include "audio.h" | 36 | #include "audio.h" |
| 37 | 37 | #ifndef TONE_GOODBYE | |
| 38 | float goodbye[][2] = { | 38 | #define TONE_GOODBYE { \ |
| 39 | {440.0*pow(2.0,(31)/12.0), 8}, | 39 | {440.0*pow(2.0,(31)/12.0), 8}, \ |
| 40 | {440.0*pow(2.0,(24)/12.0), 8}, | 40 | {440.0*pow(2.0,(24)/12.0), 8}, \ |
| 41 | {440.0*pow(2.0,(19)/12.0), 12}, | 41 | {440.0*pow(2.0,(19)/12.0), 12}, \ |
| 42 | }; | 42 | } |
| 43 | #endif | ||
| 44 | float tone_goodbye[][2] = TONE_GOODBYE; | ||
| 43 | #endif | 45 | #endif |
| 44 | 46 | ||
| 45 | static action_t keycode_to_action(uint16_t keycode); | 47 | static action_t keycode_to_action(uint16_t keycode); |
| @@ -190,7 +192,7 @@ static action_t keycode_to_action(uint16_t keycode) | |||
| 190 | case RESET: ; // RESET is 0x5000, which is why this is here | 192 | case RESET: ; // RESET is 0x5000, which is why this is here |
| 191 | clear_keyboard(); | 193 | clear_keyboard(); |
| 192 | #ifdef AUDIO_ENABLE | 194 | #ifdef AUDIO_ENABLE |
| 193 | PLAY_NOTE_ARRAY(goodbye, false, 0); | 195 | PLAY_NOTE_ARRAY(tone_goodbye, false, 0); |
| 194 | #endif | 196 | #endif |
| 195 | _delay_ms(250); | 197 | _delay_ms(250); |
| 196 | #ifdef ATREUS_ASTAR | 198 | #ifdef ATREUS_ASTAR |
