Closed Viicos closed 1 year ago
Almost feels like PixelStrip should just subclass _LED_Data
which would solve this pretty handily?
So we could use indexing/slicing on PixelStrip
directly?
Exactly, I think that makes sense?
Yes, I'll see what I can do, hoping it will be possible without having to change the current API (e.g. setPixelColor
and some others might be deprecated then).
As of today, the only possible way (at least to my knowledge) to set multiple pixel colors is by using a for loop:
What
setPixelColor
is actually doing is:I see that
_LED_Data
supports slicing:https://github.com/rpi-ws281x/rpi-ws281x-python/blob/3f7f031b8a87f584fcef72225b7cfb1cff682316/library/rpi_ws281x/rpi_ws281x.py#L47-L51
But it only works this way:
I think it would be better to have slicing working the intended way, e.g.
self._led_data[start:end] = color
, and have a newsetPixelsColor
method to do so, and the current behaviour could be reproduced with a new method as well, likesetPixelsColorMap
or something.@Gadgetoid if you are busy, I'll be happy to make a PR if you think this is a good idea.