OctoWS2811 and fade

So, playing around with the Teensy 3.0 and using the OctoWS2811 library, I wanted to be able to play some patterns across the eight strips. I wanted to be able to use some gentle fading patterns, but was finding it difficult to get enough granularity to make the fade a gentle one when using a length of 34 leds, meaning, graduated to extent that there were no sharp changes visible. The fade seemed just fine when using a few leds. This was because I did not want the maximum brightness to be very bright, as these leds are very bright at night.

The OctoWS2811 library uses a colour making function called makeColor. This is used to convert HSL (Hue, Saturation, Lightness) to RGB (Red, Green, Blue). I found that the “lightness” element of this can be used to fade the colour up and down to an extent, so long as you don’t venture into the upper end. To get a colour to increase in intensity, just keep adding on to the lightness by one in a for loop until you get to 50.

But, this looks jagged if you do it slowly when using a delay(). so, one way around this is to add in more steps. But, the lightness value is an int, so there are no more steps, as you have to increase by one each time. It finally dawned on me to add more steps by using decimal places. You would probably have come to this conclusion a long time ago, but not me. Anyhow, the upshot is, change the unsigned int to a double, and increment the lightness value by one, but use a multiplier of 0.1 in the makeColor function, and there you go. This is just one way to do it of course

so:

int makeColor(unsigned int hue, unsigned int saturation, /*unsigned int*/ double lightness)

and then in the for loop use:

int color =makeColor(300,100,(f*0.1));//colour position/colour amount/light or dark

where f is the incremented value in the for loop.

I am not sure why this works, as I was under the impression that it was the resultant type that was the issue rather than than the types being multiplied.

hope that this is of use to you

mortonkopf