diff options
author | Jack Humbert <jack.humb@gmail.com> | 2017-07-20 23:57:11 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2017-07-23 14:59:29 -0400 |
commit | 6a3c66776cb10888b24400526241b46deeb051a8 (patch) | |
tree | 7604aafe7087d9ab40aa0bb6bc603975e31d7e2e /quantum | |
parent | 8edb67b08242f2ab641d7e658a0a7adb579bbae2 (diff) | |
download | qmk_firmware-6a3c66776cb10888b24400526241b46deeb051a8.tar.gz qmk_firmware-6a3c66776cb10888b24400526241b46deeb051a8.zip |
clean-up planck and preonic keymaps, move audio stuff around
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/audio/audio.c | 14 | ||||
-rw-r--r-- | quantum/audio/audio.h | 2 | ||||
-rw-r--r-- | quantum/audio/song_list.h | 42 | ||||
-rw-r--r-- | quantum/config_common.h | 2 | ||||
-rw-r--r-- | quantum/process_keycode/process_music.c | 20 | ||||
-rw-r--r-- | quantum/quantum.c | 47 | ||||
-rw-r--r-- | quantum/quantum.h | 3 | ||||
-rw-r--r-- | quantum/quantum_keycodes.h | 4 |
8 files changed, 121 insertions, 13 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index c924f2bd5..5b8563093 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c | |||
@@ -13,6 +13,7 @@ | |||
13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | |||
16 | #include <stdio.h> | 17 | #include <stdio.h> |
17 | #include <string.h> | 18 | #include <string.h> |
18 | //#include <math.h> | 19 | //#include <math.h> |
@@ -119,9 +120,17 @@ audio_config_t audio_config; | |||
119 | uint16_t envelope_index = 0; | 120 | uint16_t envelope_index = 0; |
120 | bool glissando = true; | 121 | bool glissando = true; |
121 | 122 | ||
123 | #ifndef STARTUP_SONG | ||
124 | #define STARTUP_SONG SONG(STARTUP_SOUND) | ||
125 | #endif | ||
126 | float startup_song[][2] = STARTUP_SONG; | ||
127 | |||
122 | void audio_init() | 128 | void audio_init() |
123 | { | 129 | { |
124 | 130 | ||
131 | if (audio_initialized) | ||
132 | return; | ||
133 | |||
125 | // Check EEPROM | 134 | // Check EEPROM |
126 | if (!eeconfig_is_enabled()) | 135 | if (!eeconfig_is_enabled()) |
127 | { | 136 | { |
@@ -169,6 +178,11 @@ void audio_init() | |||
169 | #endif | 178 | #endif |
170 | 179 | ||
171 | audio_initialized = true; | 180 | audio_initialized = true; |
181 | |||
182 | if (audio_config.enable) { | ||
183 | PLAY_NOTE_ARRAY(startup_song, false, LEGATO); | ||
184 | } | ||
185 | |||
172 | } | 186 | } |
173 | 187 | ||
174 | void stop_all_notes() | 188 | void stop_all_notes() |
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 27fdc2ab6..ad3abeb78 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h | |||
@@ -99,7 +99,7 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) | |||
99 | // The global float array for the song must be used here. | 99 | // The global float array for the song must be used here. |
100 | #define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) | 100 | #define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) |
101 | #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)); | 101 | #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)); |
102 | 102 | #define PLAY_SONG(song) PLAY_NOTE_ARRAY(song, false, STACCATO) | |
103 | 103 | ||
104 | bool is_playing_notes(void); | 104 | bool is_playing_notes(void); |
105 | 105 | ||
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h index db2d1a94c..6960bee6d 100644 --- a/quantum/audio/song_list.h +++ b/quantum/audio/song_list.h | |||
@@ -18,9 +18,7 @@ | |||
18 | #ifndef SONG_LIST_H | 18 | #ifndef SONG_LIST_H |
19 | #define SONG_LIST_H | 19 | #define SONG_LIST_H |
20 | 20 | ||
21 | #define COIN_SOUND \ | 21 | #define NO_SOUND |
22 | E__NOTE(_A5 ),\ | ||
23 | HD_NOTE(_E6 ), | ||
24 | 22 | ||
25 | #define ODE_TO_JOY \ | 23 | #define ODE_TO_JOY \ |
26 | Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \ | 24 | Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \ |
@@ -55,18 +53,29 @@ | |||
55 | E__NOTE(_CS4), E__NOTE(_B4), QD_NOTE(_AS4), \ | 53 | E__NOTE(_CS4), E__NOTE(_B4), QD_NOTE(_AS4), \ |
56 | E__NOTE(_AS4), E__NOTE(_AS4), QD_NOTE(_B4), | 54 | E__NOTE(_AS4), E__NOTE(_AS4), QD_NOTE(_B4), |
57 | 55 | ||
56 | #define STARTUP_SOUND \ | ||
57 | E__NOTE(_E6), \ | ||
58 | E__NOTE(_A6), \ | ||
59 | ED_NOTE(_E7), | ||
60 | |||
58 | #define GOODBYE_SOUND \ | 61 | #define GOODBYE_SOUND \ |
59 | E__NOTE(_E7), \ | 62 | E__NOTE(_E7), \ |
60 | E__NOTE(_A6), \ | 63 | E__NOTE(_A6), \ |
61 | ED_NOTE(_E6), | 64 | ED_NOTE(_E6), |
62 | 65 | ||
63 | #define STARTUP_SOUND \ | 66 | #define PLANCK_SOUND \ |
64 | ED_NOTE(_E7 ), \ | 67 | ED_NOTE(_E7 ), \ |
65 | E__NOTE(_CS7), \ | 68 | E__NOTE(_CS7), \ |
66 | E__NOTE(_E6 ), \ | 69 | E__NOTE(_E6 ), \ |
67 | E__NOTE(_A6 ), \ | 70 | E__NOTE(_A6 ), \ |
68 | M__NOTE(_CS7, 20), | 71 | M__NOTE(_CS7, 20), |
69 | 72 | ||
73 | #define PREONIC_SOUND \ | ||
74 | M__NOTE(_B5, 20), \ | ||
75 | E__NOTE(_B6), \ | ||
76 | M__NOTE(_DS6, 20), \ | ||
77 | E__NOTE(_B6), | ||
78 | |||
70 | #define QWERTY_SOUND \ | 79 | #define QWERTY_SOUND \ |
71 | E__NOTE(_GS6 ), \ | 80 | E__NOTE(_GS6 ), \ |
72 | E__NOTE(_A6 ), \ | 81 | E__NOTE(_A6 ), \ |
@@ -107,7 +116,8 @@ | |||
107 | S__NOTE(_REST), \ | 116 | S__NOTE(_REST), \ |
108 | ED_NOTE(_E7 ), | 117 | ED_NOTE(_E7 ), |
109 | 118 | ||
110 | #define MUSIC_SCALE_SOUND \ | 119 | |
120 | #define MUSIC_ON_SOUND \ | ||
111 | E__NOTE(_A5 ), \ | 121 | E__NOTE(_A5 ), \ |
112 | E__NOTE(_B5 ), \ | 122 | E__NOTE(_B5 ), \ |
113 | E__NOTE(_CS6), \ | 123 | E__NOTE(_CS6), \ |
@@ -117,6 +127,18 @@ | |||
117 | E__NOTE(_GS6), \ | 127 | E__NOTE(_GS6), \ |
118 | E__NOTE(_A6 ), | 128 | E__NOTE(_A6 ), |
119 | 129 | ||
130 | #define MUSIC_SCALE_SOUND MUSIC_ON_SOUND | ||
131 | |||
132 | #define MUSIC_OFF_SOUND \ | ||
133 | E__NOTE(_A6 ), \ | ||
134 | E__NOTE(_GS6 ), \ | ||
135 | E__NOTE(_FS6), \ | ||
136 | E__NOTE(_E6 ), \ | ||
137 | E__NOTE(_D6 ), \ | ||
138 | E__NOTE(_CS6), \ | ||
139 | E__NOTE(_B5), \ | ||
140 | E__NOTE(_A5 ), | ||
141 | |||
120 | #define CAPS_LOCK_ON_SOUND \ | 142 | #define CAPS_LOCK_ON_SOUND \ |
121 | E__NOTE(_A3), \ | 143 | E__NOTE(_A3), \ |
122 | E__NOTE(_B3), | 144 | E__NOTE(_B3), |
@@ -141,6 +163,16 @@ | |||
141 | E__NOTE(_E5), \ | 163 | E__NOTE(_E5), \ |
142 | E__NOTE(_D5), | 164 | E__NOTE(_D5), |
143 | 165 | ||
166 | #define AG_NORM_SOUND \ | ||
167 | E__NOTE(_A5), \ | ||
168 | E__NOTE(_A5), | ||
169 | |||
170 | #define AG_SWAP_SOUND \ | ||
171 | SD_NOTE(_B5), \ | ||
172 | SD_NOTE(_A5), \ | ||
173 | SD_NOTE(_B5), \ | ||
174 | SD_NOTE(_A5), | ||
175 | |||
144 | #define UNICODE_WINDOWS \ | 176 | #define UNICODE_WINDOWS \ |
145 | E__NOTE(_B5), \ | 177 | E__NOTE(_B5), \ |
146 | S__NOTE(_E6), | 178 | S__NOTE(_E6), |
diff --git a/quantum/config_common.h b/quantum/config_common.h index c88e02d91..4c6a702af 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h | |||
@@ -100,4 +100,6 @@ | |||
100 | 100 | ||
101 | #define API_SYSEX_MAX_SIZE 32 | 101 | #define API_SYSEX_MAX_SIZE 32 |
102 | 102 | ||
103 | #include "song_list.h" | ||
104 | |||
103 | #endif | 105 | #endif |
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index 217dca280..c01740a7f 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c | |||
@@ -39,6 +39,15 @@ static uint8_t music_sequence_position = 0; | |||
39 | static uint16_t music_sequence_timer = 0; | 39 | static uint16_t music_sequence_timer = 0; |
40 | static uint16_t music_sequence_interval = 100; | 40 | static uint16_t music_sequence_interval = 100; |
41 | 41 | ||
42 | #ifndef MUSIC_ON_SONG | ||
43 | #define MUSIC_ON_SONG SONG(MUSIC_ON_SOUND) | ||
44 | #endif | ||
45 | #ifndef MUSIC_OFF_SONG | ||
46 | #define MUSIC_OFF_SONG SONG(MUSIC_OFF_SOUND) | ||
47 | #endif | ||
48 | float music_on_song[][2] = MUSIC_ON_SONG; | ||
49 | float music_off_song[][2] = MUSIC_OFF_SONG; | ||
50 | |||
42 | static void music_noteon(uint8_t note) { | 51 | static void music_noteon(uint8_t note) { |
43 | #ifdef AUDIO_ENABLE | 52 | #ifdef AUDIO_ENABLE |
44 | process_audio_noteon(note); | 53 | process_audio_noteon(note); |
@@ -79,12 +88,9 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
79 | } | 88 | } |
80 | 89 | ||
81 | if (keycode == MU_TOG && record->event.pressed) { | 90 | if (keycode == MU_TOG && record->event.pressed) { |
82 | if (music_activated) | 91 | if (music_activated) { |
83 | { | ||
84 | music_off(); | 92 | music_off(); |
85 | } | 93 | } else { |
86 | else | ||
87 | { | ||
88 | music_on(); | 94 | music_on(); |
89 | } | 95 | } |
90 | return false; | 96 | return false; |
@@ -175,12 +181,14 @@ void music_toggle(void) { | |||
175 | 181 | ||
176 | void music_on(void) { | 182 | void music_on(void) { |
177 | music_activated = 1; | 183 | music_activated = 1; |
184 | PLAY_SONG(music_on_song); | ||
178 | music_on_user(); | 185 | music_on_user(); |
179 | } | 186 | } |
180 | 187 | ||
181 | void music_off(void) { | 188 | void music_off(void) { |
182 | music_activated = 0; | ||
183 | music_all_notes_off(); | 189 | music_all_notes_off(); |
190 | music_activated = 0; | ||
191 | PLAY_SONG(music_off_song); | ||
184 | } | 192 | } |
185 | 193 | ||
186 | void matrix_scan_music(void) { | 194 | void matrix_scan_music(void) { |
diff --git a/quantum/quantum.c b/quantum/quantum.c index 36e586d31..31a6fc713 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -30,6 +30,28 @@ extern backlight_config_t backlight_config; | |||
30 | #include "fauxclicky.h" | 30 | #include "fauxclicky.h" |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | #ifdef AUDIO_ENABLE | ||
34 | #ifndef GOODBYE_SONG | ||
35 | #define GOODBYE_SONG SONG(GOODBYE_SOUND) | ||
36 | #endif | ||
37 | #ifndef AG_NORM_SONG | ||
38 | #define AG_NORM_SONG SONG(AG_NORM_SOUND) | ||
39 | #endif | ||
40 | #ifndef AG_SWAP_SONG | ||
41 | #define AG_SWAP_SONG SONG(AG_SWAP_SOUND) | ||
42 | #endif | ||
43 | #ifndef DEFAULT_LAYER_SONGS | ||
44 | #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ | ||
45 | SONG(COLEMAK_SOUND) \ | ||
46 | SONG(DVORAK_SOUND) \ | ||
47 | } | ||
48 | #endif | ||
49 | float goodbye_song[][2] = GOODBYE_SONG; | ||
50 | float ag_norm_song[][2] = AG_NORM_SONG; | ||
51 | float ag_swap_song[][2] = AG_SWAP_SONG; | ||
52 | float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; | ||
53 | #endif | ||
54 | |||
33 | static void do_code16 (uint16_t code, void (*f) (uint8_t)) { | 55 | static void do_code16 (uint16_t code, void (*f) (uint8_t)) { |
34 | switch (code) { | 56 | switch (code) { |
35 | case QK_MODS ... QK_MODS_MAX: | 57 | case QK_MODS ... QK_MODS_MAX: |
@@ -116,9 +138,15 @@ void reset_keyboard(void) { | |||
116 | clear_keyboard(); | 138 | clear_keyboard(); |
117 | #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC)) | 139 | #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC)) |
118 | music_all_notes_off(); | 140 | music_all_notes_off(); |
141 | uint16_t timer_start = timer_read(); | ||
142 | PLAY_SONG(goodbye_song); | ||
119 | shutdown_user(); | 143 | shutdown_user(); |
120 | #endif | 144 | while(timer_elapsed(timer_start) < 250) |
145 | wait_ms(1); | ||
146 | stop_all_notes(); | ||
147 | #else | ||
121 | wait_ms(250); | 148 | wait_ms(250); |
149 | #endif | ||
122 | #ifdef CATERINA_BOOTLOADER | 150 | #ifdef CATERINA_BOOTLOADER |
123 | *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific | 151 | *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific |
124 | #endif | 152 | #endif |
@@ -351,6 +379,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
351 | case MAGIC_SWAP_ALT_GUI: | 379 | case MAGIC_SWAP_ALT_GUI: |
352 | keymap_config.swap_lalt_lgui = true; | 380 | keymap_config.swap_lalt_lgui = true; |
353 | keymap_config.swap_ralt_rgui = true; | 381 | keymap_config.swap_ralt_rgui = true; |
382 | #ifdef AUDIO_ENABLE | ||
383 | PLAY_SONG(ag_swap_song); | ||
384 | #endif | ||
354 | break; | 385 | break; |
355 | case MAGIC_UNSWAP_CONTROL_CAPSLOCK: | 386 | case MAGIC_UNSWAP_CONTROL_CAPSLOCK: |
356 | keymap_config.swap_control_capslock = false; | 387 | keymap_config.swap_control_capslock = false; |
@@ -379,6 +410,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
379 | case MAGIC_UNSWAP_ALT_GUI: | 410 | case MAGIC_UNSWAP_ALT_GUI: |
380 | keymap_config.swap_lalt_lgui = false; | 411 | keymap_config.swap_lalt_lgui = false; |
381 | keymap_config.swap_ralt_rgui = false; | 412 | keymap_config.swap_ralt_rgui = false; |
413 | #ifdef AUDIO_ENABLE | ||
414 | PLAY_SONG(ag_norm_song); | ||
415 | #endif | ||
382 | break; | 416 | break; |
383 | case MAGIC_TOGGLE_NKRO: | 417 | case MAGIC_TOGGLE_NKRO: |
384 | keymap_config.nkro = !keymap_config.nkro; | 418 | keymap_config.nkro = !keymap_config.nkro; |
@@ -521,6 +555,14 @@ void send_string_with_delay(const char *str, uint8_t interval) { | |||
521 | } | 555 | } |
522 | } | 556 | } |
523 | 557 | ||
558 | void set_single_persistent_default_layer(uint8_t default_layer) { | ||
559 | #ifdef AUDIO_ENABLE | ||
560 | PLAY_SONG(default_layer_songs[default_layer]); | ||
561 | #endif | ||
562 | eeconfig_update_default_layer(1U<<default_layer); | ||
563 | default_layer_set(1U<<default_layer); | ||
564 | } | ||
565 | |||
524 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { | 566 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { |
525 | if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { | 567 | if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { |
526 | layer_on(layer3); | 568 | layer_on(layer3); |
@@ -571,6 +613,9 @@ void matrix_init_quantum() { | |||
571 | #ifdef BACKLIGHT_ENABLE | 613 | #ifdef BACKLIGHT_ENABLE |
572 | backlight_init_ports(); | 614 | backlight_init_ports(); |
573 | #endif | 615 | #endif |
616 | #ifdef AUDIO_ENABLE | ||
617 | audio_init(); | ||
618 | #endif | ||
574 | matrix_init_kb(); | 619 | matrix_init_kb(); |
575 | } | 620 | } |
576 | 621 | ||
diff --git a/quantum/quantum.h b/quantum/quantum.h index e00fe2346..6c0e46573 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
@@ -56,6 +56,7 @@ extern uint32_t default_layer_state; | |||
56 | #endif // MIDI_ENABLE | 56 | #endif // MIDI_ENABLE |
57 | 57 | ||
58 | #ifdef AUDIO_ENABLE | 58 | #ifdef AUDIO_ENABLE |
59 | #include "audio.h" | ||
59 | #include "process_audio.h" | 60 | #include "process_audio.h" |
60 | #endif | 61 | #endif |
61 | 62 | ||
@@ -103,6 +104,8 @@ void send_string_with_delay(const char *str, uint8_t interval); | |||
103 | // For tri-layer | 104 | // For tri-layer |
104 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); | 105 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); |
105 | 106 | ||
107 | void set_single_persistent_default_layer(uint8_t default_layer); | ||
108 | |||
106 | void tap_random_base64(void); | 109 | void tap_random_base64(void); |
107 | 110 | ||
108 | #define IS_LAYER_ON(layer) (layer_state & (1UL << (layer))) | 111 | #define IS_LAYER_ON(layer) (layer_state & (1UL << (layer))) |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 6038e31c4..c863b887a 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
@@ -26,6 +26,10 @@ | |||
26 | #endif | 26 | #endif |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | // Fillers to make layering more clear | ||
30 | #define _______ KC_TRNS | ||
31 | #define XXXXXXX KC_NO | ||
32 | |||
29 | enum quantum_keycodes { | 33 | enum quantum_keycodes { |
30 | // Ranges used in shortucuts - not to be used directly | 34 | // Ranges used in shortucuts - not to be used directly |
31 | QK_TMK = 0x0000, | 35 | QK_TMK = 0x0000, |