Skip to content

added pixel_order #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 23, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions neopixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel.git"

# Pixel color order constants
RGB = (0, 1, 2)
GRB = (1, 0, 2)
RGBW = (0, 1, 2, 3)
GRBW = (1, 0, 2, 3)

class NeoPixel:
"""
A sequence of neopixels.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters here should be updated to reflect the new addition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I'll update the docs if this flies. At this point I'm wondering if this general approach is even good.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't even notice this PR was open. I just put in a PR to update the docs to the new format. Suggest waiting until that is merged to update doc info.

Expand Down Expand Up @@ -76,12 +82,18 @@ class NeoPixel:
pixels[::2] = [RED] * (len(pixels) // 2)
time.sleep(2)
"""
ORDER = (1, 0, 2, 3)
def __init__(self, pin, n, *, bpp=3, brightness=1.0, auto_write=True):
#ORDER = (1, 0, 2, 3)
def __init__(self, pin, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None):
self.pin = digitalio.DigitalInOut(pin)
self.pin.direction = digitalio.Direction.OUTPUT
self.n = n
self.bpp = bpp
#self.bpp = bpp
if pixel_order is None:
self.ORDER = GRBW
self.bpp = bpp
else:
self.ORDER = pixel_order
self.bpp = len(self.ORDER)
self.buf = bytearray(n * bpp)
# Set auto_write to False temporarily so brightness setter does _not_
# call show() while in __init__.
Expand Down