-
Notifications
You must be signed in to change notification settings - Fork 101
New _pixelbuf based Neopixel object does not allow updating .buf #65
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
Comments
@rhooper is this normal? |
Sigh. This is the kind of thing that I wanted to find with testing before merging to master. I feel like we rushed merging the pixelbuf changes. This is fixable but might have slight performance penalties until I make changes to _pixelbuf to allow changing the underlying bytearray. |
there's no way to really find these sorta bugs without a lot of eyeballs lookin at em :) |
Ya, no worries dude. All things considered IMHO it's better to keep up the momentum and get it out and tested more widely than sitting on it making sure it's ISO certified |
@sta-c0000 Do you ever directly manipulate |
@rhooper while it's perhaps a decent use case, it's maybe worth considering if accessing |
@siddacious I'd say that providing your own buffer is the right approach. As this breaks backward compatibility, a (deprecated) I'll post examples and a PR soon. |
@rhooper No. Subscripts work now ( pixels.buf[:3] = b'\x04\x00\x01'
TypeError: 'bytes' object does not support item assignment Would need to do (but would have your bytearray already): b = bytearray(pixels.buf)
b[:3] = b'\x04\x00\x01'
pixels.buf = b As for siddacious's comment: I imagine direct .buf access is not very common. |
I'd rather not support direct |
@sta-c0000 You're right on the bytearray (which _pixelbuf uses). The reason for the issue with assigning to You might want to work with a _pixelbuf directly if you're already mucking with Nevertheless, I'm going to submit a PR that adds the ability to pass in your own bytearray buffer(s) to NeoPixel so you can do what you're doing another way:
|
Issue was primarily discrepancy with previous NeoPixel obj noticed while testing. I don't know, but perhaps edit: in fact I'd like to close since being pointed in that direction, is faster; e.g. fast cycling (where our buf is filled bytearray): while True:
neopixel_write(pin, buf)
buf = buf[-3:] + buf[:-3]
... Thanks again! |
@sta-c0000 I think you can close the issue. |
Yes, only starting to play with the new _pixelbuf and NeoPixel functions like .fill are leaps and bounds faster, which is great. Closing, thanks! |
ref: pull request #59
Before we could update
pixels.buf
(Neopixel obj) directly, but it does not work with new_pixelbuf
basedNeopixel
.Now it returns an error:
Simple example for circuitplayground that works with current releases using old
Neopixel
object not using_pixelbuf
:Thank you.
The text was updated successfully, but these errors were encountered: