Hi there -Have created a basic led lamp using strings of ws2812 and the fastled libray.
What I would like to do this change the colours over an hour period.
Reading up on think the best way to go about this is the blend command. I understand that blend is CRGB currentColor = blend(colorStart, colorTarget, blendAmount);.
Just can’t work out how to do work blendAmount over an hour period.
Your ideas about millisCounter and the millis() function will help you answer @alto777’s question in post #1:“How are you planning to know that time is passing?”
Thanks was planning to use the command every_n_seconds, to advade colour, use an rtc to get start time from. Look at a colour array. Hope that makes sense.
Does it mean that the ransition time from fully RED to fully Green will be over 1 hour? How long a particular blend will last -- 1 or 2 ms? Is the blending be on two colors (RG/GR or RB/BR or GB/BG) or on three colors (RGB)?
Use proportions... If one color (r or g or b) has 50 steps to change to the next color, and another color (r or g or b) has 200 steps, then the first color will take 50/200 (1/4) step and the second color will take 1 step.
I made this synchronized color changer for a dancer wearing a WS2812 dress. It is a little hard to understand, but it has utility functions that try to show how it is working. If fades from one color to the next, proportionally (not HSV, just RGB).
Or, see "crossfade" function in this sketch... might be easier to understand...
My map2colour library could be useful way to mapping the seconds of the day to a color.
Depending on the array of colors you define, conversions are smooth, stable or “jumping”.
One defines 2 arrays, the first array holds values and the second holds the matching colors. These are the reference points and between those there is interpolation.
You might define one color for every hour, however the points do not need to be equidistant, so you can define e.g. (22:00 - 06:00) as a single color. The number of points is given in the constructor.
Your program could change the color array every weekday or weekend or depending on the temperature outside or whatever sensor. Postprocessing of the color generated is of course possible e.g. change brightness.
has the source and destination colors, and uses blenbAmount to add some of one color to some of the other. At 0, it's all colorStart, at 255 it's all colorTarget. In between are, um, in between colors.
When you know the time in minutes, you can calculate the blendAmount. Just a number.
I'm sure it means something to you, and I can imagine what.
It is not, however, anything like C code.
map() isn't magic, it operates on integers and will only do the kind of thing I did with it, take a range of one set (time in minutes up to 60) and a range of an output (0 .. 255) to get that number that is how far along the color change you want to be at that time.
Thanks - Thought it was needed to work out the difference between the colours - so it was a small change ( eg 250, 240, 230 to 240,230,220) the range would not as smaller than ( 250,240,230, to 10,5,5), hope that makes sense to you as it make some sense to me !….?
Just your end points, which are CRGB colours, and where you are 0 .. 255 going from the first to the second.
It has no idea where you are coming up with the blend amount argument. The time changing nature of blendAmount is used to determine the color the strip should be now.
In a two-color FastLED blending experiment (from fully Red to fully Green), suppose the current blendAmount is 35 and the blendDuration is 60 seconds. My questions are:
1. What percentage of Green and what percentage of Red are mixed together at this blend value?
2. How long will this particular blended color be displayed before going with the next blendAmount?