Change RGBW ORDER to be an init parameter to the NeoPixel library #9125
-
Hi everyone, First of all, thanks to everyone for the great work on the MicroPython system. It is really fantastic, and we are using it to teach STEM students computational thinking in our local CoderDojo clubs. I am a somewhat newbie, so I apologize if this is a dumb question. In the NeoPixel library, on line 9 here: https://github.com/micropython/micropython/blob/master/drivers/neopixel/neopixel.py You will note that ORDER is a constant. ORDER = (1, 0, 2, 3) In about 20% of the lights we use, the order of the R and B is reversed: ORDER = (0, 1, 2, 3) Can this be added as a parameter as we initialize the NeoPixel object? Right now, I have students create a new class and change the parameter in the new class. It is only a few lines of code and a few uploads, but these are beginning students so I am trying to keep the first labs really simple. Thanks! - Dan McCreary |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
That can of course be initiated easily by yourself by submitting a Pull Request. As a temporary change, you can as well change the order after creating a neopixel object with e.g. npx = NeoPixel(pin, pixels) with npx.ORDER = (0,1,2,3) You could use that for a short explanation about visibility and search order for names in functions and classes. |
Beta Was this translation helpful? Give feedback.
-
I would suggest @robert-hh's approach of setting ORDER, but I am curious... are you finding that strips from the same manufacturer are randomly RGBW or GRBW? Or do you have strips from lots of sources? I've never seen a neopixel or neopixel-like strip, e.g. sk6812, that was not GRBW, so interested to know where they come from. It would actually be quite useful to have RGBW strips when your data is already in that order and save the cpu time to reorder it. |
Beta Was this translation helpful? Give feedback.
That can of course be initiated easily by yourself by submitting a Pull Request. As a temporary change, you can as well change the order after creating a neopixel object with e.g.
npx = NeoPixel(pin, pixels)
with
npx.ORDER = (0,1,2,3)
You could use that for a short explanation about visibility and search order for names in functions and classes.