blaz-r / pi_pico_neopixel

Pi Pico library for NeoPixel led-strip written in MicroPython. Works with ws2812b (RGB) and sk6812 (RGBW).
MIT License
254 stars 54 forks source link

Multiple outputs #8

Closed tloose closed 1 year ago

tloose commented 2 years ago

I'm interested in running 3 or 4 PIO channels at the same time driving WS2812 chains. I have seen the article about using one PIO and a shift register to drive up to 8 chains; I'd prefer to avoid the extra hardware and code to 'slice' the LED data. Has anyone run multiple PIOs to drive individual I/O pins?

Lemcott commented 2 years ago

https://github.com/adafruit/Adafruit_Blinka/issues/103#issuecomment-750945101

Seems the pico has a fundamental issue when it comes to controlling two separate PWM signals at once, which means multiple strips will require the PIO. I'd love for that to be wrong though...

blaz-r commented 2 years ago

So, I'm not entirely sure if I understand this right, but you can use different PIOs to achieve this. Just make two objects, each for separate PIO, for example:

strip = Neopixel(num_leds=29, state_machine=0, pin=0, mode="RGBW")
strip2 = Neopixel(num_leds=60, state_machine=1, pin=1, mode="GRB")

Where you specify different PIO IDs "state_machine" and output pin (you can of course do same without using parameter names, they are just added for more clarity). Above example enables you to have separate strips on pin 0 and 1, each having its own memory for colors and dedicated PIO.

Hope this helps :)

ShadowGamer3 commented 1 year ago

I've tried initializing multiple strips in one script before, but I've had no luck. It keeps giving me a RuntimeError saying "Raspberry Pi neopixel support is for one strip only!" The only workaround I've been able to get to to work so far is to have two different scripts, each initializing and driving a different strip, then having both scripts running simultaneously, although separately. Idk why I can't control both strips in the same script, but I hope this workaround helps. I would like to see native support for multiple strips in the same script added at some point though.

blaz-r commented 1 year ago

I've tried initializing multiple strips in one script before, but I've had no luck. It keeps giving me a RuntimeError saying "Raspberry Pi neopixel support is for one strip only!" The only workaround I've been able to get to to work so far is to have two different scripts, each initializing and driving a different strip, then having both scripts running simultaneously, although separately. Idk why I can't control both strips in the same script, but I hope this workaround helps. I would like to see native support for multiple strips in the same script added at some point though.

Library in this repo (pi_pico_neopixel) does support running more strips in single script as I have said above. Judging by the error message, I think your issue is regarding Adafruit (as linked above by Lemcott), which is not part of this repository.

blaz-r commented 1 year ago

Closing due to inactivity.