aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2018-05-08 18:46:29 -0700
committerskullydazed <skullydazed@users.noreply.github.com>2018-09-25 13:28:36 -0700
commite72e4b6920299176a322a2862f930b7ee5f73dff (patch)
tree1bd34f2b6fe46d08589699d5b47c984fc66d26f7 /quantum
parentb7e25f9ec4203670f2434e82608554ba284cf1f3 (diff)
downloadqmk_firmware-e72e4b6920299176a322a2862f930b7ee5f73dff.tar.gz
qmk_firmware-e72e4b6920299176a322a2862f930b7ee5f73dff.zip
Store Clicky status in EEPROM
Diffstat (limited to 'quantum')
-rw-r--r--quantum/audio/audio.c8
-rw-r--r--quantum/process_keycode/process_clicky.c14
2 files changed, 11 insertions, 11 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c
index c948a60d6..6d6833ec1 100644
--- a/quantum/audio/audio.c
+++ b/quantum/audio/audio.c
@@ -223,7 +223,7 @@ void audio_init()
223 TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10); 223 TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10);
224 TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER)); 224 TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER));
225 TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre); 225 TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre);
226 #endif 226 #endif
227 227
228 audio_initialized = true; 228 audio_initialized = true;
229 } 229 }
@@ -231,7 +231,7 @@ void audio_init()
231 if (audio_config.enable) { 231 if (audio_config.enable) {
232 PLAY_SONG(startup_song); 232 PLAY_SONG(startup_song);
233 } 233 }
234 234
235} 235}
236 236
237void stop_all_notes() 237void stop_all_notes()
@@ -464,7 +464,7 @@ ISR(TIMER3_AUDIO_vect)
464 note_position++; 464 note_position++;
465 bool end_of_note = false; 465 bool end_of_note = false;
466 if (TIMER_3_PERIOD > 0) { 466 if (TIMER_3_PERIOD > 0) {
467 if (!note_resting) 467 if (!note_resting)
468 end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF - 1)); 468 end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF - 1));
469 else 469 else
470 end_of_note = (note_position >= (note_length)); 470 end_of_note = (note_position >= (note_length));
@@ -604,7 +604,7 @@ ISR(TIMER1_AUDIO_vect)
604 note_position++; 604 note_position++;
605 bool end_of_note = false; 605 bool end_of_note = false;
606 if (TIMER_1_PERIOD > 0) { 606 if (TIMER_1_PERIOD > 0) {
607 if (!note_resting) 607 if (!note_resting)
608 end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1)); 608 end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1));
609 else 609 else
610 end_of_note = (note_position >= (note_length)); 610 end_of_note = (note_position >= (note_length));
diff --git a/quantum/process_keycode/process_clicky.c b/quantum/process_keycode/process_clicky.c
index 1e950d111..bd2f1b3b3 100644
--- a/quantum/process_keycode/process_clicky.c
+++ b/quantum/process_keycode/process_clicky.c
@@ -3,11 +3,6 @@
3 3
4#ifdef AUDIO_CLICKY 4#ifdef AUDIO_CLICKY
5 5
6#ifdef AUDIO_CLICKY_ON
7bool clicky_enable = true;
8#else // AUDIO_CLICKY_ON
9bool clicky_enable = false;
10#endif // AUDIO_CLICKY_ON
11#ifndef AUDIO_CLICKY_FREQ_DEFAULT 6#ifndef AUDIO_CLICKY_FREQ_DEFAULT
12#define AUDIO_CLICKY_FREQ_DEFAULT 440.0f 7#define AUDIO_CLICKY_FREQ_DEFAULT 440.0f
13#endif // !AUDIO_CLICKY_FREQ_DEFAULT 8#endif // !AUDIO_CLICKY_FREQ_DEFAULT
@@ -27,6 +22,8 @@ bool clicky_enable = false;
27float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; 22float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
28float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations 23float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations
29 24
25extern audio_config_t audio_config;
26
30#ifndef NO_MUSIC_MODE 27#ifndef NO_MUSIC_MODE
31extern bool music_activated; 28extern bool music_activated;
32extern bool midi_activated; 29extern bool midi_activated;
@@ -42,7 +39,10 @@ void clicky_play(void) {
42} 39}
43 40
44bool process_clicky(uint16_t keycode, keyrecord_t *record) { 41bool process_clicky(uint16_t keycode, keyrecord_t *record) {
45 if (keycode == CLICKY_TOGGLE && record->event.pressed) { clicky_enable = !clicky_enable; } 42 if (keycode == CLICKY_TOGGLE && record->event.pressed) {
43 audio_config.clicky ^= 1;
44 eeconfig_update_audio(audio_config.raw);
45 }
46 46
47 if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; } 47 if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; }
48 48
@@ -60,7 +60,7 @@ bool process_clicky(uint16_t keycode, keyrecord_t *record) {
60 } 60 }
61 61
62 62
63 if ( clicky_enable ) { 63 if ( audio_config.clicky ) {
64 if (record->event.pressed) { 64 if (record->event.pressed) {
65 clicky_play();; 65 clicky_play();;
66 } 66 }