rpi-ws281x / rpi-ws281x-python

Python library wrapping for the rpi-ws281x library
BSD 2-Clause "Simplified" License
326 stars 103 forks source link

Error in Example multistrandtest.py using PWM0 + PWM1 #66

Closed weiserhei closed 3 years ago

weiserhei commented 3 years ago

Hello,

I try to run multistrandtest.py on a Pi, trying to use both PWM Channels. The Error that comes up:

Press Ctrl-C to quit.
Traceback (most recent call last):
  File "multistrandtest.py", line 84, in <module>
    multiColorWipe(Color(255, 255, 0), Color(0, 255, 255))  # Composite White wipe
  File "multistrandtest.py", line 41, in multiColorWipe
    strip2.setPixelColor(i / 2, color2)
  File "/usr/local/lib/python3.7/dist-packages/rpi_ws281x/rpi_ws281x.py", line 144, in setPixelColor
    self._led_data[n] = color
  File "/usr/local/lib/python3.7/dist-packages/rpi_ws281x/rpi_ws281x.py", line 55, in __setitem__
    return ws.ws2811_led_set(self.channel, pos, value)
TypeError: in method 'ws2811_led_set', argument 2 of type 'int'

When looking at this second argument pos I can see its going crazy on the second Loop (8 pixel lenght):

``` 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 0.5 2 3 1.5 ```

The example is passing a float as position on this line: https://github.com/rpi-ws281x/rpi-ws281x-python/blob/master/examples/multistrandtest.py#L39 I guess the intent was to adjust for different lengths of strips? For me its just crashing, no matter the lengths are equal or not. A quick fix would be a int typecast.