diff options
author | QMK Bot <hello@qmk.fm> | 2022-12-15 08:19:43 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2022-12-15 08:19:43 +0000 |
commit | 62b89f81846984c446b3ec171db3745e691bf2e1 (patch) | |
tree | bb39398951e48914c2b5903088b721207891fe17 /quantum/rgblight | |
parent | 9e29fe16e65e389a08b3affddf729d213fe84667 (diff) | |
parent | 33cc81f36efd255447b47428f3198ef3793c1d41 (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'quantum/rgblight')
-rw-r--r-- | quantum/rgblight/rgblight.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index f832854c5f..19d80e0097 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -1480,6 +1480,8 @@ void rgblight_effect_twinkle(animation_status_t *anim) { return (v * scale) >> 8; } + const uint8_t trigger = scale((uint16_t)0xFF * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY, 127 + rgblight_config.val / 2); + for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) { TwinkleState *t = &(led_twinkle_state[i]); HSV * c = &(t->hsv); @@ -1498,7 +1500,7 @@ void rgblight_effect_twinkle(animation_status_t *anim) { t->life--; uint8_t unscaled = frac(breathe_calc(frac(t->life, t->max_life)) - bottom, top - bottom); c->v = scale(rgblight_config.val, unscaled); - } else if (rand() < scale((uint16_t)RAND_MAX * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY, 127 + rgblight_config.val / 2)) { + } else if ((rand() % 0xFF) < trigger) { // This LED is off, but was randomly selected to start brightening if (random_color) { c->h = rand() % 0xFF; |