Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rainbow Chase animation indexes the array out of bounds #5

Open
fschlaef opened this issue Apr 6, 2024 · 1 comment
Open

Rainbow Chase animation indexes the array out of bounds #5

fschlaef opened this issue Apr 6, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@fschlaef
Copy link

fschlaef commented Apr 6, 2024

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 !

@petabite
Copy link
Owner

petabite commented Apr 7, 2024

Thanks so much for the bug report! Really appreciate it

@petabite petabite added the bug Something isn't working label Apr 7, 2024
@petabite petabite self-assigned this Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants