aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 1b5076450..5ae6e69d6 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -22,7 +22,6 @@
22#include "debug.h" 22#include "debug.h"
23#include "led_tables.h" 23#include "led_tables.h"
24 24
25
26__attribute__ ((weak)) 25__attribute__ ((weak))
27const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; 26const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
28__attribute__ ((weak)) 27__attribute__ ((weak))
@@ -32,7 +31,7 @@ const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20};
32__attribute__ ((weak)) 31__attribute__ ((weak))
33const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; 32const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20};
34__attribute__ ((weak)) 33__attribute__ ((weak))
35const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; 34const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31};
36__attribute__ ((weak)) 35__attribute__ ((weak))
37const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; 36const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90};
38 37
@@ -197,6 +196,14 @@ void rgblight_step_reverse(void) {
197 rgblight_mode(mode); 196 rgblight_mode(mode);
198} 197}
199 198
199uint32_t rgblight_get_mode(void) {
200 if (!rgblight_config.enable) {
201 return false;
202 }
203
204 return rgblight_config.mode;
205}
206
200void rgblight_mode(uint8_t mode) { 207void rgblight_mode(uint8_t mode) {
201 if (!rgblight_config.enable) { 208 if (!rgblight_config.enable) {
202 return; 209 return;
@@ -220,6 +227,8 @@ void rgblight_mode(uint8_t mode) {
220 // MODE 9-14, rainbow swirl 227 // MODE 9-14, rainbow swirl
221 // MODE 15-20, snake 228 // MODE 15-20, snake
222 // MODE 21-23, knight 229 // MODE 21-23, knight
230 // MODE 24, xmas
231 // MODE 25-34, static rainbow
223 232
224 #ifdef RGBLIGHT_ANIMATIONS 233 #ifdef RGBLIGHT_ANIMATIONS
225 rgblight_timer_enable(); 234 rgblight_timer_enable();
@@ -550,7 +559,14 @@ void rgblight_effect_knight(uint8_t interval) {
550 static int8_t increment = 1; 559 static int8_t increment = 1;
551 uint8_t i, cur; 560 uint8_t i, cur;
552 561
562 // Set all the LEDs to 0
553 for (i = 0; i < RGBLED_NUM; i++) { 563 for (i = 0; i < RGBLED_NUM; i++) {
564 led[i].r = 0;
565 led[i].g = 0;
566 led[i].b = 0;
567 }
568 // Determine which LEDs should be lit up
569 for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) {
554 cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM; 570 cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM;
555 571
556 if (i >= low_bound && i <= high_bound) { 572 if (i >= low_bound && i <= high_bound) {
@@ -563,10 +579,12 @@ void rgblight_effect_knight(uint8_t interval) {
563 } 579 }
564 rgblight_set(); 580 rgblight_set();
565 581
582 // Move from low_bound to high_bound changing the direction we increment each
583 // time a boundary is hit.
566 low_bound += increment; 584 low_bound += increment;
567 high_bound += increment; 585 high_bound += increment;
568 586
569 if (high_bound <= 0 || low_bound >= RGBLED_NUM - 1) { 587 if (high_bound <= 0 || low_bound >= RGBLIGHT_EFFECT_KNIGHT_LED_NUM - 1) {
570 increment = -increment; 588 increment = -increment;
571 } 589 }
572} 590}