Skip to content

Commit b3cd6e3

Browse files
author
Melissa LeBlanc-Williams
committed
Merge branch 'neopixel'
2 parents 8f8d345 + aef49c4 commit b3cd6e3

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

adafruit_featherwing/dotstar_featherwing.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
4848
self.rows = 6
4949
self.columns = 12
5050
self._auto_write = True
51-
self._display = dotstar.DotStar(clock, data, self.rows * self.columns,
52-
brightness=brightness, auto_write=False)
51+
self._matrix = dotstar.DotStar(clock, data, self.rows * self.columns,
52+
brightness=brightness, auto_write=False)
5353

5454
def __setitem__(self, indices, value):
5555
"""
@@ -63,7 +63,7 @@ def __setitem__(self, indices, value):
6363
a single, longer int that contains RGB values, like 0xFFFFFF
6464
brightness, if specified should be a float 0-1
6565
"""
66-
self._display[self._get_index(indices)] = value
66+
self._matrix[self._get_index(indices)] = value
6767
self._update()
6868

6969
def __getitem__(self, indices):
@@ -73,7 +73,7 @@ def __getitem__(self, indices):
7373
a slice of DotStar indexes to retrieve
7474
a single int that specifies the DotStar index
7575
"""
76-
return self._display[self._get_index(indices)]
76+
return self._matrix[self._get_index(indices)]
7777

7878
def _get_index(self, indices):
7979
"""
@@ -119,7 +119,7 @@ def fill(self, color=0):
119119
dotstar.fill() # Clear all lit DotStars
120120
121121
"""
122-
self._display.fill(color)
122+
self._matrix.fill(color)
123123
self._update()
124124

125125
def show(self):
@@ -142,7 +142,7 @@ def show(self):
142142
dotstar.show() # Update the DotStars
143143
144144
"""
145-
self._display.show()
145+
self._matrix.show()
146146

147147
def shift_right(self, rotate=False):
148148
"""
@@ -176,10 +176,10 @@ def shift_right(self, rotate=False):
176176
177177
"""
178178
for y in range(0, self.rows):
179-
last_pixel = self._display[(y + 1) * self.columns - 1] if rotate else 0
179+
last_pixel = self._matrix[(y + 1) * self.columns - 1] if rotate else 0
180180
for x in range(self.columns - 1, 0, -1):
181-
self._display[y * self.columns + x] = self._display[y * self.columns + x - 1]
182-
self._display[y * self.columns] = last_pixel
181+
self._matrix[y * self.columns + x] = self._matrix[y * self.columns + x - 1]
182+
self._matrix[y * self.columns] = last_pixel
183183
self._update()
184184

185185
def shift_left(self, rotate=False):
@@ -214,10 +214,10 @@ def shift_left(self, rotate=False):
214214
215215
"""
216216
for y in range(0, self.rows):
217-
last_pixel = self._display[y * self.columns] if rotate else 0
217+
last_pixel = self._matrix[y * self.columns] if rotate else 0
218218
for x in range(0, self.columns - 1):
219-
self._display[y * self.columns + x] = self._display[y * self.columns + x + 1]
220-
self._display[(y + 1) * self.columns - 1] = last_pixel
219+
self._matrix[y * self.columns + x] = self._matrix[y * self.columns + x + 1]
220+
self._matrix[(y + 1) * self.columns - 1] = last_pixel
221221
self._update()
222222

223223
def shift_up(self, rotate=False):
@@ -252,10 +252,10 @@ def shift_up(self, rotate=False):
252252
253253
"""
254254
for x in range(0, self.columns):
255-
last_pixel = self._display[(self.rows - 1) * self.columns + x] if rotate else 0
255+
last_pixel = self._matrix[(self.rows - 1) * self.columns + x] if rotate else 0
256256
for y in range(self.rows - 1, 0, -1):
257-
self._display[y * self.columns + x] = self._display[(y - 1) * self.columns + x]
258-
self._display[x] = last_pixel
257+
self._matrix[y * self.columns + x] = self._matrix[(y - 1) * self.columns + x]
258+
self._matrix[x] = last_pixel
259259
self._update()
260260

261261
def shift_down(self, rotate=False):
@@ -290,18 +290,18 @@ def shift_down(self, rotate=False):
290290
291291
"""
292292
for x in range(0, self.columns):
293-
last_pixel = self._display[x] if rotate else 0
293+
last_pixel = self._matrix[x] if rotate else 0
294294
for y in range(0, self.rows - 1):
295-
self._display[y * self.columns + x] = self._display[(y + 1) * self.columns + x]
296-
self._display[(self.rows - 1) * self.columns + x] = last_pixel
295+
self._matrix[y * self.columns + x] = self._matrix[(y + 1) * self.columns + x]
296+
self._matrix[(self.rows - 1) * self.columns + x] = last_pixel
297297
self._update()
298298

299299
def _update(self):
300300
"""
301301
Update the Display automatically if auto_write is set to True
302302
"""
303303
if self._auto_write:
304-
self._display.show()
304+
self._matrix.show()
305305

306306
@property
307307
def auto_write(self):
@@ -356,9 +356,9 @@ def brightness(self):
356356
dotstar.brightness = 0.3
357357
358358
"""
359-
return self._display.brightness
359+
return self._matrix.brightness
360360

361361
@brightness.setter
362362
def brightness(self, brightness):
363-
self._display.brightness = min(max(brightness, 0.0), 1.0)
363+
self._matrix.brightness = min(max(brightness, 0.0), 1.0)
364364
self._update()

0 commit comments

Comments
 (0)