Skip to content

Commit

Permalink
esp32,esp8266: Add __len__ to NeoPixel driver to support iterating.
Browse files Browse the repository at this point in the history
Signed-off-by: mishafarms <github@mishafarms.us>
  • Loading branch information
mishafarms authored and dpgeorge committed Jun 22, 2021
1 parent 2fa975c commit b3a34dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ports/esp32/modules/neopixel.py
Expand Up @@ -15,6 +15,9 @@ def __init__(self, pin, n, bpp=3, timing=1):
self.pin.init(pin.OUT)
self.timing = timing

def __len__(self):
return self.n

def __setitem__(self, index, val):
offset = index * self.bpp
for i in range(self.bpp):
Expand Down
3 changes: 3 additions & 0 deletions ports/esp8266/modules/neopixel.py
Expand Up @@ -15,6 +15,9 @@ def __init__(self, pin, n, bpp=3, timing=1):
self.pin.init(pin.OUT)
self.timing = timing

def __len__(self):
return self.n

def __setitem__(self, index, val):
offset = index * self.bpp
for i in range(self.bpp):
Expand Down

0 comments on commit b3a34dd

Please sign in to comment.