Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Changing brightness is changing the RGB color #153
Still don't know if is really a bug or I didn't understood the library.
Part of a bigger project I need to modify the color of a strip and its brightness.
Setting the stip to a color ( R or G or B) and changing the brightness is fine but if I set the strip to
I am ending up in a blank strip
Set bri: 59
Please include more information. What you gave me is not enough to understand or see the problem.
NOTE: Once the internal color channel reaches zero, it will always be zero. So you can never expect to set brightness to zero and then brightness to 100 and expect anything other than black. Dimming this way is a destructive operation (original color is lost).
The only way to retain the original color and do dimming is to use the linear blend method on the color; blend between the color and black by the amount you want and then set all the pixels to that color.
I did some analysis of the code (the brightness feature is Adafruit's code ported, to remain compatible with them).
This is why I originally didn't include it at all, its flawed.
The best approach is like I stated, keep the original values, calling the RgbColor.LinearBlend() to blend to black, passing a "dim" value of 1.0 (full brightness) to 0.0 (full dim) and then pass the results to the SetPixelColor.