]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - quantum/rgblight.c
Keycode refactor
[qmk_firmware.git] / quantum / rgblight.c
index 00620da58ea51bdaf19be046102d36034d857dba..6e335a4831e049f61b06478919df14ef6f422a95 100644 (file)
@@ -183,6 +183,19 @@ void rgblight_init(void) {
   }
 }
 
+void rgblight_update_dword(uint32_t dword) {
+  rgblight_config.raw = dword;
+  eeconfig_update_rgblight(rgblight_config.raw);
+  if (rgblight_config.enable)
+    rgblight_mode(rgblight_config.mode);
+  else {
+    #ifdef RGBLIGHT_ANIMATIONS
+      rgblight_timer_disable();
+    #endif
+      rgblight_set();
+  }
+}
+
 void rgblight_increase(void) {
   uint8_t mode = 0;
   if (rgblight_config.mode < RGBLIGHT_MODES) {
@@ -412,6 +425,12 @@ void rgblight_timer_toggle(void) {
   dprintf("TIMER3 toggled.\n");
 }
 
+void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) {
+  rgblight_enable();
+  rgblight_mode(1);
+  rgblight_setrgb(r, g, b);
+}
+
 void rgblight_task(void) {
   if (rgblight_timer_enabled) {
     // mode = 1, static light, do nothing here
@@ -430,6 +449,9 @@ void rgblight_task(void) {
     } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) {
       // mode = 21 to 23, knight mode
       rgblight_effect_knight(rgblight_config.mode - 21);
+    } else {
+      // mode = 24, christmas mode
+      rgblight_effect_christmas();
     }
   }
 }
@@ -575,4 +597,22 @@ void rgblight_effect_knight(uint8_t interval) {
   }
 }
 
+
+void rgblight_effect_christmas(void) {
+  static uint16_t current_offset = 0;
+  static uint16_t last_timer = 0;
+  uint16_t hue;
+  uint8_t i;
+  if (timer_elapsed(last_timer) < 1000) {
+    return;
+  }
+  last_timer = timer_read();
+  current_offset = (current_offset + 1) % 2;
+  for (i = 0; i < RGBLED_NUM; i++) {
+    hue = 0 + ((RGBLED_NUM * (i + current_offset)) % 2) * 80;
+    sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]);
+  }
+  rgblight_set();
+}
+
 #endif