Skip to content
This repository was archived by the owner on Apr 20, 2022. It is now read-only.

Set auto_write after brightness in init #21

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions adafruit_pypixelbuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def __init__( # pylint: disable=too-many-locals,too-many-arguments

bpp, byteorder_tuple, has_white, dotstar_mode = self.parse_byteorder(byteorder)

self.auto_write = False

effective_bpp = 4 if dotstar_mode else bpp
_bytes = effective_bpp * n
buf = bytearray(_bytes)
Expand Down Expand Up @@ -89,8 +91,6 @@ def __init__( # pylint: disable=too-many-locals,too-many-arguments
self._dotstar_mode = dotstar_mode
self._pixel_step = effective_bpp

self.auto_write = auto_write

if dotstar_mode:
self._byteorder_tuple = (
byteorder_tuple[0] + 1,
Expand All @@ -102,6 +102,8 @@ def __init__( # pylint: disable=too-many-locals,too-many-arguments
self._brightness = 1.0
self.brightness = brightness

self.auto_write = auto_write

@staticmethod
def parse_byteorder(byteorder):
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/pypixelbuf_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def _transmit(self, buffer): # pylint: disable=unused-argument
self.called = True


buf = TestBuf(20, "RGBW", 1.0, auto_write=True)
buf = TestBuf(20, "RGBW", brightness=0.5, auto_write=True)
buf[0] = (1, 2, 3)
buf[1] = (1, 2, 3, 4)
buf[2] = (2, 2, 2)
Expand Down