From 5229734647706054066c277ea348a6d25cc38095 Mon Sep 17 00:00:00 2001 From: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Date: Tue, 5 Jun 2018 00:10:39 +0900 Subject: 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 --- quantum/rgblight.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'quantum/rgblight.c') diff --git a/quantum/rgblight.c b/quantum/rgblight.c index db66e735bb..8b2a3cd9f8 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -42,6 +42,8 @@ __attribute__ ((weak)) const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; __attribute__ ((weak)) const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; +__attribute__ ((weak)) +const uint16_t RGBLED_RGBTEST_INTERVALS[] PROGMEM = {1024}; rgblight_config_t rgblight_config; @@ -238,14 +240,15 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_disable(); #endif - } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 24) { + } else if ((rgblight_config.mode >= 2 && rgblight_config.mode <= 24) || + rgblight_config.mode == 35 ) { // MODE 2-5, breathing // MODE 6-8, rainbow mood // MODE 9-14, rainbow swirl // MODE 15-20, snake // MODE 21-23, knight // MODE 24, xmas - // MODE 25-34, static rainbow + // MODE 35 RGB test #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_enable(); @@ -579,6 +582,9 @@ void rgblight_task(void) { } else if (rgblight_config.mode == 24) { // mode = 24, christmas mode rgblight_effect_christmas(); + } else if (rgblight_config.mode == 35) { + // mode = 35, RGB test + rgblight_effect_rgbtest(); } } } @@ -734,4 +740,30 @@ void rgblight_effect_christmas(void) { rgblight_set(); } -#endif +void rgblight_effect_rgbtest(void) { + static uint8_t pos = 0; + static uint16_t last_timer = 0; + static uint8_t maxval = 0; + uint8_t g; uint8_t r; uint8_t b; + + if (timer_elapsed(last_timer) < pgm_read_word(&RGBLED_RGBTEST_INTERVALS[0])) { + return; + } + + if( maxval == 0 ) { + LED_TYPE tmp_led; + sethsv(0, 255, RGBLIGHT_LIMIT_VAL, &tmp_led); + maxval = tmp_led.r; + } + last_timer = timer_read(); + g = r = b = 0; + switch( pos ) { + case 0: r = maxval; break; + case 1: g = maxval; break; + case 2: b = maxval; break; + } + rgblight_setrgb(r, g, b); + pos = (pos + 1) % 3; +} + +#endif /* RGBLIGHT_ANIMATIONS */ -- cgit v1.2.3