]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Store Clicky status in EEPROM
authorDrashna Jaelre <drashna@live.com>
Wed, 9 May 2018 01:46:29 +0000 (18:46 -0700)
committerskullydazed <skullydazed@users.noreply.github.com>
Tue, 25 Sep 2018 20:28:36 +0000 (13:28 -0700)
docs/feature_audio.md
quantum/audio/audio.c
quantum/process_keycode/process_clicky.c
users/drashna/drashna.c
users/drashna/drashna.h

index 039c62cdf16b2b99b8c365f45342a1b3692d6998..fe210c09b95cfcf1a97c34f05e052ab47572383f 100644 (file)
@@ -128,13 +128,11 @@ This adds a click sound each time you hit a button, to simulate click sounds fro
 * `CK_UP` - Increases the frequency of the clicks
 * `CK_DOWN` - Decreases the frequency of the clicks
 
+
 The feature is disabled by default, to save space.  To enable it, add this to your `config.h`:
 
     #define AUDIO_CLICKY
 
-Additionally, 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`:
-
-    #define AUDIO_CLICKY_ON
 
 You can configure the default, min and max frequencies, the stepping and built in randomness by defining these values: 
 
index c948a60d6cfced46b2369372416b025beb32361d..6d6833ec11f178dc1ec1a98fc68b76b4bb2b0390 100644 (file)
@@ -223,7 +223,7 @@ void audio_init()
             TCCR1B = (1 << WGM13)  | (1 << WGM12)  | (0 << CS12)  | (1 << CS11) | (0 << CS10);
             TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER));
             TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre);
-        #endif 
+        #endif
 
         audio_initialized = true;
     }
@@ -231,7 +231,7 @@ void audio_init()
     if (audio_config.enable) {
         PLAY_SONG(startup_song);
     }
-    
+
 }
 
 void stop_all_notes()
@@ -464,7 +464,7 @@ ISR(TIMER3_AUDIO_vect)
         note_position++;
         bool end_of_note = false;
         if (TIMER_3_PERIOD > 0) {
-            if (!note_resting) 
+            if (!note_resting)
                 end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF - 1));
             else
                 end_of_note = (note_position >= (note_length));
@@ -604,7 +604,7 @@ ISR(TIMER1_AUDIO_vect)
         note_position++;
         bool end_of_note = false;
         if (TIMER_1_PERIOD > 0) {
-            if (!note_resting) 
+            if (!note_resting)
                 end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1));
             else
                 end_of_note = (note_position >= (note_length));
index 1e950d111377c40957c0af84449944b1f210ec63..bd2f1b3b37b2f37374e4b00f08c6a574ce538150 100644 (file)
@@ -3,11 +3,6 @@
 
 #ifdef AUDIO_CLICKY
 
-#ifdef AUDIO_CLICKY_ON
-bool clicky_enable = true;
-#else // AUDIO_CLICKY_ON
-bool clicky_enable = false;
-#endif // AUDIO_CLICKY_ON
 #ifndef AUDIO_CLICKY_FREQ_DEFAULT
 #define AUDIO_CLICKY_FREQ_DEFAULT 440.0f
 #endif // !AUDIO_CLICKY_FREQ_DEFAULT
@@ -27,6 +22,8 @@ bool clicky_enable = false;
 float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
 float clicky_song[][2]  = {{AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations
 
+extern audio_config_t audio_config;
+
 #ifndef NO_MUSIC_MODE
 extern bool music_activated;
 extern bool midi_activated;
@@ -42,7 +39,10 @@ void clicky_play(void) {
 }
 
 bool process_clicky(uint16_t keycode, keyrecord_t *record) {
-    if (keycode == CLICKY_TOGGLE && record->event.pressed) { clicky_enable = !clicky_enable; }
+    if (keycode == CLICKY_TOGGLE && record->event.pressed) {
+      audio_config.clicky ^= 1;
+      eeconfig_update_audio(audio_config.raw);
+    }
 
     if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; }
 
@@ -60,7 +60,7 @@ bool process_clicky(uint16_t keycode, keyrecord_t *record) {
     }
 
 
-    if ( clicky_enable ) {
+    if ( audio_config.clicky ) {
       if (record->event.pressed) {
         clicky_play();;
       }
index 20df2f4de6c86562582c5a4b4deaf7ed565785a5..7bb272a267371a7979af496228cb67a874d6ed3f 100644 (file)
@@ -133,9 +133,6 @@ void led_set_keymap(uint8_t usb_led) {}
 void matrix_init_user(void) {
   userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE);
 
-#ifdef AUDIO_CLICKY
-  clicky_enable = userspace_config.clicky_enable;
-#endif
 
 #ifdef BOOTLOADER_CATERINA
   DDRD &= ~(1<<5);
@@ -145,7 +142,6 @@ void matrix_init_user(void) {
   PORTB &= ~(1<<0);
 #endif
 
-
 #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
        set_unicode_input_mode(UC_WINC);
 #endif //UNICODE_ENABLE
@@ -338,11 +334,27 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
     return false; break;
 
 
-  case CLICKY_TOGGLE:
-#ifdef AUDIO_CLICKY
-    userspace_config.clicky_enable = clicky_enable;
-    eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw);
+  case KC_CCCV:                                    // One key copy/paste
+    if(record->event.pressed){
+      copy_paste_timer = timer_read();
+    } else {
+      if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) {   // Hold, copy
+        register_code(KC_LCTL);
+        tap(KC_C);
+        unregister_code(KC_LCTL);
+#ifdef AUDIO_ENABLE
+        PLAY_SONG(tone_copy);
+#endif
+      } else {                                // Tap, paste
+        register_code(KC_LCTL);
+        tap(KC_V);
+        unregister_code(KC_LCTL);
+#ifdef AUDIO_ENABLE
+        PLAY_SONG(tone_paste);
 #endif
+      }
+    }
+    return false;
     break;
 #ifdef UNICODE_ENABLE
   case UC_FLIP: // (╯°□°)╯ ︵ ┻━┻
index dd0d1c0d7eb89f5a80b093699edda29e2603beee..de8c3ba9470afef186c4975d21be0880f79bb491 100644 (file)
@@ -49,7 +49,7 @@ enum userspace_layers {
 // RGB color codes are no longer located here anymore.  Instead, you will want to
 // head to https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h
 
-extern bool clicky_enable;
+extern bool rgb_layer_change;
 
 #ifdef RGBLIGHT_ENABLE
 void 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
 typedef union {
   uint8_t raw;
   struct {
-    bool     clicky_enable    :1;
     bool     rgb_layer_change :1;
     bool     is_overwatch     :1;
     bool     nuke_switch      :1;