LED-Wavepool: Smooth out hue transitions

Based largely on ToyKeeper/Kaleidoscope-LED-Wavepool#8, this smooths out the hue
transitions, so that the ripple is a nice rainbow, without oddly flashing colors
while cycling through the effect.

Thanks @bjc for the change!

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/510/head
Gergely Nagy 6 years ago
parent 0540f96562
commit e4689caf8a
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -188,14 +188,13 @@ void WavepoolEffect::update(void) {
#endif #endif
uint8_t intensity = abs(height) * 2; uint8_t intensity = abs(height) * 2;
uint8_t saturation = 0xff - intensity;
// color starts white but gets dimmer and more saturated as it fades, // color starts white but gets dimmer and more saturated as it fades,
// with hue wobbling according to height map // with hue wobbling according to height map
int16_t hue = (current_hue + height + (height >> 1)) & 0xff; int16_t hue = (current_hue + height + (height >> 1)) & 0xff;
uint8_t value = (intensity >= 128) ? 255 : intensity << 1;
cRGB color = hsvToRgb(hue, cRGB color = hsvToRgb(hue, saturation, value);
0xff - intensity,
((uint16_t)intensity) * 2);
::LEDControl.setCrgbAt(r, c, color); ::LEDControl.setCrgbAt(r, c, color);
} }

Loading…
Cancel
Save