Motivation
- I have a RGB strip on my bed connected to ESPHome
- Set colors are boring
- Fixed patterns are predictable
- Random colors look bad
- What if I could create a random gradient that looks good?
Process
- Tried a number of things, eventually settled on a color wipe-based effect, the color is based off a drifting hue and a sorta-random saturation
- This way the light strip is different every time, and can create some awesome gradients
Result
Here’s a GIF of a timelapse of the light strip. The GIF is really low quality, hopefully it’s enough to just show that it is indeed random.
Here’s the code for the light effect:
- addressable_lambda:
name: "Chroma Haze"
update_interval: 100ms
lambda: |
static uint8_t hue = 160;
static uint16_t saturation = 255;
hue = hue - 5 + (uint16_t)(random_float() * 10);
float rand_v = random_float();
uint16_t new_saturation = 255 - (uint16_t)(rand_v * rand_v * 200);
saturation = (saturation * 7 + new_saturation) / 8;
if ((hue < 30 || hue > 225) && saturation > 200) {
saturation = (saturation * 2 + 180) / 3;
}
it.shift_right(1);
it[0] = ESPHSVColor(hue, saturation, 255);