Skip to content

Commit fe5f385

Browse files
mcscopemattytrentini
authored andcommitted
polish
1 parent 77aaef9 commit fe5f385

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

adafruit_dotstar.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,16 @@ def _set_item(self, index, value):
159159
if isinstance(value, int):
160160
rgb = (value >> 16, (value >> 8) & 0xff, value & 0xff)
161161

162-
offset = index * 4 + START_HEADER_SIZE
163-
rgb = value
164-
165162
if len(value) == 4:
166163
brightness = value[-1]
167164
rgb = value[:3]
168165
else:
169-
brightness = 100
166+
brightness = 1
170167

171-
brightness_byte = math.ceil(brightness * 31) & 0b00011111
172168
# LED startframe is three "1" bits, followed by 5 brightness bits
173169
# then 8 bits for each of R, G, and B. The order of those 3 are configurable and
174170
# vary based on hardware
171+
brightness_byte = math.ceil(brightness * 31) & 0b00011111
175172
self._buf[offset] = brightness_byte | LED_START
176173
self._buf[offset + 1] = int(rgb[self.pixel_order[0]])
177174
self._buf[offset + 2] = int(rgb[self.pixel_order[1]])

0 commit comments

Comments
 (0)