From cae269b08b642b07ee06dec7120a784a3c3d7aab Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 23 Dec 2016 10:29:19 -0500 Subject: [PATCH] Christmas RGB light mode --- quantum/rgblight.c | 21 +++++++++++++++++++++ quantum/rgblight.h | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 625971e0fe..6e335a4831 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -449,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(); } } } @@ -594,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 diff --git a/quantum/rgblight.h b/quantum/rgblight.h index aa1d026e0e..ceb624692a 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h @@ -2,7 +2,7 @@ #define RGBLIGHT_H #ifdef RGBLIGHT_ANIMATIONS - #define RGBLIGHT_MODES 23 + #define RGBLIGHT_MODES 24 #else #define RGBLIGHT_MODES 1 #endif @@ -98,5 +98,6 @@ void rgblight_effect_rainbow_mood(uint8_t interval); void rgblight_effect_rainbow_swirl(uint8_t interval); void rgblight_effect_snake(uint8_t interval); void rgblight_effect_knight(uint8_t interval); +void rgblight_effect_christmas(void); #endif