diff --git a/adafruit_pypixelbuf.py b/adafruit_pypixelbuf.py index c0d0469..3cb83e9 100644 --- a/adafruit_pypixelbuf.py +++ b/adafruit_pypixelbuf.py @@ -98,6 +98,9 @@ def __init__( # pylint: disable=too-many-locals,too-many-arguments byteorder_tuple[2] + 1, 0, ) + # Initialize the buffer with the dotstar start bytes. + for i in range(self._offset, self._bytes + self._offset, 4): + self._post_brightness_buffer[i] = DOTSTAR_LED_START_FULL_BRIGHT self._brightness = 1.0 self.brightness = brightness @@ -252,9 +255,7 @@ def _parse_color(self, value): # LED startframe is three "1" bits, followed by 5 brightness bits # then 8 bits for each of R, G, and B. The order of those 3 are configurable and # vary based on hardware - # same as math.ceil(brightness * 31) & 0b00011111 - # Idea from https://www.codeproject.com/Tips/700780/Fast-floor-ceiling-functions - w = (32 - int(32 - w * 31) & 0b00011111) | DOTSTAR_LED_START + w = (int(w * 31) & 0b00011111) | DOTSTAR_LED_START elif ( self._has_white and (isinstance(value, int) or len(value) == 3)