Hi, I have a question regarding the duty cycle (fraction of time when the

Hi, I have a question regarding the duty cycle (fraction of time when the LED is on) of LEDs in a LED strip controlled with FastSPI_LED. I would like to know if the duty cycle of LEDs increases linearly when color channel values are increased. In other words, is it correct that if leds[1].setRGB(0,0,0) then the duty cycle is 0%, if leds[1].setRGB(127,127,127) then the duty cycle is 50% and if leds[1].setRGB(255,255,255) then the duty cycle is 100% (LED always on)? I’m using the WS2801. Thank you!

To the best of my knowledge, all of the chips out there, including the one you’re using, do straight, linear, PWM with whatever values you send them. So yes, I’d expect 127 to give you 50% duty cycle.

It’s worth noting here that the human eye’s respond to light is extraordinarily NON-linear; we’re WAY more sensitive to small differences at the low end of the brightness scale than we are at the high end. You can easily see the difference between a brightness of 2 and a brightness of 3, but you can’t really see any difference between 252 and 253.

Further, in practice, 127 looks way brighter than “half” of 255.If you want “apparently linear” brightness ramping, you need to apply a ‘dimming’ function. The FastLED library offers two fast ‘dimming’ approximation functions: dim8_raw( byte i) and dim8_video( byte i). If you take whatever apparent brightness you want (eg 127, meaning “half brightness”), pass it through one of the dimming functions, and THEN set it on the LED pixel, you’ll get something closer to “apparently linear” brightness. There are other more psychometrically accurate dimming functions, but the FastLED dim8_raw and dim8_video are (1) very fast, (2) good enough for many applications, and (3) already written for you :slight_smile: .