aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIBNobody <ibnobody@gmail.com>2016-04-17 20:14:37 -0500
committerIBNobody <ibnobody@gmail.com>2016-04-17 20:14:37 -0500
commit5c98ad59606ee95b82c27bf2525383a9ec88542b (patch)
tree99124a3567045aff6922a39a7062f27bd38e132a
parent23231fa577f7c6c585124226a83f21a7668e62dd (diff)
downloadqmk_firmware-5c98ad59606ee95b82c27bf2525383a9ec88542b.tar.gz
qmk_firmware-5c98ad59606ee95b82c27bf2525383a9ec88542b.zip
Added extra songs, LED indicator notes
-rw-r--r--keyboard/atomic/atomic.c31
-rw-r--r--keyboard/atomic/keymaps/pvc/config.h10
-rw-r--r--keyboard/atomic/keymaps/pvc/keymap.c292
-rw-r--r--keyboard/atomic/keymaps/pvc/makefile.mk2
-rw-r--r--keyboard/planck/keymaps/pvc_planck.c24
-rw-r--r--keyboard/retro_refit/retro_refit.c32
-rw-r--r--quantum/audio.c17
-rw-r--r--quantum/audio.h2
-rw-r--r--quantum/keymap_common.c14
-rw-r--r--quantum/musical_notes.h5
-rw-r--r--quantum/song_list.h104
-rw-r--r--tmk_core/common/command.c7
12 files changed, 346 insertions, 194 deletions
diff --git a/keyboard/atomic/atomic.c b/keyboard/atomic/atomic.c
index 30e812289..5e31264e6 100644
--- a/keyboard/atomic/atomic.c
+++ b/keyboard/atomic/atomic.c
@@ -2,12 +2,22 @@
2 2
3__attribute__ ((weak)) 3__attribute__ ((weak))
4void matrix_init_user(void) { 4void matrix_init_user(void) {
5 // leave these blank 5 // leave this function blank - it can be defined in a keymap file
6} 6};
7 7
8__attribute__ ((weak)) 8__attribute__ ((weak))
9void matrix_scan_user(void) { 9void matrix_scan_user(void) {
10 // leave these blank 10 // leave this function blank - it can be defined in a keymap file
11}
12
13__attribute__ ((weak))
14void process_action_user(keyrecord_t *record) {
15 // leave this function blank - it can be defined in a keymap file
16}
17
18__attribute__ ((weak))
19void led_set_user(uint8_t usb_led) {
20 // leave this function blank - it can be defined in a keymap file
11} 21}
12 22
13void matrix_init_kb(void) { 23void matrix_init_kb(void) {
@@ -33,4 +43,17 @@ void matrix_scan_kb(void) {
33 // runs every cycle (a lot) 43 // runs every cycle (a lot)
34 44
35 matrix_scan_user(); 45 matrix_scan_user();
36} \ No newline at end of file 46}
47
48void process_action_kb(keyrecord_t *record) {
49 // put your per-action keyboard code here
50 // runs for every action, just before processing by the firmware
51
52 process_action_user(record);
53}
54
55void led_set_kb(uint8_t usb_led) {
56 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
57
58 led_set_user(usb_led);
59}
diff --git a/keyboard/atomic/keymaps/pvc/config.h b/keyboard/atomic/keymaps/pvc/config.h
index 8449fa06d..cb0b78e44 100644
--- a/keyboard/atomic/keymaps/pvc/config.h
+++ b/keyboard/atomic/keymaps/pvc/config.h
@@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
41 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) 41 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
42 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) 42 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
43 * 43 *
44*/ 44*/
45#define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7, D3, D2, D1 } 45#define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7, D3, D2, D1 }
46#define ROWS (int []){ D0, D5, B5, B6, B3 } 46#define ROWS (int []){ D0, D5, B5, B6, B3 }
47 47
@@ -62,17 +62,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
62/* Locking resynchronize hack */ 62/* Locking resynchronize hack */
63#define LOCKING_RESYNC_ENABLE 63#define LOCKING_RESYNC_ENABLE
64 64
65/* 65/*
66 * Force NKRO 66 * Force NKRO
67 * 67 *
68 * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved 68 * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
69 * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the 69 * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
70 * makefile for this to work.) 70 * makefile for this to work.)
71 * 71 *
72 * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) 72 * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
73 * until the next keyboard reset. 73 * until the next keyboard reset.
74 * 74 *
75 * NKRO may prevent your keystrokes from being detected in the BIOS, but it is 75 * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
76 * fully operational during normal computer usage. 76 * fully operational during normal computer usage.
77 * 77 *
78 * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) 78 * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
@@ -90,7 +90,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
90 * the keyboard. They are best used in combination with the HID Listen program, 90 * the keyboard. They are best used in combination with the HID Listen program,
91 * found here: https://www.pjrc.com/teensy/hid_listen.html 91 * found here: https://www.pjrc.com/teensy/hid_listen.html
92 * 92 *
93 * The options below allow the magic key functionality to be changed. This is 93 * The options below allow the magic key functionality to be changed. This is
94 * useful if your keyboard/keypad is missing keys and you want magic key support. 94 * useful if your keyboard/keypad is missing keys and you want magic key support.
95 * 95 *
96 */ 96 */
diff --git a/keyboard/atomic/keymaps/pvc/keymap.c b/keyboard/atomic/keymaps/pvc/keymap.c
index aaef6b041..563519e4c 100644
--- a/keyboard/atomic/keymaps/pvc/keymap.c
+++ b/keyboard/atomic/keymaps/pvc/keymap.c
@@ -1,17 +1,18 @@
1#include "atomic.h" 1#include "atomic.h"
2#include "action_layer.h" 2#include "action_layer.h"
3#include "led.h"
3 4
4#ifdef AUDIO_ENABLE 5#ifdef AUDIO_ENABLE
5#include "audio.h" 6#include "audio.h"
6#include "song_list.h" 7#include "song_list.h"
7#endif 8#endif
8 9
9
10#define _QW 0 10#define _QW 0
11#define _LW 1 11#define _LW 1
12#define _RS 2 12#define _RS 2
13#define _AD 3 13#define _AD 3
14#define _FN 4 14#define _FN 4
15#define _MUSIC 4
15 16
16#define M_QW 0 17#define M_QW 0
17#define M_LW 1 18#define M_LW 1
@@ -24,6 +25,24 @@
24#define M_TU 8 25#define M_TU 8
25#define M_TD 9 26#define M_TD 9
26#define M_DF 10 27#define M_DF 10
28#define M_MUSIC_ON 11
29#define M_MUSIC_OFF 12
30#define M_AUDIO_ON 13
31#define M_AUDIO_OFF 14
32
33#define TIMBR_1 M(M_T1)
34#define TIMBR_2 M(M_T2)
35#define TIMBR_3 M(M_T3)
36#define TIMBR_4 M(M_T4)
37#define TMPO_UP M(M_TU)
38#define TMPO_DN M(M_TD)
39#define TMPO_DF M(M_DF)
40
41
42#define MUS_ON M(M_MUSIC_ON)
43#define MUS_OFF M(M_MUSIC_OFF)
44#define AUD_OFF M(M_AUDIO_OFF)
45#define AUD_ON M(M_AUDIO_ON)
27 46
28 47
29#define _______ KC_TRNS 48#define _______ KC_TRNS
@@ -70,135 +89,40 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
70 { 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___ }, 89 { 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___ },
71 { 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 }, 90 { 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 },
72 { 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 }, 91 { 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 },
73 { _______, M(M_T1), M(M_T2), M(M_T3), M(M_T4), M(M_TU), M(M_TD), M(M_DF), _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, 92 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D },
74 { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, 93 { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R },
75 }, 94 },
76 [_AD] = { /* ADJUST */ 95 [_AD] = { /* ADJUST */
96 { _______, TIMBR_1, TIMBR_2, TIMBR_3, TIMBR_4, TMPO_UP, TMPO_DN, TMPO_DF, _______, MUS_ON, MUS_OFF, AUD_ON, AUD_OFF, ___T___, ___T___ },
97 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ },
98 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ },
99 { _______, _______, _______, _______, _______, RESET, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ },
100 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ },
101 },
102[_MUSIC] = {
77 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___ }, 103 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___ },
78 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ }, 104 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ },
79 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ }, 105 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ },
80 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ }, 106 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ },
81 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ }, 107 { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ },
82 }, 108}
83};
84
85
86
87#ifdef AUDIO_ENABLE
88 109
89float start_up[][2] = SONG(ODE_TO_JOY);
90
91float tone_lw[][2] = {
92
93 Q__NOTE(_C4 ) ,
94 Q__NOTE(_CS4 ) ,
95 Q__NOTE(_D4 ) ,
96 Q__NOTE(_DS4 ) ,
97 Q__NOTE(_E4 ) ,
98 Q__NOTE(_F4 ) ,
99 Q__NOTE(_FS4 ) ,
100 Q__NOTE(_G4 ) ,
101 Q__NOTE(_GS4 ) ,
102 Q__NOTE(_A4 ) ,
103 Q__NOTE(_AS4 ) ,
104
105 Q__NOTE(_B1 ) ,
106
107 Q__NOTE(_C2 ) ,
108 Q__NOTE(_CS2 ) ,
109 Q__NOTE(_D2 ) ,
110 Q__NOTE(_DS2 ) ,
111 Q__NOTE(_E2 ) ,
112 Q__NOTE(_F2 ) ,
113 Q__NOTE(_FS2 ) ,
114 Q__NOTE(_G2 ) ,
115 Q__NOTE(_GS2 ) ,
116 Q__NOTE(_A2 ) ,
117 Q__NOTE(_AS2 ) ,
118 Q__NOTE(_B2 ) ,
119 Q__NOTE(_C3 ) ,
120 Q__NOTE(_CS3 ) ,
121 Q__NOTE(_D3 ) ,
122 Q__NOTE(_DS3 ) ,
123 Q__NOTE(_E3 ) ,
124 Q__NOTE(_F3 ) ,
125 Q__NOTE(_FS3 ) ,
126 Q__NOTE(_G3 ) ,
127 Q__NOTE(_GS3 ) ,
128 Q__NOTE(_A3 ) ,
129 Q__NOTE(_AS3 ) ,
130 Q__NOTE(_B3 ) ,
131 Q__NOTE(_C4 ) ,
132 Q__NOTE(_CS4 ) ,
133 Q__NOTE(_D4 ) ,
134 Q__NOTE(_DS4 ) ,
135 Q__NOTE(_E4 ) ,
136 Q__NOTE(_F4 ) ,
137 Q__NOTE(_FS4 ) ,
138 Q__NOTE(_G4 ) ,
139 Q__NOTE(_GS4 ) ,
140 Q__NOTE(_A4 ) ,
141 Q__NOTE(_AS4 ) ,
142 Q__NOTE(_B4 ) ,
143 Q__NOTE(_C5 ) ,
144 Q__NOTE(_CS5 ) ,
145 Q__NOTE(_D5 ) ,
146 Q__NOTE(_DS5 ) ,
147 Q__NOTE(_E5 ) ,
148 Q__NOTE(_F5 ) ,
149 Q__NOTE(_FS5 ) ,
150 Q__NOTE(_G5 ) ,
151 Q__NOTE(_GS5 ) ,
152 Q__NOTE(_A5 ) ,
153 Q__NOTE(_AS5 ) ,
154 Q__NOTE(_B5 ) ,
155 Q__NOTE(_C6 ) ,
156 Q__NOTE(_CS6 ) ,
157 Q__NOTE(_D6 ) ,
158 Q__NOTE(_DS6 ) ,
159 Q__NOTE(_E6 ) ,
160 Q__NOTE(_F6 ) ,
161 Q__NOTE(_FS6 ) ,
162 Q__NOTE(_G6 ) ,
163 Q__NOTE(_GS6 ) ,
164 Q__NOTE(_A6 ) ,
165 Q__NOTE(_AS6 ) ,
166 Q__NOTE(_B6 ) ,
167 Q__NOTE(_C7 ) ,
168 Q__NOTE(_CS7 ) ,
169 Q__NOTE(_D7 ) ,
170 Q__NOTE(_DS7 ) ,
171 Q__NOTE(_E7 ) ,
172 Q__NOTE(_F7 ) ,
173 Q__NOTE(_FS7 ) ,
174 Q__NOTE(_G7 ) ,
175 Q__NOTE(_GS7 ) ,
176 Q__NOTE(_A7 ) ,
177 Q__NOTE(_AS7 ) ,
178 Q__NOTE(_B7 ) ,
179 Q__NOTE(_C8 ) ,
180 Q__NOTE(_CS8 ) ,
181 Q__NOTE(_D8 ) ,
182 Q__NOTE(_DS8 ) ,
183 Q__NOTE(_E8 ) ,
184 Q__NOTE(_F8 ) ,
185 Q__NOTE(_FS8 ) ,
186 Q__NOTE(_G8 ) ,
187 Q__NOTE(_GS8 ) ,
188 Q__NOTE(_A8 ) ,
189 Q__NOTE(_AS8 ) ,
190 Q__NOTE(_B8 ) ,
191}; 110};
192 111
193float tone_rs[][2] = SONG(ROCK_A_BYE_BABY); 112#ifdef AUDIO_ENABLE
194 113
195void matrix_init_user(void) { 114float tone_my_startup[][2] = SONG(ODE_TO_JOY);
196 init_notes(); 115float tone_my_goodbye[][2] = SONG(ROCK_A_BYE_BABY);
197 PLAY_NOTE_ARRAY(start_up, false, STACCATO); 116float tone_audio_on[][2] = SONG(CLOSE_ENCOUNTERS_5_NOTE);
198 println("Matrix Init"); 117float tone_music_on[][2] = SONG(DOE_A_DEER);
199} 118float tone_caps_on[][2] = SONG(CAPS_LOCK_ON_SOUND);
119float tone_caps_off[][2] = SONG(CAPS_LOCK_OFF_SOUND);
120float tone_numlk_on[][2] = SONG(NUM_LOCK_ON_SOUND);
121float tone_numlk_off[][2] = SONG(NUM_LOCK_OFF_SOUND);
122float tone_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND);
123float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
200 124
201#endif 125#endif /* AUDIO_ENABLE */
202 126
203 127
204void update_quad_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3, uint8_t layer4, bool order) 128void update_quad_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3, uint8_t layer4, bool order)
@@ -242,9 +166,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
242 { 166 {
243 case M_LW: 167 case M_LW:
244 if (record->event.pressed) { 168 if (record->event.pressed) {
245 #ifdef AUDIO_ENABLE
246 PLAY_NOTE_ARRAY(tone_lw, false, STACCATO);
247 #endif
248 layer_on(_LW); 169 layer_on(_LW);
249 update_tri_layer(_LW, _RS, _AD); 170 update_tri_layer(_LW, _RS, _AD);
250 } else { 171 } else {
@@ -254,9 +175,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
254 break; 175 break;
255 case M_RS: 176 case M_RS:
256 if (record->event.pressed) { 177 if (record->event.pressed) {
257 #ifdef AUDIO_ENABLE
258 PLAY_NOTE_ARRAY(tone_rs, false, LEGATO);
259 #endif
260 layer_on(_RS); 178 layer_on(_RS);
261 update_tri_layer(_LW, _RS, _AD); 179 update_tri_layer(_LW, _RS, _AD);
262 } else { 180 } else {
@@ -306,9 +224,135 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
306 } 224 }
307 break; 225 break;
308 226
227 case M_AUDIO_OFF:
228 if (record->event.pressed) {
229 #ifdef AUDIO_ENABLE
230 audio_off();
231 #endif
232 }
233 break;
234
235 case M_AUDIO_ON:
236 if (record->event.pressed)
237 {
238 #ifdef AUDIO_ENABLE
239 audio_on();
240 PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO);
241 #endif
242 }
243 break;
244
245 case M_MUSIC_ON:
246 if (record->event.pressed)
247 {
248 #ifdef AUDIO_ENABLE
249 PLAY_NOTE_ARRAY(tone_music_on, false, STACCATO);
250 layer_on(_MUSIC);
251 #endif
252 }
253 break;
254
255 case M_MUSIC_OFF:
256 if (record->event.pressed)
257 {
258 #ifdef AUDIO_ENABLE
259 layer_off(_MUSIC);
260 stop_all_notes();
261 #endif
262 }
263 break;
264
309 default: 265 default:
310 break; 266 break;
311 267
312 } 268 }
313 return MACRO_NONE; 269 return MACRO_NONE;
314}; \ No newline at end of file 270};
271
272
273#ifdef AUDIO_ENABLE
274
275uint8_t starting_note = 0x0C;
276int offset = 7;
277
278
279void process_action_user(keyrecord_t *record)
280{
281 if (IS_LAYER_ON(_MUSIC))
282 {
283 if (record->event.pressed)
284 {
285 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);
286 }
287 else
288 {
289 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)));
290 }
291 }
292}
293
294
295void matrix_init_user(void)
296{
297 init_notes();
298 play_startup_tone();
299 println("Matrix Init");
300}
301
302void led_set_user(uint8_t usb_led)
303{
304 static uint8_t old_usb_led = 0;
305 static bool first_run = true;
306
307 // Skip first execution to avoid beeps caused by LED states being detected on power-up
308 if (!first_run)
309 {
310
311 if ((usb_led & (1<<USB_LED_CAPS_LOCK)) && !(old_usb_led & (1<<USB_LED_CAPS_LOCK)))
312 {
313 // If CAPS LK LED is turning on...
314 PLAY_NOTE_ARRAY(tone_caps_on, false, LEGATO);
315 }
316 else if (!(usb_led & (1<<USB_LED_CAPS_LOCK)) && (old_usb_led & (1<<USB_LED_CAPS_LOCK)))
317 {
318 // If CAPS LK LED is turning off...
319 PLAY_NOTE_ARRAY(tone_caps_off, false, LEGATO);
320 }
321 else if ((usb_led & (1<<USB_LED_NUM_LOCK)) && !(old_usb_led & (1<<USB_LED_NUM_LOCK)))
322 {
323 // If NUM LK LED is turning on...
324 PLAY_NOTE_ARRAY(tone_numlk_on, false, LEGATO);
325 }
326 else if (!(usb_led & (1<<USB_LED_NUM_LOCK)) && (old_usb_led & (1<<USB_LED_NUM_LOCK)))
327 {
328 // If NUM LED is turning off...
329 PLAY_NOTE_ARRAY(tone_numlk_off, false, LEGATO);
330 }
331 else if ((usb_led & (1<<USB_LED_SCROLL_LOCK)) && !(old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
332 {
333 // If SCROLL LK LED is turning on...
334 PLAY_NOTE_ARRAY(tone_scroll_on, false, LEGATO);
335 }
336 else if (!(usb_led & (1<<USB_LED_SCROLL_LOCK)) && (old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
337 {
338 // If SCROLL LED is turning off...
339 PLAY_NOTE_ARRAY(tone_scroll_off, false, LEGATO);
340 }
341 }
342 old_usb_led = usb_led;
343 first_run = false;
344}
345
346
347void play_startup_tone()
348{
349 PLAY_NOTE_ARRAY(tone_my_startup, false, STACCATO);
350}
351
352void play_goodbye_tone()
353{
354 PLAY_NOTE_ARRAY(tone_my_goodbye, false, STACCATO);
355 _delay_ms(2000);
356}
357
358#endif /* AUDIO_ENABLE */
diff --git a/keyboard/atomic/keymaps/pvc/makefile.mk b/keyboard/atomic/keymaps/pvc/makefile.mk
index d46996650..eefa42855 100644
--- a/keyboard/atomic/keymaps/pvc/makefile.mk
+++ b/keyboard/atomic/keymaps/pvc/makefile.mk
@@ -1,7 +1,7 @@
1BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) 1BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
2MOUSEKEY_ENABLE = yes # Mouse keys(+4700) 2MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
3EXTRAKEY_ENABLE = yes # Audio control and System control(+450) 3EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
4CONSOLE_ENABLE = yes # Console for debug(+400) 4CONSOLE_ENABLE = no # Console for debug(+400)
5COMMAND_ENABLE = yes # Commands for debug and configuration 5COMMAND_ENABLE = yes # Commands for debug and configuration
6NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 6NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
7BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality 7BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
diff --git a/keyboard/planck/keymaps/pvc_planck.c b/keyboard/planck/keymaps/pvc_planck.c
index 20bb5d86d..1de8acb1e 100644
--- a/keyboard/planck/keymaps/pvc_planck.c
+++ b/keyboard/planck/keymaps/pvc_planck.c
@@ -131,8 +131,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
131 */ 131 */
132[_FN] = { 132[_FN] = {
133 {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}, 133 {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
134 {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, MG_H, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
135 {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}, 134 {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
135 {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
136 {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX} 136 {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}
137} 137}
138}; 138};
@@ -142,16 +142,6 @@ const uint16_t PROGMEM fn_actions[] = {
142}; 142};
143 143
144 144
145int tri_layer = 0;
146void update_tri_layer(int layer) {
147 if (tri_layer > 1) {
148 layer_on(layer);
149 } else {
150 layer_off(layer);
151 }
152}
153
154
155const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) 145const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
156{ 146{
157 // MACRODOWN only works in this function 147 // MACRODOWN only works in this function
@@ -161,13 +151,11 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
161 if (record->event.pressed) { 151 if (record->event.pressed) {
162 print("RS_DN"); 152 print("RS_DN");
163 layer_on(_RS); 153 layer_on(_RS);
164 tri_layer++; 154 update_tri_layer(_RS, _LW, _FN);
165 update_tri_layer(_FN);
166 } else { 155 } else {
167 print("RS_UP"); 156 print("RS_UP");
168 layer_off(_RS); 157 layer_off(_RS);
169 tri_layer--; 158 update_tri_layer(_RS, _LW, _FN);
170 update_tri_layer(_FN);
171 phex(layer_state); 159 phex(layer_state);
172 } 160 }
173 break; 161 break;
@@ -176,13 +164,11 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
176 if (record->event.pressed) { 164 if (record->event.pressed) {
177 print("LW_DN"); 165 print("LW_DN");
178 layer_on(_LW); 166 layer_on(_LW);
179 tri_layer++; 167 update_tri_layer(_RS, _LW, _FN);
180 update_tri_layer(_FN);
181 } else { 168 } else {
182 print("LW_UP"); 169 print("LW_UP");
183 layer_off(_LW); 170 layer_off(_LW);
184 tri_layer--; 171 update_tri_layer(_RS, _LW, _FN);
185 update_tri_layer(_FN);
186 } 172 }
187 break; 173 break;
188 174
diff --git a/keyboard/retro_refit/retro_refit.c b/keyboard/retro_refit/retro_refit.c
index 0b13eb830..78b6edca7 100644
--- a/keyboard/retro_refit/retro_refit.c
+++ b/keyboard/retro_refit/retro_refit.c
@@ -2,39 +2,39 @@
2 2
3__attribute__ ((weak)) 3__attribute__ ((weak))
4void matrix_init_user(void) { 4void matrix_init_user(void) {
5 // leave this function blank - it can be defined in a keymap file 5 // leave this function blank - it can be defined in a keymap file
6}; 6};
7 7
8__attribute__ ((weak)) 8__attribute__ ((weak))
9void matrix_scan_user(void) { 9void matrix_scan_user(void) {
10 // leave this function blank - it can be defined in a keymap file 10 // leave this function blank - it can be defined in a keymap file
11}; 11};
12 12
13__attribute__ ((weak)) 13__attribute__ ((weak))
14void led_set_user(uint8_t usb_led) { 14void led_set_user(uint8_t usb_led) {
15 // leave this function blank - it can be defined in a keymap file 15 // leave this function blank - it can be defined in a keymap file
16}; 16};
17 17
18void matrix_init_kb(void) { 18void matrix_init_kb(void) {
19 // put your keyboard start-up code here 19 // put your keyboard start-up code here
20 // runs once when the firmware starts up 20 // runs once when the firmware starts up
21 21
22 // Disable status LED on KB, enable status LED on Teensy (KB_STATUS = !TEENSY_STATUS) 22 // Disable status LED on KB, enable status LED on Teensy (KB_STATUS = !TEENSY_STATUS)
23 DDRD |= (1<<6); 23 DDRD |= (1<<6);
24 PORTD |= (1<<6); 24 PORTD |= (1<<6);
25 25
26 matrix_init_user(); 26 matrix_init_user();
27}; 27};
28 28
29void amatrix_scan_kb(void) { 29void amatrix_scan_kb(void) {
30 // put your looping keyboard code here 30 // put your looping keyboard code here
31 // runs every cycle (a lot) 31 // runs every cycle (a lot)
32 32
33 matrix_scan_user(); 33 matrix_scan_user();
34}; 34};
35 35
36void led_set_kb(uint8_t usb_led) { 36void led_set_kb(uint8_t usb_led) {
37 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here 37 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
38 38
39 if (usb_led & (1<<USB_LED_CAPS_LOCK)) { 39 if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
40 // output low 40 // output low
@@ -62,7 +62,7 @@ void led_set_kb(uint8_t usb_led) {
62 // Hi-Z 62 // Hi-Z
63 DDRC &= ~(1<<6); 63 DDRC &= ~(1<<6);
64 PORTC &= ~(1<<6); 64 PORTC &= ~(1<<6);
65 } 65 }
66 66
67 led_set_user(usb_led); 67 led_set_user(usb_led);
68}; \ No newline at end of file 68}; \ No newline at end of file
diff --git a/quantum/audio.c b/quantum/audio.c
index 3ccd5ab9b..602366973 100644
--- a/quantum/audio.c
+++ b/quantum/audio.c
@@ -351,7 +351,7 @@ void play_notes(float (*np)[][2], uint8_t n_count, bool n_repeat, float n_rest)
351 351
352if (audio_config.enable) { 352if (audio_config.enable) {
353 353
354 if (note) 354 if (note || notes)
355 stop_all_notes(); 355 stop_all_notes();
356 356
357 notes_pointer = np; 357 notes_pointer = np;
@@ -406,7 +406,7 @@ void play_note(double freq, int vol) {
406 406
407if (audio_config.enable && voices < 8) { 407if (audio_config.enable && voices < 8) {
408 408
409 if (notes) 409 if (note || notes)
410 stop_all_notes(); 410 stop_all_notes();
411 #ifdef PWM_AUDIO 411 #ifdef PWM_AUDIO
412 freq = freq / SAMPLE_RATE; 412 freq = freq / SAMPLE_RATE;
@@ -471,3 +471,16 @@ void increase_tempo(uint8_t tempo_change)
471 } 471 }
472} 472}
473 473
474//------------------------------------------------------------------------------
475// Override these functions in your keymap file to play different tunes on
476// startup and bootloader jump
477__attribute__ ((weak))
478void play_startup_tone()
479{
480}
481
482__attribute__ ((weak))
483void play_goodbye_tone()
484{
485}
486//------------------------------------------------------------------------------
diff --git a/quantum/audio.h b/quantum/audio.h
index 05d314c94..44cafccd6 100644
--- a/quantum/audio.h
+++ b/quantum/audio.h
@@ -44,5 +44,7 @@ void decrease_tempo(uint8_t tempo_change);
44#define NOTE_ARRAY_SIZE(x) ((int)(sizeof(x) / (sizeof(x[0])))) 44#define NOTE_ARRAY_SIZE(x) ((int)(sizeof(x) / (sizeof(x[0]))))
45#define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style)); 45#define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style));
46 46
47void play_goodbye_tone(void);
48void play_startup_tone(void);
47 49
48#endif \ No newline at end of file 50#endif \ No newline at end of file
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 2001438b9..4ee290ad0 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -34,12 +34,6 @@ 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
38 #ifndef TONE_GOODBYE
39 #define TONE_GOODBYE OLKB_GOODBYE
40 #endif /*! TONE_GOODBYE */
41
42 float tone_goodbye[][2] = SONG(TONE_GOODBYE);
43#endif /* AUDIO_ENABLE */ 37#endif /* AUDIO_ENABLE */
44 38
45static action_t keycode_to_action(uint16_t keycode); 39static action_t keycode_to_action(uint16_t keycode);
@@ -47,7 +41,7 @@ static action_t keycode_to_action(uint16_t keycode);
47/* converts key to action */ 41/* converts key to action */
48action_t action_for_key(uint8_t layer, keypos_t key) 42action_t action_for_key(uint8_t layer, keypos_t key)
49{ 43{
50 // 16bit keycodes - important 44 // 16bit keycodes - important
51 uint16_t keycode = keymap_key_to_keycode(layer, key); 45 uint16_t keycode = keymap_key_to_keycode(layer, key);
52 46
53 switch (keycode) { 47 switch (keycode) {
@@ -190,7 +184,7 @@ static action_t keycode_to_action(uint16_t keycode)
190 case RESET: ; // RESET is 0x5000, which is why this is here 184 case RESET: ; // RESET is 0x5000, which is why this is here
191 clear_keyboard(); 185 clear_keyboard();
192 #ifdef AUDIO_ENABLE 186 #ifdef AUDIO_ENABLE
193 PLAY_NOTE_ARRAY(tone_goodbye, false, 0); 187 play_goodbye_tone();
194 #endif 188 #endif
195 _delay_ms(250); 189 _delay_ms(250);
196 #ifdef ATREUS_ASTAR 190 #ifdef ATREUS_ASTAR
@@ -303,7 +297,7 @@ static action_t keycode_to_action(uint16_t keycode)
303/* translates key to keycode */ 297/* translates key to keycode */
304uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) 298uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
305{ 299{
306 // Read entire word (16bits) 300 // Read entire word (16bits)
307 return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]); 301 return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
308} 302}
309 303
@@ -315,7 +309,7 @@ action_t keymap_fn_to_action(uint16_t keycode)
315 309
316action_t keymap_func_to_action(uint16_t keycode) 310action_t keymap_func_to_action(uint16_t keycode)
317{ 311{
318 // For FUNC without 8bit limit 312 // For FUNC without 8bit limit
319 return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) }; 313 return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) };
320} 314}
321 315
diff --git a/quantum/musical_notes.h b/quantum/musical_notes.h
index ccdc34f27..b08d16a6f 100644
--- a/quantum/musical_notes.h
+++ b/quantum/musical_notes.h
@@ -51,7 +51,10 @@
51 51
52 52
53// Notes - # = Octave 53// Notes - # = Octave
54
54#define NOTE_REST 0.00 55#define NOTE_REST 0.00
56
57/* These notes are currently bugged
55#define NOTE_C0 16.35 58#define NOTE_C0 16.35
56#define NOTE_CS0 17.32 59#define NOTE_CS0 17.32
57#define NOTE_D0 18.35 60#define NOTE_D0 18.35
@@ -75,6 +78,8 @@
75#define NOTE_GS1 51.91 78#define NOTE_GS1 51.91
76#define NOTE_A1 55.00 79#define NOTE_A1 55.00
77#define NOTE_AS1 58.27 80#define NOTE_AS1 58.27
81*/
82
78#define NOTE_B1 61.74 83#define NOTE_B1 61.74
79#define NOTE_C2 65.41 84#define NOTE_C2 65.41
80#define NOTE_CS2 69.30 85#define NOTE_CS2 69.30
diff --git a/quantum/song_list.h b/quantum/song_list.h
index b626c3fa6..e992bd18a 100644
--- a/quantum/song_list.h
+++ b/quantum/song_list.h
@@ -4,20 +4,98 @@
4#define SONG_LIST_H 4#define SONG_LIST_H
5 5
6#define ODE_TO_JOY \ 6#define ODE_TO_JOY \
7 Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \ 7 Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \
8 Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), \ 8 Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), \
9 Q__NOTE(_C4), Q__NOTE(_C4), Q__NOTE(_D4), Q__NOTE(_E4), \ 9 Q__NOTE(_C4), Q__NOTE(_C4), Q__NOTE(_D4), Q__NOTE(_E4), \
10 QD_NOTE(_E4), E__NOTE(_D4), H__NOTE(_D4), 10 QD_NOTE(_E4), E__NOTE(_D4), H__NOTE(_D4),
11 11
12#define ROCK_A_BYE_BABY \ 12#define ROCK_A_BYE_BABY \
13 QD_NOTE(_B4), E__NOTE(_D4), Q__NOTE(_B5), \ 13 QD_NOTE(_B4), E__NOTE(_D4), Q__NOTE(_B5), \
14 H__NOTE(_A5), Q__NOTE(_G5), \ 14 H__NOTE(_A5), Q__NOTE(_G5), \
15 QD_NOTE(_B4), E__NOTE(_D5), Q__NOTE(_G5), \ 15 QD_NOTE(_B4), E__NOTE(_D5), Q__NOTE(_G5), \
16 H__NOTE(_FS5), 16 H__NOTE(_FS5),
17 17
18#define OLKB_GOODBYE \ 18#define CLOSE_ENCOUNTERS_5_NOTE \
19 E__NOTE(_E7), \ 19 Q__NOTE(_D5), \
20 E__NOTE(_A6), \ 20 Q__NOTE(_E5), \
21 ED_NOTE(_E6), 21 Q__NOTE(_C5), \
22 Q__NOTE(_C4), \
23 Q__NOTE(_G4),
24
25#define DOE_A_DEER \
26 QD_NOTE(_C4), E__NOTE(_D4), \
27 QD_NOTE(_E4), E__NOTE(_C4), \
28 Q__NOTE(_E4), Q__NOTE(_C4), \
29 Q__NOTE(_E4),
30
31#define GOODBYE_SOUND \
32 E__NOTE(_E7), \
33 E__NOTE(_A6), \
34 ED_NOTE(_E6),
35
36#define STARTUP_SOUND \
37 ED_NOTE(_E7 ), \
38 E__NOTE(_CS7), \
39 E__NOTE(_E6 ), \
40 E__NOTE(_A6 ), \
41 M__NOTE(_CS7, 20),
42
43#define QWERTY_SOUND \
44 E__NOTE(_GS6 ), \
45 E__NOTE(_A6 ), \
46 S__NOTE(_REST), \
47 Q__NOTE(_E7 ),
48
49#define COLEMAK_SOUND \
50 E__NOTE(_GS6 ), \
51 E__NOTE(_A6 ), \
52 S__NOTE(_REST), \
53 ED_NOTE(_E7 ), \
54 S__NOTE(_REST), \
55 ED_NOTE(_GS7 ),
56
57#define DVORAK_SOUND \
58 E__NOTE(_GS6 ), \
59 E__NOTE(_A6 ), \
60 S__NOTE(_REST), \
61 E__NOTE(_E7 ), \
62 S__NOTE(_REST), \
63 E__NOTE(_FS7 ), \
64 S__NOTE(_REST), \
65 E__NOTE(_E7 ),
66
67#define MUSIC_SCALE_SOUND \
68 E__NOTE(_A5 ), \
69 E__NOTE(_B5 ), \
70 E__NOTE(_CS6), \
71 E__NOTE(_D6 ), \
72 E__NOTE(_E6 ), \
73 E__NOTE(_FS6), \
74 E__NOTE(_GS6), \
75 E__NOTE(_A6 ),
76
77#define CAPS_LOCK_ON_SOUND \
78 E__NOTE(_A3), \
79 E__NOTE(_B3),
80
81#define CAPS_LOCK_OFF_SOUND \
82 E__NOTE(_B3), \
83 E__NOTE(_A3),
84
85#define SCROLL_LOCK_ON_SOUND \
86 E__NOTE(_D4), \
87 E__NOTE(_E4),
88
89#define SCROLL_LOCK_OFF_SOUND \
90 E__NOTE(_E4), \
91 E__NOTE(_D4),
92
93#define NUM_LOCK_ON_SOUND \
94 E__NOTE(_D5), \
95 E__NOTE(_E5),
96
97#define NUM_LOCK_OFF_SOUND \
98 E__NOTE(_E5), \
99 E__NOTE(_D5),
22 100
23#endif 101#endif
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c
index 7572b9597..f06abaf7f 100644
--- a/tmk_core/common/command.c
+++ b/tmk_core/common/command.c
@@ -49,6 +49,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
49# include "usbdrv.h" 49# include "usbdrv.h"
50#endif 50#endif
51 51
52#ifdef AUDIO_ENABLE
53 #include "audio.h"
54#endif /* AUDIO_ENABLE */
55
52 56
53static bool command_common(uint8_t code); 57static bool command_common(uint8_t code);
54static void command_common_help(void); 58static void command_common_help(void);
@@ -352,6 +356,9 @@ static bool command_common(uint8_t code)
352 case MAGIC_KC(MAGIC_KEY_BOOTLOADER): 356 case MAGIC_KC(MAGIC_KEY_BOOTLOADER):
353 clear_keyboard(); // clear to prevent stuck keys 357 clear_keyboard(); // clear to prevent stuck keys
354 print("\n\nJumping to bootloader... "); 358 print("\n\nJumping to bootloader... ");
359 #ifdef AUDIO_ENABLE
360 play_goodbye_tone();
361 #endif
355 _delay_ms(1000); 362 _delay_ms(1000);
356 bootloader_jump(); // not return 363 bootloader_jump(); // not return
357 break; 364 break;