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