adafruit / Adafruit_DotStar

GNU General Public License v3.0
97 stars 58 forks source link

APA102 Brightness function could use the 5-bit brightness value instead of scaling the component values. #58

Open zackees opened 11 months ago

zackees commented 11 months ago

In the Adafruit_DotStar library that brightness is implemented via scaling down the led values, similar to the WS2812. But DotStar contains a 5-bit brightness value that if used, will preserve the color resolution. The downside is that there would only be 32 brightness levels rather than the 256.

FastLED enables something similar via the global brightness #define.

Since I just submitted a PR already for this code base, I might implement this for Adafruit myself.

The question I want to ask is whether it's important to preserve the current brightness setting. My recommendation is to replace the brightness logic with the 5-bit brightness yet present the same brightness range to the user through the API.

For example, store the brightness as a full range uint8_t but then scale down to the 5-bit brightness value and write that out with the leds during show(). This way anyone using the brightness feature would get an improvement in visual quality without having to change how they use the API.