esp8266/modules/neopixel.py: Add timing param to NeoPixel constructor.

This matches the esp32 port.
This commit is contained in:
Christopher Tse 2021-01-26 03:28:20 -06:00 committed by Damien George
parent 993ab6aa2c
commit 5c37e76e4f

View File

@ -7,12 +7,13 @@ from esp import neopixel_write
class NeoPixel: class NeoPixel:
ORDER = (1, 0, 2, 3) ORDER = (1, 0, 2, 3)
def __init__(self, pin, n, bpp=3): def __init__(self, pin, n, bpp=3, timing=1):
self.pin = pin self.pin = pin
self.n = n self.n = n
self.bpp = bpp self.bpp = bpp
self.buf = bytearray(n * bpp) self.buf = bytearray(n * bpp)
self.pin.init(pin.OUT) self.pin.init(pin.OUT)
self.timing = timing
def __setitem__(self, index, val): def __setitem__(self, index, val):
offset = index * self.bpp offset = index * self.bpp
@ -28,4 +29,4 @@ class NeoPixel:
self[i] = color self[i] = color
def write(self): def write(self):
neopixel_write(self.pin, self.buf, True) neopixel_write(self.pin, self.buf, self.timing)