mirror of
https://github.com/Makuna/NeoPixelBus.git
synced 2025-08-09 22:04:27 +02:00
Created FAQ #9 (markdown)
11
FAQ-#9.md
Normal file
11
FAQ-#9.md
Normal file
@@ -0,0 +1,11 @@
|
||||
### Other libraries have a method to dim all the pixels with one call. Is there a way to do this?
|
||||
There is not a method that will "darken all" in one call.
|
||||
|
||||
It can be simply implemented by iterating over all pixels, get the pixel color, call `Darken()` on it, and then set the pixel with the new color.
|
||||
|
||||
But, what you really want is to animate it dimming and not just "blink" to the dimmed color. The best way to do that is to remember the original color, calculate the target "dimmed" color, start an animation, and lerp between the original and target in the animation update callback. The tricky part is that you may want to apply gamma correction to the color values. Applying gamma to an iterative approach of read the last color, dim it a little, and set it back does not work correctly. But Lerp-ing between two gamma corrected values or applying gamma correction after a lerp does work. So its important to remember the original, and lerp between it and the target on every iteration.
|
||||
|
||||
The NeoPixelBus can not manage animations, this is the job of your sketch. So exposing the "darken all" method would confuse how to best do this work; so it was specifically left out of the API.
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user