Closed eddiewebb closed 4 years ago
Not sure why the list/tuple change. But change in value is from https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/blob/master/neopixel.py#L232 which multiplies by brightness.
Can you post full code so we can also see how you initialized the NeoPixel object.
What version of the library are you using?
@caternuson, the code is in a public repo. You can see where I define colors as tuples https://github.com/eddiewebb/sense-show/blob/master/led_strip.py#L22
And where I basically want to say "if the pixel is not already set to X, set it to Y". That call returns the color as a list. https://github.com/eddiewebb/sense-show/blob/master/led_strip.py#L133
@tannewt 4.1.0
sudo pip3 freeze | grep neopixel
adafruit-circuitpython-neopixel==4.1.0
You can see I've worked around the tuple/list issue by converting the response from neopixel. https://github.com/eddiewebb/sense-show/blob/master/led_strip.py#L138
now = self.pixels[id]
if isinstance(now, list):
now = tuple(int(i*(1/brightness)) for i in now)
I think you might be hitting this: https://github.com/adafruit/Adafruit_CircuitPython_Pypixelbuf/pull/4#discussion_r368309515 which should be fixed in latest release. Try updating to the 5.0.0 release and see if the problem persists: https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/releases/tag/5.0.0 Return may still be a list, but hopefully will not have the incorrect value.
This issue is resolved.
>>> import board
>>> import neopixel
>>> pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, auto_write=False, brightness=0.5)
>>> red = (80, 0, 0)
>>> pixels[1] = red
>>> print(pixels[1])
(80, 0, 0)
On version 4.1.0
color values passed as tuples
(r,g,b)
are returned as `[brightnessr,brightnessb,brightness*c]Prints
[40,0,0]