Add support for more than one strip
See original GitHub issueWhen trying to control two WS2812 strips with AdaFruit_NeoPixel on two separate PWM GPIOs (Board.D13 and Board.D18) I get the following RuntimeError:
Error in atexit._run_exitfuncs: Traceback (most recent call last): File “na.py”, line 1287, in exit_handler led_strip.shutdown() File “na.py”, line 891, in shutdown self.color_wipe(LED.color(0, 0, 0)) File “na.py”, line 934, in color_wipe self.pixels2.show() File “/usr/local/lib/python3.5/dist-packages/neopixel.py”, line 230, in show neopixel_write(self.pin, self.buf) File “/usr/local/lib/python3.5/dist-packages/neopixel_write.py”, line 24, in neopixel_write return _neopixel.neopixel_write(gpio, buf) File “/usr/local/lib/python3.5/dist-packages/adafruit_blinka/microcontroller/bcm283x/neopixel.py”, line 70, in neopixel_write raise RuntimeError(“Raspberry Pi neopixel support is for one strip only!”) RuntimeError: Raspberry Pi neopixel support is for one strip only! swig/python detected a memory leak of type ‘ws2811_t *’, no destructor found.
Here is how I initialize:
pixels1 = neopixel.NeoPixel(
board.D18, LED.LED_COUNT, brightness=1, auto_write=False, pixel_order=neopixel.GRB)
pixels2 = neopixel.NeoPixel(
board.D13, LED.LED_COUNT, brightness=1, auto_write=False, pixel_order=neopixel.GRB)
RuntimeErrors are thrown whenever I call this:
pixels1.fill(color)
pixels1.show()
pixels2.fill(color)
pixels2.show()
Is there a reason only one strip is supported?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (6 by maintainers)
Top GitHub Comments
Ok after trying a number of different strategies, I’m concluding that it really isn’t possible. Here’s some background of what I tried: I was running into issues with NeoPixels on 2 different pins responding to the same changes. This is because there are 2 PWM channels on the Raspberry Pi that share a number of pins and both of the ones I was using are on PWM0.
The specific parameter options for this dtoverlay can be found with the following command:
So I enabled the second PWM channel using the
pwm-2chan
dtoverlay by adding the following line to my /boot/config.txtThe pin functionality can be found on page 102 of the data sheet at https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf.
I confirmed they were set in PWM output with the following command:
and got the following output:
I ran my test script and got the following error:
I did notice that after running the script, the raspi-gpio command now outputs the following:
This tells me that the rpi_ws281x library is handling changing the pin muxing already and the dtoverlay was probably not necessary. However, it just refuses to cooperate and the issue lies outside of Blinka. Also, the benefit of 1 additional strand is probably not worth it since strands can be chained together already, so I’m going to close this issue.
There seems to be a pretty big bug with the rpi_ws281x library that will write the data to both GPIOs once they have been initialized as separate strips. This happened when using multiple instances and adapting the multistrand example above. I think strategy 2 (reinitializing between each write) might be the way to go.