-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please!
good find! |
This will help with #8 |
@caternuson is it fixed now? |
@ladyada yep. seems like it. mpy-cross'd it and tried it out. FAIL CASE Adafruit CircuitPython 4.1.2 on 2019-12-18; Adafruit Gemma M0 with samd21e18
>>> import board
>>> import neopixel
>>> pixels = neopixel.NeoPixel(board.D1, 8, pixel_order="OMG_CUTE_KITTEH")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "neopixel.py", line 117, in __init__
File "adafruit_pypixelbuf.py", line 55, in __init__
File "adafruit_pypixelbuf.py", line 123, in parse_byteorder
ValueError: Invalid Byteorder string
>>> SUCCESS CASE Adafruit CircuitPython 4.1.2 on 2019-12-18; Adafruit Gemma M0 with samd21e18
>>> import board
>>> import neopixel
>>> pixels = neopixel.NeoPixel(board.D1, 8, pixel_order="GRBW")
>>> pixels.fill(0xADAF00)
>>> pixels.brightness = 0.2
>>> pixels[2] = 0xff0000
>>> pixels[4] = 0x00ff00
>>> pixels[6] = 0x0000ff
>>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is clever! I hadn't seen strip used in this way.
@caternuson did I merge this prematurely? I'm confused by the convo above. |
@dhalbert nah, i don't think so. approved and tested. should be fine. |
This doesn't validate internal characters because strip only trims the ends of a string. https://docs.python.org/3.8/library/stdtypes.html#str.strip So, it will fail for "RXB". You could use a set comparison instead. |
Seems to work? Idea is to have nothing left after the strip. Otherwise, there's an unexpected character. >>> "RGB".strip("RGBWP") != ""
False
>>> "GRB".strip("RGBWP") != ""
False
>>> "GRBW".strip("RGBWP") != ""
False
>>> "RGBW".strip("RGBWP") != ""
False
>>> "RXB".strip("RGBWP") != ""
True |
But it's not robust the other way - if you spam it with acceptable characters: >>> "RRGBGRGBRWWRGBRPPGBR".strip("RGBWP") != ""
False |
cater, neither was the |
Doc: The outermost leading and trailing chars argument values are stripped from the string. Characters are removed from the leading end until reaching a string character that is not contained in the set of characters in chars. A similar action takes place on the trailing end. So basically it's doing a set membership. |
Ah, ok. I'm wrong. :-) Carry on. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_Pypixelbuf to 1.0.3 from 1.0.2: > build.yml: move pylint, black, and Sphinx installs to each repo; add description to 'actions-ci/install.sh' > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#6 from jepler/no-re Updating https://github.com/adafruit/Adafruit_CircuitPython_turtle to 2.0.0 from 1.1.2: > Merge pull request adafruit/Adafruit_CircuitPython_turtle#18 from Marius-450/marius_improvements > build.yml: move pylint, black, and Sphinx installs to each repo; add description to 'actions-ci/install.sh' Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Added the following libraries: Adafruit_CircuitPython_Wiznet5k
The goal of the regular expression is to test that the letters in the byteorder string are only from the set R, G, B, W, and P. This
strip()
formulation achieves the same goal.