@@ -48,7 +48,7 @@ def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
48
48
self .rows = 6
49
49
self .columns = 12
50
50
self ._auto_write = True
51
- self ._dotstar = dotstar .DotStar (clock , data , self .rows * self .columns ,
51
+ self ._display = dotstar .DotStar (clock , data , self .rows * self .columns ,
52
52
brightness = brightness , auto_write = False )
53
53
54
54
def __setitem__ (self , indices , value ):
@@ -63,7 +63,7 @@ def __setitem__(self, indices, value):
63
63
a single, longer int that contains RGB values, like 0xFFFFFF
64
64
brightness, if specified should be a float 0-1
65
65
"""
66
- self ._dotstar [self ._get_index (indices )] = value
66
+ self ._display [self ._get_index (indices )] = value
67
67
self ._update ()
68
68
69
69
def __getitem__ (self , indices ):
@@ -73,7 +73,7 @@ def __getitem__(self, indices):
73
73
a slice of DotStar indexes to retrieve
74
74
a single int that specifies the DotStar index
75
75
"""
76
- return self ._dotstar [self ._get_index (indices )]
76
+ return self ._display [self ._get_index (indices )]
77
77
78
78
def _get_index (self , indices ):
79
79
"""
@@ -119,7 +119,7 @@ def fill(self, color=0):
119
119
dotstar.fill() # Clear all lit DotStars
120
120
121
121
"""
122
- self ._dotstar .fill (color )
122
+ self ._display .fill (color )
123
123
self ._update ()
124
124
125
125
def show (self ):
@@ -142,7 +142,7 @@ def show(self):
142
142
dotstar.show() # Update the DotStars
143
143
144
144
"""
145
- self ._dotstar .show ()
145
+ self ._display .show ()
146
146
147
147
def shift_right (self , rotate = False ):
148
148
"""
@@ -164,22 +164,22 @@ def shift_right(self, rotate=False):
164
164
dotstar[6, 3] = (0, 255, 0)
165
165
166
166
# Rotate it off the screen
167
- for i in range(0, 11 ):
167
+ for i in range(0, dotstar.columns - 1 ):
168
168
dotstar.shift_right(True)
169
169
time.sleep(.1)
170
170
171
171
time.sleep(1)
172
172
# Shift it off the screen
173
- for i in range(0, 11 ):
173
+ for i in range(0, dotstar.columns - 1 ):
174
174
dotstar.shift_right()
175
175
time.sleep(.1)
176
176
177
177
"""
178
178
for y in range (0 , self .rows ):
179
- last_pixel = self ._dotstar [(y + 1 ) * self .columns - 1 ] if rotate else 0
179
+ last_pixel = self ._display [(y + 1 ) * self .columns - 1 ] if rotate else 0
180
180
for x in range (self .columns - 1 , 0 , - 1 ):
181
- self ._dotstar [y * self .columns + x ] = self ._dotstar [y * self .columns + x - 1 ]
182
- self ._dotstar [y * self .columns ] = last_pixel
181
+ self ._display [y * self .columns + x ] = self ._display [y * self .columns + x - 1 ]
182
+ self ._display [y * self .columns ] = last_pixel
183
183
self ._update ()
184
184
185
185
def shift_left (self , rotate = False ):
@@ -202,22 +202,22 @@ def shift_left(self, rotate=False):
202
202
dotstar[6, 3] = (0, 255, 0)
203
203
204
204
# Rotate it off the screen
205
- for i in range(0, 11 ):
205
+ for i in range(0, dotstar.columns - 1 ):
206
206
dotstar.shift_left(True)
207
207
time.sleep(.1)
208
208
209
209
time.sleep(1)
210
210
# Shift it off the screen
211
- for i in range(0, 11 ):
211
+ for i in range(0, dotstar.columns - 1 ):
212
212
dotstar.shift_left()
213
213
time.sleep(.1)
214
214
215
215
"""
216
216
for y in range (0 , self .rows ):
217
- last_pixel = self ._dotstar [y * self .columns ] if rotate else 0
217
+ last_pixel = self ._display [y * self .columns ] if rotate else 0
218
218
for x in range (0 , self .columns - 1 ):
219
- self ._dotstar [y * self .columns + x ] = self ._dotstar [y * self .columns + x + 1 ]
220
- self ._dotstar [(y + 1 ) * self .columns - 1 ] = last_pixel
219
+ self ._display [y * self .columns + x ] = self ._display [y * self .columns + x + 1 ]
220
+ self ._display [(y + 1 ) * self .columns - 1 ] = last_pixel
221
221
self ._update ()
222
222
223
223
def shift_up (self , rotate = False ):
@@ -240,22 +240,22 @@ def shift_up(self, rotate=False):
240
240
dotstar[6, 3] = (0, 255, 0)
241
241
242
242
# Rotate it off the screen
243
- for i in range(0, 5 ):
243
+ for i in range(0, dotstar.rows - 1 ):
244
244
dotstar.shift_up(True)
245
245
time.sleep(.1)
246
246
247
247
time.sleep(1)
248
248
# Shift it off the screen
249
- for i in range(0, 5 ):
249
+ for i in range(0, dotstar.rows - 1 ):
250
250
dotstar.shift_up()
251
251
time.sleep(.1)
252
252
253
253
"""
254
254
for x in range (0 , self .columns ):
255
- last_pixel = self ._dotstar [(self .rows - 1 ) * self .columns + x ] if rotate else 0
255
+ last_pixel = self ._display [(self .rows - 1 ) * self .columns + x ] if rotate else 0
256
256
for y in range (self .rows - 1 , 0 , - 1 ):
257
- self ._dotstar [y * self .columns + x ] = self ._dotstar [(y - 1 ) * self .columns + x ]
258
- self ._dotstar [x ] = last_pixel
257
+ self ._display [y * self .columns + x ] = self ._display [(y - 1 ) * self .columns + x ]
258
+ self ._display [x ] = last_pixel
259
259
self ._update ()
260
260
261
261
def shift_down (self , rotate = False ):
@@ -278,30 +278,30 @@ def shift_down(self, rotate=False):
278
278
dotstar[6, 3] = (0, 255, 0)
279
279
280
280
# Rotate it off the screen
281
- for i in range(0, 5 ):
281
+ for i in range(0, dotstar.rows - 1 ):
282
282
dotstar.shift_down(True)
283
283
time.sleep(.1)
284
284
285
285
time.sleep(1)
286
286
# Shift it off the screen
287
- for i in range(0, 5 ):
287
+ for i in range(0, dotstar.rows - 1 ):
288
288
dotstar.shift_down()
289
289
time.sleep(.1)
290
290
291
291
"""
292
292
for x in range (0 , self .columns ):
293
- last_pixel = self ._dotstar [x ] if rotate else 0
293
+ last_pixel = self ._display [x ] if rotate else 0
294
294
for y in range (0 , self .rows - 1 ):
295
- self ._dotstar [y * self .columns + x ] = self ._dotstar [(y + 1 ) * self .columns + x ]
296
- self ._dotstar [(self .rows - 1 ) * self .columns + x ] = last_pixel
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
297
297
self ._update ()
298
298
299
299
def _update (self ):
300
300
"""
301
301
Update the Display automatically if auto_write is set to True
302
302
"""
303
303
if self ._auto_write :
304
- self ._dotstar .show ()
304
+ self ._display .show ()
305
305
306
306
@property
307
307
def auto_write (self ):
@@ -356,9 +356,9 @@ def brightness(self):
356
356
dotstar.brightness = 0.3
357
357
358
358
"""
359
- return self ._dotstar .brightness
359
+ return self ._display .brightness
360
360
361
361
@brightness .setter
362
362
def brightness (self , brightness ):
363
- self ._dotstar .brightness = min (max (brightness , 0.0 ), 1.0 )
363
+ self ._display .brightness = min (max (brightness , 0.0 ), 1.0 )
364
364
self ._update ()
0 commit comments