]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - quantum/rgblight.c
[BASE]: Meh, Hyper now have symbols on both sides
[qmk_firmware.git] / quantum / rgblight.c
index 5623c65de71a9b00a680f4e802f67dbeb02a8fe4..b1b0f035d58d48bc53035db4655c04963d385b48 100644 (file)
@@ -42,7 +42,7 @@ void sethsv(uint16_t hue, uint8_t sat, uint8_t val, struct cRGB *led1) {
        The DIM_CURVE is used only on brightness/value and on saturation (inverted).
        This looks the most natural.
        */
-  uint8_t r, g, b;
+  uint8_t r = 0, g = 0, b = 0;
 
   val = pgm_read_byte(&DIM_CURVE[val]);
        sat = 255 - pgm_read_byte(&DIM_CURVE[255 - sat]);
@@ -146,7 +146,9 @@ void rgblight_init(void) {
        }
        eeconfig_debug_rgblight(); // display current eeprom values
 
-       rgblight_timer_init(); // setup the timer
+       #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+               rgblight_timer_init(); // setup the timer
+       #endif
 
   if (rgblight_config.enable) {
     rgblight_mode(rgblight_config.mode);
@@ -154,7 +156,7 @@ void rgblight_init(void) {
 }
 
 void rgblight_increase(void) {
-       uint8_t mode;
+       uint8_t mode = 0;
   if (rgblight_config.mode < RGBLIGHT_MODES) {
     mode = rgblight_config.mode + 1;
   }
@@ -162,7 +164,7 @@ void rgblight_increase(void) {
 }
 
 void rgblight_decrease(void) {
-       uint8_t mode;
+       uint8_t mode = 0;
   if (rgblight_config.mode > 1) { //mode will never < 1, if mode is less than 1, eeprom need to be initialized.
     mode = rgblight_config.mode-1;
   }
@@ -170,7 +172,7 @@ void rgblight_decrease(void) {
 }
 
 void rgblight_step(void) {
-       uint8_t mode;
+       uint8_t mode = 0;
   mode = rgblight_config.mode + 1;
   if (mode > RGBLIGHT_MODES) {
     mode = 1;
@@ -190,16 +192,21 @@ void rgblight_mode(uint8_t mode) {
                rgblight_config.mode = mode;
        }
   eeconfig_update_rgblight(rgblight_config.raw);
-  dprintf("rgblight mode: %u\n", rgblight_config.mode);
+  xprintf("rgblight mode: %u\n", rgblight_config.mode);
        if (rgblight_config.mode == 1) {
-               rgblight_timer_disable();
+               #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+                       rgblight_timer_disable();
+               #endif
        } else if (rgblight_config.mode >=2 && rgblight_config.mode <=23) {
                // MODE 2-5, breathing
                // MODE 6-8, rainbow mood
                // MODE 9-14, rainbow swirl
                // MODE 15-20, snake
                // MODE 21-23, knight
-               rgblight_timer_enable();
+
+               #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+                       rgblight_timer_enable();
+               #endif
        }
   rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
 }
@@ -207,11 +214,14 @@ void rgblight_mode(uint8_t mode) {
 void rgblight_toggle(void) {
   rgblight_config.enable ^= 1;
   eeconfig_update_rgblight(rgblight_config.raw);
-  dprintf("rgblight toggle: rgblight_config.enable = %u\n", rgblight_config.enable);
+  xprintf("rgblight toggle: rgblight_config.enable = %u\n", rgblight_config.enable);
        if (rgblight_config.enable) {
                rgblight_mode(rgblight_config.mode);
        } else {
-               rgblight_timer_disable();
+
+               #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+                       rgblight_timer_disable();
+               #endif
                _delay_ms(50);
                rgblight_set();
        }
@@ -300,7 +310,7 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val){
                rgblight_config.sat = sat;
                rgblight_config.val = val;
                eeconfig_update_rgblight(rgblight_config.raw);
-               dprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
+               xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
   }
 }
 
@@ -328,6 +338,9 @@ void rgblight_set(void) {
        }
 }
 
+
+#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+
 // Animation timer -- AVR Timer3
 void rgblight_timer_init(void) {
        static uint8_t rgblight_timer_is_init = 0;
@@ -503,3 +516,5 @@ void rgblight_effect_knight(uint8_t interval) {
        }
 
 }
+
+#endif
\ No newline at end of file