Skip to content

Added NeoPixel FeatherWing #25

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 17 commits into from
Feb 12, 2019
Merged
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ These drivers depends on:
* `Seesaw <https://github.com/adafruit/Adafruit_CircuitPython_seesaw>`_
* `HT16K33 <https://github.com/adafruit/Adafruit_CircuitPython_HT16K33>`_
* `DotStar <https://github.com/adafruit/Adafruit_CircuitPython_DotStar>`_
* `NeoPixel <https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel>`_

Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
Expand Down
56 changes: 28 additions & 28 deletions adafruit_featherwing/dotstar_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
self.rows = 6
self.columns = 12
self._auto_write = True
self._dotstar = dotstar.DotStar(clock, data, self.rows * self.columns,
self._display = dotstar.DotStar(clock, data, self.rows * self.columns,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consider naming this matrix instead of display as we have a lot of display libraries within which we use that term. There are some FeatherWings with displays (or maybe only one?) and it might be a little confusing.

brightness=brightness, auto_write=False)

def __setitem__(self, indices, value):
Expand All @@ -63,7 +63,7 @@ def __setitem__(self, indices, value):
a single, longer int that contains RGB values, like 0xFFFFFF
brightness, if specified should be a float 0-1
"""
self._dotstar[self._get_index(indices)] = value
self._display[self._get_index(indices)] = value
self._update()

def __getitem__(self, indices):
Expand All @@ -73,7 +73,7 @@ def __getitem__(self, indices):
a slice of DotStar indexes to retrieve
a single int that specifies the DotStar index
"""
return self._dotstar[self._get_index(indices)]
return self._display[self._get_index(indices)]

def _get_index(self, indices):
"""
Expand Down Expand Up @@ -119,7 +119,7 @@ def fill(self, color=0):
dotstar.fill() # Clear all lit DotStars

"""
self._dotstar.fill(color)
self._display.fill(color)
self._update()

def show(self):
Expand All @@ -142,7 +142,7 @@ def show(self):
dotstar.show() # Update the DotStars

"""
self._dotstar.show()
self._display.show()

def shift_right(self, rotate=False):
"""
Expand All @@ -164,22 +164,22 @@ def shift_right(self, rotate=False):
dotstar[6, 3] = (0, 255, 0)

# Rotate it off the screen
for i in range(0, 11):
for i in range(0, dotstar.columns - 1):
dotstar.shift_right(True)
time.sleep(.1)

time.sleep(1)
# Shift it off the screen
for i in range(0, 11):
for i in range(0, dotstar.columns - 1):
dotstar.shift_right()
time.sleep(.1)

"""
for y in range(0, self.rows):
last_pixel = self._dotstar[(y + 1) * self.columns - 1] if rotate else 0
last_pixel = self._display[(y + 1) * self.columns - 1] if rotate else 0
for x in range(self.columns - 1, 0, -1):
self._dotstar[y * self.columns + x] = self._dotstar[y * self.columns + x - 1]
self._dotstar[y * self.columns] = last_pixel
self._display[y * self.columns + x] = self._display[y * self.columns + x - 1]
self._display[y * self.columns] = last_pixel
self._update()

def shift_left(self, rotate=False):
Expand All @@ -202,22 +202,22 @@ def shift_left(self, rotate=False):
dotstar[6, 3] = (0, 255, 0)

# Rotate it off the screen
for i in range(0, 11):
for i in range(0, dotstar.columns - 1):
dotstar.shift_left(True)
time.sleep(.1)

time.sleep(1)
# Shift it off the screen
for i in range(0, 11):
for i in range(0, dotstar.columns - 1):
dotstar.shift_left()
time.sleep(.1)

"""
for y in range(0, self.rows):
last_pixel = self._dotstar[y * self.columns] if rotate else 0
last_pixel = self._display[y * self.columns] if rotate else 0
for x in range(0, self.columns - 1):
self._dotstar[y * self.columns + x] = self._dotstar[y * self.columns + x + 1]
self._dotstar[(y + 1) * self.columns - 1] = last_pixel
self._display[y * self.columns + x] = self._display[y * self.columns + x + 1]
self._display[(y + 1) * self.columns - 1] = last_pixel
self._update()

def shift_up(self, rotate=False):
Expand All @@ -240,22 +240,22 @@ def shift_up(self, rotate=False):
dotstar[6, 3] = (0, 255, 0)

# Rotate it off the screen
for i in range(0, 5):
for i in range(0, dotstar.rows - 1):
dotstar.shift_up(True)
time.sleep(.1)

time.sleep(1)
# Shift it off the screen
for i in range(0, 5):
for i in range(0, dotstar.rows - 1):
dotstar.shift_up()
time.sleep(.1)

"""
for x in range(0, self.columns):
last_pixel = self._dotstar[(self.rows - 1) * self.columns + x] if rotate else 0
last_pixel = self._display[(self.rows - 1) * self.columns + x] if rotate else 0
for y in range(self.rows - 1, 0, -1):
self._dotstar[y * self.columns + x] = self._dotstar[(y - 1) * self.columns + x]
self._dotstar[x] = last_pixel
self._display[y * self.columns + x] = self._display[(y - 1) * self.columns + x]
self._display[x] = last_pixel
self._update()

def shift_down(self, rotate=False):
Expand All @@ -278,30 +278,30 @@ def shift_down(self, rotate=False):
dotstar[6, 3] = (0, 255, 0)

# Rotate it off the screen
for i in range(0, 5):
for i in range(0, dotstar.rows - 1):
dotstar.shift_down(True)
time.sleep(.1)

time.sleep(1)
# Shift it off the screen
for i in range(0, 5):
for i in range(0, dotstar.rows - 1):
dotstar.shift_down()
time.sleep(.1)

"""
for x in range(0, self.columns):
last_pixel = self._dotstar[x] if rotate else 0
last_pixel = self._display[x] if rotate else 0
for y in range(0, self.rows - 1):
self._dotstar[y * self.columns + x] = self._dotstar[(y + 1) * self.columns + x]
self._dotstar[(self.rows - 1) * self.columns + x] = last_pixel
self._display[y * self.columns + x] = self._display[(y + 1) * self.columns + x]
self._display[(self.rows - 1) * self.columns + x] = last_pixel
self._update()

def _update(self):
"""
Update the Display automatically if auto_write is set to True
"""
if self._auto_write:
self._dotstar.show()
self._display.show()

@property
def auto_write(self):
Expand Down Expand Up @@ -356,9 +356,9 @@ def brightness(self):
dotstar.brightness = 0.3

"""
return self._dotstar.brightness
return self._display.brightness

@brightness.setter
def brightness(self, brightness):
self._dotstar.brightness = min(max(brightness, 0.0), 1.0)
self._display.brightness = min(max(brightness, 0.0), 1.0)
self._update()
Loading