aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/feature_audio.md4
-rw-r--r--quantum/audio/audio.c8
-rw-r--r--quantum/process_keycode/process_clicky.c14
-rw-r--r--users/drashna/drashna.c28
-rw-r--r--users/drashna/drashna.h3
5 files changed, 33 insertions, 24 deletions
diff --git a/docs/feature_audio.md b/docs/feature_audio.md
index 039c62cdf..fe210c09b 100644
--- a/docs/feature_audio.md
+++ b/docs/feature_audio.md
@@ -128,13 +128,11 @@ This adds a click sound each time you hit a button, to simulate click sounds fro
128* `CK_UP` - Increases the frequency of the clicks 128* `CK_UP` - Increases the frequency of the clicks
129* `CK_DOWN` - Decreases the frequency of the clicks 129* `CK_DOWN` - Decreases the frequency of the clicks
130 130
131
131The feature is disabled by default, to save space. To enable it, add this to your `config.h`: 132The feature is disabled by default, to save space. To enable it, add this to your `config.h`:
132 133
133 #define AUDIO_CLICKY 134 #define AUDIO_CLICKY
134 135
135Additionally, even when enabled, the feature is not enabled by default, so you would need to turn it on first. And since we don't use EEPROM to store the setting (yet), you can default this to on by adding this to your `config.h`:
136
137 #define AUDIO_CLICKY_ON
138 136
139You can configure the default, min and max frequencies, the stepping and built in randomness by defining these values: 137You can configure the default, min and max frequencies, the stepping and built in randomness by defining these values:
140 138
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 }
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index 20df2f4de..7bb272a26 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -133,9 +133,6 @@ void led_set_keymap(uint8_t usb_led) {}
133void matrix_init_user(void) { 133void matrix_init_user(void) {
134 userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE); 134 userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE);
135 135
136#ifdef AUDIO_CLICKY
137 clicky_enable = userspace_config.clicky_enable;
138#endif
139 136
140#ifdef BOOTLOADER_CATERINA 137#ifdef BOOTLOADER_CATERINA
141 DDRD &= ~(1<<5); 138 DDRD &= ~(1<<5);
@@ -145,7 +142,6 @@ void matrix_init_user(void) {
145 PORTB &= ~(1<<0); 142 PORTB &= ~(1<<0);
146#endif 143#endif
147 144
148
149#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) 145#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
150 set_unicode_input_mode(UC_WINC); 146 set_unicode_input_mode(UC_WINC);
151#endif //UNICODE_ENABLE 147#endif //UNICODE_ENABLE
@@ -338,11 +334,27 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
338 return false; break; 334 return false; break;
339 335
340 336
341 case CLICKY_TOGGLE: 337 case KC_CCCV: // One key copy/paste
342#ifdef AUDIO_CLICKY 338 if(record->event.pressed){
343 userspace_config.clicky_enable = clicky_enable; 339 copy_paste_timer = timer_read();
344 eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); 340 } else {
341 if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy
342 register_code(KC_LCTL);
343 tap(KC_C);
344 unregister_code(KC_LCTL);
345#ifdef AUDIO_ENABLE
346 PLAY_SONG(tone_copy);
347#endif
348 } else { // Tap, paste
349 register_code(KC_LCTL);
350 tap(KC_V);
351 unregister_code(KC_LCTL);
352#ifdef AUDIO_ENABLE
353 PLAY_SONG(tone_paste);
345#endif 354#endif
355 }
356 }
357 return false;
346 break; 358 break;
347#ifdef UNICODE_ENABLE 359#ifdef UNICODE_ENABLE
348 case UC_FLIP: // (╯°□°)╯ ︵ ┻━┻ 360 case UC_FLIP: // (╯°□°)╯ ︵ ┻━┻
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h
index dd0d1c0d7..de8c3ba94 100644
--- a/users/drashna/drashna.h
+++ b/users/drashna/drashna.h
@@ -49,7 +49,7 @@ enum userspace_layers {
49// RGB color codes are no longer located here anymore. Instead, you will want to 49// RGB color codes are no longer located here anymore. Instead, you will want to
50// head to https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h 50// head to https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h
51 51
52extern bool clicky_enable; 52extern bool rgb_layer_change;
53 53
54#ifdef RGBLIGHT_ENABLE 54#ifdef RGBLIGHT_ENABLE
55void rgblight_sethsv_default_helper(uint8_t index); 55void rgblight_sethsv_default_helper(uint8_t index);
@@ -64,7 +64,6 @@ bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t thi
64typedef union { 64typedef union {
65 uint8_t raw; 65 uint8_t raw;
66 struct { 66 struct {
67 bool clicky_enable :1;
68 bool rgb_layer_change :1; 67 bool rgb_layer_change :1;
69 bool is_overwatch :1; 68 bool is_overwatch :1;
70 bool nuke_switch :1; 69 bool nuke_switch :1;