micropython-ws2812 icon indicating copy to clipboard operation
micropython-ws2812 copied to clipboard

Compatibility with standard micropython neopixel

Open RetiredWizard opened this issue 1 year ago • 0 comments

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.

RetiredWizard avatar Feb 05 '23 23:02 RetiredWizard