aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
authorTakeshi ISHII <2170248+mtei@users.noreply.github.com>2018-06-05 00:10:39 +0900
committerDrashna Jaelre <drashna@live.com>2018-06-04 08:10:39 -0700
commit5229734647706054066c277ea348a6d25cc38095 (patch)
treeac59bd43b32548ebac576b2fddd6db86afa40f4b /quantum/rgblight.c
parentcb91320d6d8836dd13db19bd2434abe2e7cadc20 (diff)
downloadqmk_firmware-5229734647706054066c277ea348a6d25cc38095.tar.gz
qmk_firmware-5229734647706054066c277ea348a6d25cc38095.zip
Add rgblight mode 35 (R,G,B test mode) (#3114)
* add rgblight mode 35 (RGB cyclic mode) into quantum/rgblight.c * Update docs, add rgblight mode 35(RGB cyclic) * rename RGBCYCLIC to RGBTEST
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index db66e735b..8b2a3cd9f 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -42,6 +42,8 @@ __attribute__ ((weak))
42const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; 42const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31};
43__attribute__ ((weak)) 43__attribute__ ((weak))
44const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; 44const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90};
45__attribute__ ((weak))
46const uint16_t RGBLED_RGBTEST_INTERVALS[] PROGMEM = {1024};
45 47
46rgblight_config_t rgblight_config; 48rgblight_config_t rgblight_config;
47 49
@@ -238,14 +240,15 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
238 #ifdef RGBLIGHT_ANIMATIONS 240 #ifdef RGBLIGHT_ANIMATIONS
239 rgblight_timer_disable(); 241 rgblight_timer_disable();
240 #endif 242 #endif
241 } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 24) { 243 } else if ((rgblight_config.mode >= 2 && rgblight_config.mode <= 24) ||
244 rgblight_config.mode == 35 ) {
242 // MODE 2-5, breathing 245 // MODE 2-5, breathing
243 // MODE 6-8, rainbow mood 246 // MODE 6-8, rainbow mood
244 // MODE 9-14, rainbow swirl 247 // MODE 9-14, rainbow swirl
245 // MODE 15-20, snake 248 // MODE 15-20, snake
246 // MODE 21-23, knight 249 // MODE 21-23, knight
247 // MODE 24, xmas 250 // MODE 24, xmas
248 // MODE 25-34, static rainbow 251 // MODE 35 RGB test
249 252
250 #ifdef RGBLIGHT_ANIMATIONS 253 #ifdef RGBLIGHT_ANIMATIONS
251 rgblight_timer_enable(); 254 rgblight_timer_enable();
@@ -579,6 +582,9 @@ void rgblight_task(void) {
579 } else if (rgblight_config.mode == 24) { 582 } else if (rgblight_config.mode == 24) {
580 // mode = 24, christmas mode 583 // mode = 24, christmas mode
581 rgblight_effect_christmas(); 584 rgblight_effect_christmas();
585 } else if (rgblight_config.mode == 35) {
586 // mode = 35, RGB test
587 rgblight_effect_rgbtest();
582 } 588 }
583 } 589 }
584} 590}
@@ -734,4 +740,30 @@ void rgblight_effect_christmas(void) {
734 rgblight_set(); 740 rgblight_set();
735} 741}
736 742
737#endif 743void rgblight_effect_rgbtest(void) {
744 static uint8_t pos = 0;
745 static uint16_t last_timer = 0;
746 static uint8_t maxval = 0;
747 uint8_t g; uint8_t r; uint8_t b;
748
749 if (timer_elapsed(last_timer) < pgm_read_word(&RGBLED_RGBTEST_INTERVALS[0])) {
750 return;
751 }
752
753 if( maxval == 0 ) {
754 LED_TYPE tmp_led;
755 sethsv(0, 255, RGBLIGHT_LIMIT_VAL, &tmp_led);
756 maxval = tmp_led.r;
757 }
758 last_timer = timer_read();
759 g = r = b = 0;
760 switch( pos ) {
761 case 0: r = maxval; break;
762 case 1: g = maxval; break;
763 case 2: b = maxval; break;
764 }
765 rgblight_setrgb(r, g, b);
766 pos = (pos + 1) % 3;
767}
768
769#endif /* RGBLIGHT_ANIMATIONS */