Skip to content

Commit 814b0af

Browse files
author
Melissa LeBlanc-Williams
committed
Added NeoPixel FeatherWing. Modified DotStar Lib.
1 parent 5349c63 commit 814b0af

11 files changed

+396
-35
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ These drivers depends on:
2626
* `Seesaw <https://github.com/adafruit/Adafruit_CircuitPython_seesaw>`_
2727
* `HT16K33 <https://github.com/adafruit/Adafruit_CircuitPython_HT16K33>`_
2828
* `DotStar <https://github.com/adafruit/Adafruit_CircuitPython_DotStar>`_
29+
* `NeoPixel <https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel>`_
2930

3031
Please ensure all dependencies are available on the CircuitPython filesystem.
3132
This is easily achieved by downloading

adafruit_featherwing/dotstar_featherwing.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
4949
self.columns = 12
5050
self._brightness = brightness
5151
self._auto_write = True
52-
self._dotstar = dotstar.DotStar(clock, data, self.rows * self.columns,
52+
self._display = dotstar.DotStar(clock, data, self.rows * self.columns,
5353
brightness=self._brightness, auto_write=False)
5454

5555
def __setitem__(self, indices, value):
@@ -64,7 +64,7 @@ def __setitem__(self, indices, value):
6464
a single, longer int that contains RGB values, like 0xFFFFFF
6565
brightness, if specified should be a float 0-1
6666
"""
67-
self._dotstar[self._get_index(indices)] = value
67+
self._display[self._get_index(indices)] = value
6868
self._update()
6969

7070
def __getitem__(self, indices):
@@ -74,7 +74,7 @@ def __getitem__(self, indices):
7474
a slice of DotStar indexes to retrieve
7575
a single int that specifies the DotStar index
7676
"""
77-
return self._dotstar[self._get_index(indices)]
77+
return self._display[self._get_index(indices)]
7878

7979
def _get_index(self, indices):
8080
"""
@@ -120,7 +120,7 @@ def fill(self, color=0):
120120
dotstar.fill() # Clear all lit DotStars
121121
122122
"""
123-
self._dotstar.fill(color)
123+
self._display.fill(color)
124124
self._update()
125125

126126
def show(self):
@@ -143,7 +143,7 @@ def show(self):
143143
dotstar.show() # Update the DotStars
144144
145145
"""
146-
self._dotstar.show()
146+
self._display.show()
147147

148148
def shift_right(self, rotate=False):
149149
"""
@@ -165,22 +165,22 @@ def shift_right(self, rotate=False):
165165
dotstar[6, 3] = (0, 255, 0)
166166
167167
# Rotate it off the screen
168-
for i in range(0, 11):
168+
for i in range(0, dotstar.columns - 1):
169169
dotstar.shift_right(True)
170170
time.sleep(.1)
171171
172172
time.sleep(1)
173173
# Shift it off the screen
174-
for i in range(0, 11):
174+
for i in range(0, dotstar.columns - 1):
175175
dotstar.shift_right()
176176
time.sleep(.1)
177177
178178
"""
179179
for y in range(0, self.rows):
180-
last_pixel = self._dotstar[(y + 1) * self.columns - 1] if rotate else 0
180+
last_pixel = self._display[(y + 1) * self.columns - 1] if rotate else 0
181181
for x in range(self.columns - 1, 0, -1):
182-
self._dotstar[y * self.columns + x] = self._dotstar[y * self.columns + x - 1]
183-
self._dotstar[y * self.columns] = last_pixel
182+
self._display[y * self.columns + x] = self._display[y * self.columns + x - 1]
183+
self._display[y * self.columns] = last_pixel
184184
self._update()
185185

186186
def shift_left(self, rotate=False):
@@ -203,22 +203,22 @@ def shift_left(self, rotate=False):
203203
dotstar[6, 3] = (0, 255, 0)
204204
205205
# Rotate it off the screen
206-
for i in range(0, 11):
206+
for i in range(0, dotstar.columns - 1):
207207
dotstar.shift_left(True)
208208
time.sleep(.1)
209209
210210
time.sleep(1)
211211
# Shift it off the screen
212-
for i in range(0, 11):
212+
for i in range(0, dotstar.columns - 1):
213213
dotstar.shift_left()
214214
time.sleep(.1)
215215
216216
"""
217217
for y in range(0, self.rows):
218-
last_pixel = self._dotstar[y * self.columns] if rotate else 0
218+
last_pixel = self._display[y * self.columns] if rotate else 0
219219
for x in range(0, self.columns - 1):
220-
self._dotstar[y * self.columns + x] = self._dotstar[y * self.columns + x + 1]
221-
self._dotstar[(y + 1) * self.columns - 1] = last_pixel
220+
self._display[y * self.columns + x] = self._display[y * self.columns + x + 1]
221+
self._display[(y + 1) * self.columns - 1] = last_pixel
222222
self._update()
223223

224224
def shift_up(self, rotate=False):
@@ -241,22 +241,22 @@ def shift_up(self, rotate=False):
241241
dotstar[6, 3] = (0, 255, 0)
242242
243243
# Rotate it off the screen
244-
for i in range(0, 5):
244+
for i in range(0, dotstar.rows - 1):
245245
dotstar.shift_up(True)
246246
time.sleep(.1)
247247
248248
time.sleep(1)
249249
# Shift it off the screen
250-
for i in range(0, 5):
250+
for i in range(0, dotstar.rows - 1):
251251
dotstar.shift_up()
252252
time.sleep(.1)
253253
254254
"""
255255
for x in range(0, self.columns):
256-
last_pixel = self._dotstar[(self.rows - 1) * self.columns + x] if rotate else 0
256+
last_pixel = self._display[(self.rows - 1) * self.columns + x] if rotate else 0
257257
for y in range(self.rows - 1, 0, -1):
258-
self._dotstar[y * self.columns + x] = self._dotstar[(y - 1) * self.columns + x]
259-
self._dotstar[x] = last_pixel
258+
self._display[y * self.columns + x] = self._display[(y - 1) * self.columns + x]
259+
self._display[x] = last_pixel
260260
self._update()
261261

262262
def shift_down(self, rotate=False):
@@ -279,30 +279,30 @@ def shift_down(self, rotate=False):
279279
dotstar[6, 3] = (0, 255, 0)
280280
281281
# Rotate it off the screen
282-
for i in range(0, 5):
282+
for i in range(0, dotstar.rows - 1):
283283
dotstar.shift_down(True)
284284
time.sleep(.1)
285285
286286
time.sleep(1)
287287
# Shift it off the screen
288-
for i in range(0, 5):
288+
for i in range(0, dotstar.rows - 1):
289289
dotstar.shift_down()
290290
time.sleep(.1)
291291
292292
"""
293293
for x in range(0, self.columns):
294-
last_pixel = self._dotstar[x] if rotate else 0
294+
last_pixel = self._display[x] if rotate else 0
295295
for y in range(0, self.rows - 1):
296-
self._dotstar[y * self.columns + x] = self._dotstar[(y + 1) * self.columns + x]
297-
self._dotstar[(self.rows - 1) * self.columns + x] = last_pixel
296+
self._display[y * self.columns + x] = self._display[(y + 1) * self.columns + x]
297+
self._display[(self.rows - 1) * self.columns + x] = last_pixel
298298
self._update()
299299

300300
def _update(self):
301301
"""
302302
Update the Display automatically if auto_write is set to True
303303
"""
304304
if self._auto_write:
305-
self._dotstar.show()
305+
self._display.show()
306306

307307
@property
308308
def auto_write(self):
@@ -357,9 +357,9 @@ def brightness(self):
357357
dotstar.brightness = 0.3
358358
359359
"""
360-
return self._dotstar.brightness
360+
return self._display.brightness
361361

362362
@brightness.setter
363363
def brightness(self, brightness):
364-
self._dotstar.brightness = min(max(brightness, 0.0), 1.0)
365-
self._update()
364+
self._display.brightness = min(max(brightness, 0.0), 1.0)
365+
self._update()

0 commit comments

Comments
 (0)