The most dim value for the EVEN led’s seems to be 16 and for the ODD led’s a value of 2. The upper limit for both is 255. The fadingcurve is not linear.
And also because the HSV to RGB conversion will attempt to (roughly) provide a non-linear curve to brightness, whereas the %= is just a straight scale8 of the rgb values. (Well, technically, scale8 video, but for the purposes here, they’re effectively the same thing).
Okay…
Here’s what I got. I came up with this RGB clock. It’s level is controlled by a LDR. It’s analog reading is mapped three times: first 50-200 being the hands(red green, blue), second 50-100 all “remaining” led’s and last 200-0 being an inverted saturation for the same “remaining” led’s. So, during the day the saturation for the remaining 57 led’s is close to zero: they go white. During the night their saturation fades to value 200 and turn blue AND dim as well. Needing to be able so set a saturation level, I have to use the CHSV object. There is no “set.Sat” like there is “set.Hue”.
@Kasper_Kamperman
If setHue controls brightness, what controls hue? This doesn’t make sense to me.
In the above code , hue stays the same throughout and the led’s behave accordingly. It’s the dimming (if I change the values simultaneously) that doesn’t run smooth. Is there a way to control both hue AND saturation in a mathematical way so I can assign a value to both separately? setHue and % do it in a nice way, but setHSV not.
I can use HSV but it doesn’t give the same output as setHue and % combined.
When using HSV, the level “kicks in” at level 16, whereas % does a better job starting at 2 (out of 255). I just made a video showing the difference. Let me see if I can upload it
My point is, that if I want to control saturation for any led, I have to use HSV. But specifying hue and % gives much better control, but no saturation control!
%= uses video_scaling (sorry, I always read modulo when I see this, so I struggled a bit to understand this part.
But according to the documentation (https://github.com/FastLED/FastLED/wiki/Pixel-reference) you’ll do this:
leds[i].nscale8_video( 192);
In the HSV2RGB conversion there isn’t any non-lineair curve applied right now (at least in the 2.1 branch) I think. I thought that this would be the case, but it’s not.
Best thing to do is to apply the non-lineair scaling to your brightness by using the dim8_video function.
So:
for(int i=0; i<60; i=i+2) leds[i].setHSV(161,255,dim8_video(brightness));
Okay, I’ll give it a try. BUT this still leaves me with the saturation part. How do I control the sat for a given led while NOT using the setHSV command? I can set the level (%=) for a specific led, I can set the hue (setHue) but not it’s saturation. How so set the saturation for any given led using a single value?
Hsv2rgb does do a non-linear curve. (V = scale8(V,V); does a quick approximation of that) - this is why there’s a difference between the two sets of code used.
Hi guys,
I took Kasper’s advice on desaturating colors and it works like charme! Now I have a nice looking curve, can control hue, sat and level in fine detail.
Thanks to Kasper and Daniel!
@Roger_M Glad I could help! Did you use dim8_raw as well?
Daniel, Mark I’m checking the hsv2rgb code. Is the non-lineair scaling only implemented in the default hsv2rgb_rainbow? Because I can’t find it in the hsv2rgb_raw (that was the one I was using and which had some strange behavior after applying a dim_curve to the rgb values).
dim8_raw it is! At least for my application. The clock runs smooth, dims well and all colors look very much alive and balanced. Color is all about math…