Closed margaret closed 6 years ago
More context
setup for self._buf
is like this
:param int n: The number of dotstars in the chain
...
self._n = n
self.start_header_size = 4
# Supply one extra clock cycle for each two pixels in the strip.
self.end_header_size = n // 16
if n % 16 != 0:
self.end_header_size += 1
self._buf = bytearray(n * 4 + self.start_header_size + self.end_header_size)
so if you had one dotstar, length of self._buf
would be 1*4 + 4 + 0
and self._buf // 4
would be 2 instead of the expected 1 in
def __getitem__(self, index):
if isinstance(index, slice):
out = []
for in_i in range(*index.indices(self._n)): # used to be self._buf // 4
out.append(
tuple(self._buf[in_i * 4 + (3 - i) + self.start_header_size] for i in range(3)))
return out
Tested this manually with the pycon Gemma M0 ✅
@tannewt Ready for review
__setitem__
useslen(self)
, make this consistent with__getitem__
and useself._n
directly)