]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Notes Bugfix
authorIBNobody <ibnobody@gmail.com>
Mon, 18 Apr 2016 03:08:05 +0000 (22:08 -0500)
committerIBNobody <ibnobody@gmail.com>
Mon, 18 Apr 2016 03:08:05 +0000 (22:08 -0500)
keyboard/atomic/keymaps/pvc/keymap.c
quantum/audio.c

index 563519e4c0d2c639f04429298ee3cafbc9962607..f88d5117c97fbc2a58940bf02d664e2f9d81c99d 100644 (file)
@@ -302,45 +302,38 @@ void matrix_init_user(void)
 void led_set_user(uint8_t usb_led)
 {
        static uint8_t old_usb_led = 0;
-       static bool first_run = true;
 
-       // Skip first execution to avoid beeps caused by LED states being detected on power-up
-       if (!first_run)
+       if ((usb_led & (1<<USB_LED_CAPS_LOCK)) && !(old_usb_led & (1<<USB_LED_CAPS_LOCK)))
        {
-
-               if ((usb_led & (1<<USB_LED_CAPS_LOCK)) && !(old_usb_led & (1<<USB_LED_CAPS_LOCK)))
-               {
-                               // If CAPS LK LED is turning on...
-                               PLAY_NOTE_ARRAY(tone_caps_on,  false, LEGATO);
-           }
-               else if (!(usb_led & (1<<USB_LED_CAPS_LOCK)) && (old_usb_led & (1<<USB_LED_CAPS_LOCK)))
-           {
-                               // If CAPS LK LED is turning off...
-                               PLAY_NOTE_ARRAY(tone_caps_off, false, LEGATO);
-           }
-               else if ((usb_led & (1<<USB_LED_NUM_LOCK)) && !(old_usb_led & (1<<USB_LED_NUM_LOCK)))
-               {
-                               // If NUM LK LED is turning on...
-                               PLAY_NOTE_ARRAY(tone_numlk_on,  false, LEGATO);
-           }
-               else if (!(usb_led & (1<<USB_LED_NUM_LOCK)) && (old_usb_led & (1<<USB_LED_NUM_LOCK)))
-           {
-                               // If NUM LED is turning off...
-                               PLAY_NOTE_ARRAY(tone_numlk_off, false, LEGATO);
-           }
-               else if ((usb_led & (1<<USB_LED_SCROLL_LOCK)) && !(old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
-               {
-                               // If SCROLL LK LED is turning on...
-                               PLAY_NOTE_ARRAY(tone_scroll_on,  false, LEGATO);
-           }
-               else if (!(usb_led & (1<<USB_LED_SCROLL_LOCK)) && (old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
-           {
-                               // If SCROLL LED is turning off...
-                               PLAY_NOTE_ARRAY(tone_scroll_off, false, LEGATO);
-           }
-       }
+                       // If CAPS LK LED is turning on...
+                       PLAY_NOTE_ARRAY(tone_caps_on,  false, LEGATO);
+    }
+       else if (!(usb_led & (1<<USB_LED_CAPS_LOCK)) && (old_usb_led & (1<<USB_LED_CAPS_LOCK)))
+    {
+                       // If CAPS LK LED is turning off...
+                       PLAY_NOTE_ARRAY(tone_caps_off, false, LEGATO);
+    }
+       else if ((usb_led & (1<<USB_LED_NUM_LOCK)) && !(old_usb_led & (1<<USB_LED_NUM_LOCK)))
+       {
+                       // If NUM LK LED is turning on...
+                       PLAY_NOTE_ARRAY(tone_numlk_on,  false, LEGATO);
+    }
+       else if (!(usb_led & (1<<USB_LED_NUM_LOCK)) && (old_usb_led & (1<<USB_LED_NUM_LOCK)))
+    {
+                       // If NUM LED is turning off...
+                       PLAY_NOTE_ARRAY(tone_numlk_off, false, LEGATO);
+    }
+       else if ((usb_led & (1<<USB_LED_SCROLL_LOCK)) && !(old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
+       {
+                       // If SCROLL LK LED is turning on...
+                       PLAY_NOTE_ARRAY(tone_scroll_on,  false, LEGATO);
+    }
+       else if (!(usb_led & (1<<USB_LED_SCROLL_LOCK)) && (old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
+    {
+                       // If SCROLL LED is turning off...
+                       PLAY_NOTE_ARRAY(tone_scroll_off, false, LEGATO);
+    }
        old_usb_led = usb_led;
-       first_run = false;
 }
 
 
index 60236697392c24c2ae583885d91c4e55f4ee7cb5..ba85e418ed655939993e8e7f08151640351c4749 100644 (file)
@@ -351,7 +351,8 @@ void play_notes(float (*np)[][2], uint8_t n_count, bool n_repeat, float n_rest)
 
 if (audio_config.enable) {
 
-    if (note || notes)
+       // Cancel note if a note is playing
+    if (note)
         stop_all_notes();
 
     notes_pointer = np;
@@ -406,7 +407,8 @@ void play_note(double freq, int vol) {
 
 if (audio_config.enable && voices < 8) {
 
-    if (note || notes)
+    // Cancel notes if notes are playing
+    if (notes)
         stop_all_notes();
     #ifdef PWM_AUDIO
         freq = freq / SAMPLE_RATE;