Dear FastLED experts, how would one go about simulating dynamics of natural light with

(Andreas Hopf) #1

Dear FastLED experts,

how would one go about simulating dynamics of natural light with an APA102C 144 LED strip and FastLED’s functions - meaning having all LEDs lit, but very slowly, sometimes nearly perceptibly, sometimes noticeably, “twinkling” in the sense that random LEDs become very slowly a bit brighter or darker, also changing colour temperature from “cold white” to “warm white” to “cold white” during the course of many hours? So, there’s two things going on at different speeds - a slow random “twinkling” and a very slow overall colour change of the entire strip.

Think sunlight passing through very slowly moving long grass, foliage or clouds during the course of the day, sometimes moving not at all, sometimes agitated quite a bit by wind.

I am using an Adafruit Metro Mini with the LED strip at the moment. I know with that I can have only 256 PWM dimming levels, but it’s first about the principle. Later, I could probably buy some IC or breakout board that provides 12 or 16 bit PWm.

Any hints regarding programming such an effect very much appreciated!

(Andrew Tuline) #2

I would:

  1. Define a palette with the colours I like.
  2. Use a noise routine.
  3. Slowly change that palette over time.
  4. Optionally change the colour temperature over time.

Maybe something like this, and slow it down:

You can get some very subtle effects with the right speed, palette and palette changes.

Edit: Also, you can apparently change colour correction/temperature on the fly:

(Andreas Hopf) #3

Thanks, Andrew, that sounds almost too easy… ; )

I have to give that a try next week when I’m near my gear again.

I guess I don’t have to define a palette, since all LEDs are supposed to have the same colour (the colour and brightness of all LED changes from morning to noon to evening). I saw your noise example on YouTube and that seems to go in the right direction, only I need to implement more “twinkle” of single LEDs and it all needs to slow by a great deal. Your example video seems to really point the way forward.

(Andreas Hopf) #4

@Andreas_Hopf With CHSV hsvval(39, 128, 1);
and fill_solid(leds, NUM_LEDS, hsvval);
I get a fairly strong red, whereas I was expecting to get a nearly zero version of the 39 hue. In contrast, using I get a gradient where the hue does not change between max and min brightness. How can one dim an LED in FastLED without having its colour change? Reason I’m asking is I wanted to begin modifying one of the “shimmer” or “glitter” examples and noticed that the dimming towards zero or “off” changes an LEDs colour.

I found this FastLED page here but there seem to be no code snippets explaining what these functions do an how they should be used.

(Andreas Hopf) #5

Any ideas related to reducing the HSV “V” changing the colour of the LED when approaching zero?
Is there some blog out there that explains how to really use those FastLED functions?


(Andreas Hopf) #6

Ok, I am getting somewhere, regarding understanding how to use a palette. The code is here since it’s not formatted well pasted here.

The question now would be how 1. one could simply desaturate a palette programmatically or even interactively and how 2. one would now get all LEDs to shimmer (dim up/down ever so slightly in a random fashion). Also, when stretched out over 1-2 hours, the 256 steps of colour change become noticeable. Is there a solution for that?

Thanks for your help!

(Andreas Hopf) #7

Another issue, in conjunction with my previous comment, is that after the last colour of the gradient is displayed, the strip becomes pink and does not stop on blue.

(Andreas Hopf) #8

So, one thing I found out via a GitHub comment on FastLed is that the paletteIndex should stop at 240 if one wants to end at the end of a palette. Going to paletteIndex 255, the last colour would then wrap around to the start of the palette, introducing an unwanted additional colour transition.

Could be good to have that pointed out in the FastLED wiki for us beginners.