Closed jerryneedell closed 5 years ago
That is what I would suggest. But looking at the logic for when an int
is passed in, I'm not sure if there's some reasoning to provide automatic behavior for when RGBW pixels are used but only a RGB 3 tuple is supplied. I've added a comment in the issue thread so we can discuss there and nail down what we want to do.
updated PR to capture discussion - I hope:
>>> import board,neopixel
>>> pixels = neopixel.NeoPixel(board.NEOPIXEL, 1, pixel_order=neopixel.RGB)
>>> pixels[0] = ( 10,0,10)
>>> pixels[0] = ( 10,0,10,10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "neopixel.py", line 172, in __setitem__
File "neopixel.py", line 153, in _set_item
ValueError: Color tuple size does not match pixel_order.
>>> pixels[0] = 0xffffff
>>> pixels[0] = 0x1ffffff
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "neopixel.py", line 172, in __setitem__
File "neopixel.py", line 135, in _set_item
ValueError: only bits 0->23 valid for integer input
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-alpha.2-84-gbd79c0c0d-dirty on 2018-10-28; Adafruit Metro M4 Express with samd51j19
>>> import board,neopixel
>>> pixels = neopixel.NeoPixel(board.NEOPIXEL, 1, pixel_order=neopixel.RGBW)
>>> pixels[0] = (255,255,0)
>>> pixels[0] = (255,255,0,0)
>>> pixels[0] = 0xff0000
>>> pixels[0] = 0x1ff0000
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "neopixel.py", line 172, in __setitem__
File "neopixel.py", line 135, in _set_item
ValueError: only bits 0->23 valid for integer input
>>>
Is this what you had in mind to address #34 ?