bb9625ba550dbe3bbd2967f488c4ee92815637f0

Author
Ryan <fauxpark@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

RGBLight: Improve RGB Test animation (#24477)

Diff

 1diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c
 2index 6426ccf2c8630a8df7b82d4d4770fe41a7b1a223..ddccc9bae36ddf964569cb2a33484643825aa7ba 100644
 3--- a/quantum/rgblight/rgblight.c
 4+++ b/quantum/rgblight/rgblight.c
 5@@ -1342,29 +1342,13 @@ void rgblight_effect_christmas(animation_status_t *anim) {
 6 __attribute__((weak)) const uint16_t RGBLED_RGBTEST_INTERVALS[] PROGMEM = {1024};
 7 
 8 void rgblight_effect_rgbtest(animation_status_t *anim) {
 9-    static uint8_t maxval = 0;
10-    uint8_t        g;
11-    uint8_t        r;
12-    uint8_t        b;
13-
14-    if (maxval == 0) {
15-        rgb_t rgb = hsv_to_rgb((hsv_t){0, 255, RGBLIGHT_LIMIT_VAL});
16-        maxval    = rgb.r;
17-    }
18-    g = r = b = 0;
19-    switch (anim->pos) {
20-        case 0:
21-            r = maxval;
22-            break;
23-        case 1:
24-            g = maxval;
25-            break;
26-        case 2:
27-            b = maxval;
28-            break;
29-    }
30+    uint8_t val = rgblight_get_val();
31+
32+    uint8_t r = anim->pos & 1 ? val : 0;
33+    uint8_t g = anim->pos & 2 ? val : 0;
34+    uint8_t b = anim->pos & 4 ? val : 0;
35     rgblight_setrgb(r, g, b);
36-    anim->pos = (anim->pos + 1) % 3;
37+    anim->pos = (anim->pos + 1) % 8;
38 }
39 #endif
40