Skip to content

Rainbow Chase animation indexes the array out of bounds #5

@fschlaef

Description

@fschlaef

Hello,

First of all, great project !
I noticed the Rainbow Chase array would almost instantly freeze on my 70 LED strip on an RPI Pico W.

The error in the console is :

Traceback (most recent call last):
  File "uPixels.py", line 90, in execute
  File "uPixels.py", line 249, in rainbowChase
  File "neopixel.py", line 1, in __setitem__
IndexError: bytearray index out of range

Turns out on line 249 and 253 of uPixels.py, the self.np[i + q] instruction indexes the array out of bounds because :

  • for i in range(0, self.np.n , 3) will generate 69 as the max value
  • for q in range(3) will generate 0, 1 and 2
  • therefore self.np[i + q] can reach 70, 71, both out of bounds

The best solution I found was to add -2 to lines 247 and 252, like so :

for i in range(0, self.np.n - 2, 3):

And then everything works !

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions