You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 20, 2022. It is now read-only.
No, if you set the brightness to 0.0 it will be set to 0.
The rounding, is just happening because of the float needing to become a whole number (a 5 bit int for the dotstar). So in the pypixelbuf code, it really is just equivalent to a math.ceil, so 0 still yields a 0.
As an example:
User enters: 0.0 --> Multiply by 31 (5 bits): 0 --> Set brightness with: 0 (same with pixelbuf)
User enters: 0.4 --> Multiply by 31 (5 bits): 12.4 --> Set brightness with: 13 (pixelbuf would set to 12)
Either way is equally useful, really just a matter of preference!
The dotstar brightness byte is exposed to the user as a float, but then internally converted into an integer, so it needs to be rounded.
In pypixelbuf the brightness is always rounded up using an approach equivalent to
math.ceil
:Adafruit_CircuitPython_Pypixelbuf/adafruit_pypixelbuf.py
Lines 255 to 257 in e52c672
However, in pixelbuf the brightness is rounded down by truncating:
https://github.com/adafruit/circuitpython/blob/41fe62929f268bfc1f2b06be8b649409234d9d1a/shared-module/_pixelbuf/PixelBuf.c#L181-L185
If rounding down is desired I can make a pull request to correct this? Or if not, I can file an issue in CP and update pixelbuf to round up!
The text was updated successfully, but these errors were encountered: