1 /* Copyright 2016-2017 Yang Liu
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <avr/eeprom.h>
18 #include <avr/interrupt.h>
19 #include <util/delay.h>
24 #include "led_tables.h"
26 #ifndef RGBLIGHT_LIMIT_VAL
27 #define RGBLIGHT_LIMIT_VAL 255
30 #define MIN(a,b) (((a)<(b))?(a):(b))
31 #define MAX(a,b) (((a)>(b))?(a):(b))
33 __attribute__ ((weak))
34 const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
35 __attribute__ ((weak))
36 const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30};
37 __attribute__ ((weak))
38 const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20};
39 __attribute__ ((weak))
40 const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20};
41 __attribute__ ((weak))
42 const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31};
43 __attribute__ ((weak))
44 const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90};
45 __attribute__ ((weak))
46 const uint16_t RGBLED_RGBCYCLIC_INTERVALS[] PROGMEM = {1024};
48 rgblight_config_t rgblight_config;
50 LED_TYPE led[RGBLED_NUM];
51 uint8_t rgblight_inited = 0;
52 bool rgblight_timer_enabled = false;
54 void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
55 uint8_t r = 0, g = 0, b = 0, base, color;
57 if (val > RGBLIGHT_LIMIT_VAL) {
58 val=RGBLIGHT_LIMIT_VAL; // limit the val
61 if (sat == 0) { // Acromatic color (gray). Hue doesn't mind.
66 base = ((255 - sat) * val) >> 8;
67 color = (val - base) * (hue % 60) / 60;
102 r = pgm_read_byte(&CIE1931_CURVE[r]);
103 g = pgm_read_byte(&CIE1931_CURVE[g]);
104 b = pgm_read_byte(&CIE1931_CURVE[b]);
106 setrgb(r, g, b, led1);
109 void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) {
116 uint32_t eeconfig_read_rgblight(void) {
117 return eeprom_read_dword(EECONFIG_RGBLIGHT);
119 void eeconfig_update_rgblight(uint32_t val) {
120 eeprom_update_dword(EECONFIG_RGBLIGHT, val);
122 void eeconfig_update_rgblight_default(void) {
123 dprintf("eeconfig_update_rgblight_default\n");
124 rgblight_config.enable = 1;
125 rgblight_config.mode = 1;
126 rgblight_config.hue = 0;
127 rgblight_config.sat = 255;
128 rgblight_config.val = RGBLIGHT_LIMIT_VAL;
129 rgblight_config.speed = 0;
130 eeconfig_update_rgblight(rgblight_config.raw);
132 void eeconfig_debug_rgblight(void) {
133 dprintf("rgblight_config eprom\n");
134 dprintf("rgblight_config.enable = %d\n", rgblight_config.enable);
135 dprintf("rghlight_config.mode = %d\n", rgblight_config.mode);
136 dprintf("rgblight_config.hue = %d\n", rgblight_config.hue);
137 dprintf("rgblight_config.sat = %d\n", rgblight_config.sat);
138 dprintf("rgblight_config.val = %d\n", rgblight_config.val);
139 dprintf("rgblight_config.speed = %d\n", rgblight_config.speed);
142 void rgblight_init(void) {
143 debug_enable = 1; // Debug ON!
144 dprintf("rgblight_init called.\n");
146 dprintf("rgblight_init start!\n");
147 if (!eeconfig_is_enabled()) {
148 dprintf("rgblight_init eeconfig is not enabled.\n");
150 eeconfig_update_rgblight_default();
152 rgblight_config.raw = eeconfig_read_rgblight();
153 if (!rgblight_config.mode) {
154 dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n");
155 eeconfig_update_rgblight_default();
156 rgblight_config.raw = eeconfig_read_rgblight();
158 eeconfig_debug_rgblight(); // display current eeprom values
160 #ifdef RGBLIGHT_ANIMATIONS
161 rgblight_timer_init(); // setup the timer
164 if (rgblight_config.enable) {
165 rgblight_mode_noeeprom(rgblight_config.mode);
169 void rgblight_update_dword(uint32_t dword) {
170 rgblight_config.raw = dword;
171 eeconfig_update_rgblight(rgblight_config.raw);
172 if (rgblight_config.enable)
173 rgblight_mode(rgblight_config.mode);
175 #ifdef RGBLIGHT_ANIMATIONS
176 rgblight_timer_disable();
182 void rgblight_increase(void) {
184 if (rgblight_config.mode < RGBLIGHT_MODES) {
185 mode = rgblight_config.mode + 1;
189 void rgblight_decrease(void) {
191 // Mode will never be < 1. If it ever is, eeprom needs to be initialized.
192 if (rgblight_config.mode > 1) {
193 mode = rgblight_config.mode - 1;
197 void rgblight_step(void) {
199 mode = rgblight_config.mode + 1;
200 if (mode > RGBLIGHT_MODES) {
205 void rgblight_step_reverse(void) {
207 mode = rgblight_config.mode - 1;
209 mode = RGBLIGHT_MODES;
214 uint32_t rgblight_get_mode(void) {
215 if (!rgblight_config.enable) {
219 return rgblight_config.mode;
222 void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
223 if (!rgblight_config.enable) {
227 rgblight_config.mode = 1;
228 } else if (mode > RGBLIGHT_MODES) {
229 rgblight_config.mode = RGBLIGHT_MODES;
231 rgblight_config.mode = mode;
233 if (write_to_eeprom) {
234 eeconfig_update_rgblight(rgblight_config.raw);
235 xprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode);
237 xprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode);
239 if (rgblight_config.mode == 1) {
240 #ifdef RGBLIGHT_ANIMATIONS
241 rgblight_timer_disable();
243 } else if ((rgblight_config.mode >= 2 && rgblight_config.mode <= 24) ||
244 rgblight_config.mode == 35 ) {
245 // MODE 2-5, breathing
246 // MODE 6-8, rainbow mood
247 // MODE 9-14, rainbow swirl
249 // MODE 21-23, knight
251 // MODE 25-34, static rainbow
252 // MODE 35 RGB cyclic
254 #ifdef RGBLIGHT_ANIMATIONS
255 rgblight_timer_enable();
257 } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) {
258 // MODE 25-34, static gradient
260 #ifdef RGBLIGHT_ANIMATIONS
261 rgblight_timer_disable();
264 rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
267 void rgblight_mode(uint8_t mode) {
268 rgblight_mode_eeprom_helper(mode, true);
271 void rgblight_mode_noeeprom(uint8_t mode) {
272 rgblight_mode_eeprom_helper(mode, false);
276 void rgblight_toggle(void) {
277 xprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable);
278 if (rgblight_config.enable) {
286 void rgblight_toggle_noeeprom(void) {
287 xprintf("rgblight toggle [NOEEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable);
288 if (rgblight_config.enable) {
289 rgblight_disable_noeeprom();
292 rgblight_enable_noeeprom();
296 void rgblight_enable(void) {
297 rgblight_config.enable = 1;
298 // No need to update EEPROM here. rgblight_mode() will do that, actually
299 //eeconfig_update_rgblight(rgblight_config.raw);
300 xprintf("rgblight enable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
301 rgblight_mode(rgblight_config.mode);
304 void rgblight_enable_noeeprom(void) {
305 rgblight_config.enable = 1;
306 xprintf("rgblight enable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
307 rgblight_mode_noeeprom(rgblight_config.mode);
310 void rgblight_disable(void) {
311 rgblight_config.enable = 0;
312 eeconfig_update_rgblight(rgblight_config.raw);
313 xprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
314 #ifdef RGBLIGHT_ANIMATIONS
315 rgblight_timer_disable();
321 void rgblight_disable_noeeprom(void) {
322 rgblight_config.enable = 0;
323 xprintf("rgblight disable [noEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
324 #ifdef RGBLIGHT_ANIMATIONS
325 rgblight_timer_disable();
332 // Deals with the messy details of incrementing an integer
333 uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) {
334 int16_t new_value = value;
336 return MIN( MAX( new_value, min ), max );
339 uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) {
340 int16_t new_value = value;
342 return MIN( MAX( new_value, min ), max );
345 void rgblight_increase_hue(void) {
347 hue = (rgblight_config.hue+RGBLIGHT_HUE_STEP) % 360;
348 rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val);
350 void rgblight_decrease_hue(void) {
352 if (rgblight_config.hue-RGBLIGHT_HUE_STEP < 0) {
353 hue = (rgblight_config.hue + 360 - RGBLIGHT_HUE_STEP) % 360;
355 hue = (rgblight_config.hue - RGBLIGHT_HUE_STEP) % 360;
357 rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val);
359 void rgblight_increase_sat(void) {
361 if (rgblight_config.sat + RGBLIGHT_SAT_STEP > 255) {
364 sat = rgblight_config.sat + RGBLIGHT_SAT_STEP;
366 rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val);
368 void rgblight_decrease_sat(void) {
370 if (rgblight_config.sat - RGBLIGHT_SAT_STEP < 0) {
373 sat = rgblight_config.sat - RGBLIGHT_SAT_STEP;
375 rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val);
377 void rgblight_increase_val(void) {
379 if (rgblight_config.val + RGBLIGHT_VAL_STEP > RGBLIGHT_LIMIT_VAL) {
380 val = RGBLIGHT_LIMIT_VAL;
382 val = rgblight_config.val + RGBLIGHT_VAL_STEP;
384 rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val);
386 void rgblight_decrease_val(void) {
388 if (rgblight_config.val - RGBLIGHT_VAL_STEP < 0) {
391 val = rgblight_config.val - RGBLIGHT_VAL_STEP;
393 rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val);
395 void rgblight_increase_speed(void) {
396 rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 );
397 eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
400 void rgblight_decrease_speed(void) {
401 rgblight_config.speed = decrement( rgblight_config.speed, 1, 0, 3 );
402 eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
405 void rgblight_sethsv_noeeprom_old(uint16_t hue, uint8_t sat, uint8_t val) {
406 if (rgblight_config.enable) {
408 sethsv(hue, sat, val, &tmp_led);
409 // dprintf("rgblight set hue [MEMORY]: %u,%u,%u\n", inmem_config.hue, inmem_config.sat, inmem_config.val);
410 rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
414 void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) {
415 if (rgblight_config.enable) {
416 if (rgblight_config.mode == 1) {
419 sethsv(hue, sat, val, &tmp_led);
420 rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
422 // all LEDs in same color
423 if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) {
424 // breathing mode, ignore the change of val, use in memory value instead
425 val = rgblight_config.val;
426 } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) {
427 // rainbow mood and rainbow swirl, ignore the change of hue
428 hue = rgblight_config.hue;
429 } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) {
432 int8_t direction = ((rgblight_config.mode - 25) % 2) ? -1 : 1;
433 uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - 25) / 2]);
434 for (uint8_t i = 0; i < RGBLED_NUM; i++) {
435 _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360;
436 dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range);
437 sethsv(_hue, sat, val, (LED_TYPE *)&led[i]);
442 rgblight_config.hue = hue;
443 rgblight_config.sat = sat;
444 rgblight_config.val = val;
445 if (write_to_eeprom) {
446 eeconfig_update_rgblight(rgblight_config.raw);
447 xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
449 xprintf("rgblight set hsv [NOEEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
454 void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
455 rgblight_sethsv_eeprom_helper(hue, sat, val, true);
458 void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
459 rgblight_sethsv_eeprom_helper(hue, sat, val, false);
462 uint16_t rgblight_get_hue(void) {
463 return rgblight_config.hue;
466 uint8_t rgblight_get_sat(void) {
467 return rgblight_config.sat;
470 uint8_t rgblight_get_val(void) {
471 return rgblight_config.val;
474 void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) {
475 if (!rgblight_config.enable) { return; }
477 for (uint8_t i = 0; i < RGBLED_NUM; i++) {
485 void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) {
486 if (!rgblight_config.enable || index >= RGBLED_NUM) { return; }
494 void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) {
495 if (!rgblight_config.enable) { return; }
498 sethsv(hue, sat, val, &tmp_led);
499 rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index);
502 #ifndef RGBLIGHT_CUSTOM_DRIVER
503 void rgblight_set(void) {
504 if (rgblight_config.enable) {
506 ws2812_setleds_rgbw(led, RGBLED_NUM);
508 ws2812_setleds(led, RGBLED_NUM);
511 for (uint8_t i = 0; i < RGBLED_NUM; i++) {
517 ws2812_setleds_rgbw(led, RGBLED_NUM);
519 ws2812_setleds(led, RGBLED_NUM);
525 #ifdef RGBLIGHT_ANIMATIONS
527 // Animation timer -- AVR Timer3
528 void rgblight_timer_init(void) {
529 // static uint8_t rgblight_timer_is_init = 0;
530 // if (rgblight_timer_is_init) {
533 // rgblight_timer_is_init = 1;
534 // /* Timer 3 setup */
535 // TCCR3B = _BV(WGM32) // CTC mode OCR3A as TOP
536 // | _BV(CS30); // Clock selelct: clk/1
537 // /* Set TOP value */
538 // uint8_t sreg = SREG;
540 // OCR3AH = (RGBLED_TIMER_TOP >> 8) & 0xff;
541 // OCR3AL = RGBLED_TIMER_TOP & 0xff;
544 rgblight_timer_enabled = true;
546 void rgblight_timer_enable(void) {
547 rgblight_timer_enabled = true;
548 dprintf("TIMER3 enabled.\n");
550 void rgblight_timer_disable(void) {
551 rgblight_timer_enabled = false;
552 dprintf("TIMER3 disabled.\n");
554 void rgblight_timer_toggle(void) {
555 rgblight_timer_enabled ^= rgblight_timer_enabled;
556 dprintf("TIMER3 toggled.\n");
559 void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) {
562 rgblight_setrgb(r, g, b);
565 void rgblight_task(void) {
566 if (rgblight_timer_enabled) {
567 // mode = 1, static light, do nothing here
568 if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) {
569 // mode = 2 to 5, breathing mode
570 rgblight_effect_breathing(rgblight_config.mode - 2);
571 } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 8) {
572 // mode = 6 to 8, rainbow mood mod
573 rgblight_effect_rainbow_mood(rgblight_config.mode - 6);
574 } else if (rgblight_config.mode >= 9 && rgblight_config.mode <= 14) {
575 // mode = 9 to 14, rainbow swirl mode
576 rgblight_effect_rainbow_swirl(rgblight_config.mode - 9);
577 } else if (rgblight_config.mode >= 15 && rgblight_config.mode <= 20) {
578 // mode = 15 to 20, snake mode
579 rgblight_effect_snake(rgblight_config.mode - 15);
580 } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) {
581 // mode = 21 to 23, knight mode
582 rgblight_effect_knight(rgblight_config.mode - 21);
583 } else if (rgblight_config.mode == 24) {
584 // mode = 24, christmas mode
585 rgblight_effect_christmas();
586 } else if (rgblight_config.mode == 35) {
587 // mode = 35, RGB cyclic
588 rgblight_effect_rgbcyclic();
594 void rgblight_effect_breathing(uint8_t interval) {
595 static uint8_t pos = 0;
596 static uint16_t last_timer = 0;
599 if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_BREATHING_INTERVALS[interval])) {
602 last_timer = timer_read();
605 // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
606 val = (exp(sin((pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E));
607 rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val);
608 pos = (pos + 1) % 256;
610 void rgblight_effect_rainbow_mood(uint8_t interval) {
611 static uint16_t current_hue = 0;
612 static uint16_t last_timer = 0;
614 if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_MOOD_INTERVALS[interval])) {
617 last_timer = timer_read();
618 rgblight_sethsv_noeeprom_old(current_hue, rgblight_config.sat, rgblight_config.val);
619 current_hue = (current_hue + 1) % 360;
621 void rgblight_effect_rainbow_swirl(uint8_t interval) {
622 static uint16_t current_hue = 0;
623 static uint16_t last_timer = 0;
626 if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2])) {
629 last_timer = timer_read();
630 for (i = 0; i < RGBLED_NUM; i++) {
631 hue = (360 / RGBLED_NUM * i + current_hue) % 360;
632 sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]);
637 current_hue = (current_hue + 1) % 360;
639 if (current_hue - 1 < 0) {
642 current_hue = current_hue - 1;
646 void rgblight_effect_snake(uint8_t interval) {
647 static uint8_t pos = 0;
648 static uint16_t last_timer = 0;
651 int8_t increment = 1;
655 if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_SNAKE_INTERVALS[interval / 2])) {
658 last_timer = timer_read();
659 for (i = 0; i < RGBLED_NUM; i++) {
663 for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) {
664 k = pos + j * increment;
669 sethsv(rgblight_config.hue, rgblight_config.sat, (uint8_t)(rgblight_config.val*(RGBLIGHT_EFFECT_SNAKE_LENGTH-j)/RGBLIGHT_EFFECT_SNAKE_LENGTH), (LED_TYPE *)&led[i]);
674 if (increment == 1) {
676 pos = RGBLED_NUM - 1;
681 pos = (pos + 1) % RGBLED_NUM;
684 void rgblight_effect_knight(uint8_t interval) {
685 static uint16_t last_timer = 0;
686 if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) {
689 last_timer = timer_read();
691 static int8_t low_bound = 0;
692 static int8_t high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1;
693 static int8_t increment = 1;
696 // Set all the LEDs to 0
697 for (i = 0; i < RGBLED_NUM; i++) {
702 // Determine which LEDs should be lit up
703 for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) {
704 cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM;
706 if (i >= low_bound && i <= high_bound) {
707 sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]);
716 // Move from low_bound to high_bound changing the direction we increment each
717 // time a boundary is hit.
718 low_bound += increment;
719 high_bound += increment;
721 if (high_bound <= 0 || low_bound >= RGBLIGHT_EFFECT_KNIGHT_LED_NUM - 1) {
722 increment = -increment;
727 void rgblight_effect_christmas(void) {
728 static uint16_t current_offset = 0;
729 static uint16_t last_timer = 0;
732 if (timer_elapsed(last_timer) < RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL) {
735 last_timer = timer_read();
736 current_offset = (current_offset + 1) % 2;
737 for (i = 0; i < RGBLED_NUM; i++) {
738 hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + current_offset) % 2) * 120;
739 sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]);
744 void rgblight_effect_rgbcyclic(void) {
745 static uint8_t pos = 0;
746 static uint16_t last_timer = 0;
747 uint8_t g; uint8_t r; uint8_t b;
749 if (timer_elapsed(last_timer) < pgm_read_word(&RGBLED_RGBCYCLIC_INTERVALS[0])) {
752 last_timer = timer_read();
755 case 0: r = RGBLIGHT_LIMIT_VAL; break;
756 case 1: g = RGBLIGHT_LIMIT_VAL; break;
757 case 2: b = RGBLIGHT_LIMIT_VAL; break;
759 rgblight_setrgb(r, g, b);
763 #endif /* RGBLIGHT_ANIMATIONS */