Closed jerryneedell closed 6 years ago
Would a fix be as simple as changing:
if type(value) == tuple and len(value) == self.bpp:
if self.bpp == 3:
r, g, b = value
else:
r, g, b, w = value
to
if ((type(value) == tuple) or (type(value) == list)) and len(value) == self.bpp:
if self.bpp == 3:
r, g, b = value
else:
r, g, b, w = value
Do we want list to be acceptable or force users to use tuples?
I have tested this change on a trinket_m0 with the Neopixel Jewel and it does work with the returned values from shell being type list. I'll generate pull request.
Its not my intention to force tuples on everyone.
In fact, #5 was for me to fix it. I fixed it in DotStar when I redid it but haven't done that here. I'd suggest doing it the same way that I did in DotStar where we special case int and otherwise assume its a sequence like list or tuple. https://github.com/adafruit/Adafruit_CircuitPython_DotStar/blob/master/adafruit_dotstar.py#L122
Sounds good. I’ll update it and resubmit a new pull request. I missed that it was already queued in #5.
Hello @jerryneedell, My device has 3 neopixel WS2812B RGB LEDs. I am using Pycom LoPy controller. I tried using this library I am getting an error: no module named "digitalio". I get the same error for "neopixel_write". Where can I find these libraries? Thank You.
@Djsharma07 For the Pycom LoPy are you using micropython? I don't think circuitpython runs that board unless you have ported it. digitalio and these libraries are for circutpython ( https://github.com/adafruit/circuitpython ) and are not supported under MicroPython. If you are using circuitpython, please post your code. I'll be happy to give it a try.
@jerryneedell, Thanks a lot. It works on micropython. I'd try searching library accordingly. Do you have any idea of a good library for micropython?
@Djsharma07 I thought neopixel support was included in micropython - see: https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/neopixel.html ah - that is for esp8266 - sorry - I am not familiar with LoPy
@Djsharma07 you might find this useful - I have not tried it - just found it via "google lopy neopixel" good luck! https://github.com/aureleq/wipy-lopy-WS2812
@jerryneedell , Thanks for the help. I guess the latter one link would be more useful.
This has been done.
If the input to set_item is of type list then it gets ignored in this driver. If that is intentional, then it needs to be clearly documented. In contrast, the dotstar driver will accept a tuple or a list as input - it treats anything other than an int as a tuple and seems to work ok with a list.
An example of the problem is in this code example distributed with the trinket_m0 and gemma_m0 as main.py:
The function wheel returns its value as type list - using []. This will work for the dotstar driver but the me-pixel driver ignores the input since it is neither type int nor type tuple.
Modifying the code to return type tuple - use ()for the returns make it work for both.