micropython-ws2812
micropython-ws2812 copied to clipboard
Compatibility with standard micropython neopixel
These changes should make the library a swap in replacement for code that uses the standard MicroPython builtin neopixel library.
That is by replacing:
import neopixel
npixels = neopixel.NeoPixel(NeoPin,led_count)
with:
try:
import ws2812
npixels = ws2812.WS2812(SPI_BUS,led_count)
except:
import neopixel
npixels = neopixel.NeoPixel(NeoPin,led_count)
existing code that uses neopixels should work on boards with the builtin library or boards that don't have the neopixel library but have ws2812 neopixels connected to the MOSI pin of the SPI bus.