33
33
34
34
import board
35
35
import adafruit_dotstar as dotstar
36
- from adafruit_featherwing .pixelmatrix_featherwing import PixelMatrixFeatherWing
36
+ from adafruit_featherwing .pixelmatrix import PixelMatrix
37
37
38
- class DotStarFeatherWing (PixelMatrixFeatherWing ):
38
+ class DotStarFeatherWing (PixelMatrix ):
39
39
"""Class representing a `DotStar FeatherWing
40
40
<https://www.adafruit.com/product/3449>`_.
41
41
@@ -51,243 +51,3 @@ def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
51
51
self .columns = 12
52
52
self ._matrix = dotstar .DotStar (clock , data , self .rows * self .columns ,
53
53
brightness = brightness , auto_write = False )
54
-
55
- def fill (self , color = 0 ):
56
- """
57
- Fills all of the DotStars with a color or unlit if empty.
58
-
59
- :param color: (Optional) The text or number to display (default=0)
60
- :type color: list/tuple or int
61
-
62
- This example shows various ways of using the fill() function
63
-
64
- .. code-block:: python
65
-
66
- import time
67
- from adafruit_featherwing import dotstar_featherwing
68
-
69
- dotstar = dotstar_featherwing.DotStarFeatherWing()
70
- dotstar.fill((255, 255, 255)) # Fill White
71
- time.sleep(1)
72
- dotstar.fill((255, 255, 255, 0.5)) # Fill White Half Brightness
73
- time.sleep(1)
74
- dotstar.fill(0xFF0000) # Fill Red
75
- time.sleep(1)
76
- dotstar.fill() # Clear all lit DotStars
77
-
78
- """
79
- super ()._fill (color )
80
-
81
- def show (self ):
82
- """
83
- Update the DotStars. This is only needed if auto_write is set to False
84
- This can be very useful for more advanced graphics effects.
85
-
86
- This example changes the blink rate and prints out the current setting
87
-
88
- .. code-block:: python
89
-
90
- import time
91
- from adafruit_featherwing import dotstar_featherwing
92
-
93
- dotstar = dotstar_featherwing.DotStarFeatherWing()
94
- dotstar.fill() # Clear any lit Dotstars
95
- dotstar.auto_write = False
96
- dotstar[0, 0] = (255, 255, 255) # Set White
97
- time.sleep(1)
98
- dotstar.show() # Update the DotStars
99
-
100
- """
101
- super ()._show ()
102
-
103
- def shift_right (self , rotate = False ):
104
- """
105
- Shift all pixels right
106
-
107
- :param rotate: (Optional) Rotate the shifted pixels to the left side (default=False)
108
-
109
- This example shifts 2 pixels to the right
110
-
111
- .. code-block:: python
112
-
113
- import time
114
- from adafruit_featherwing import dotstar_featherwing
115
-
116
- dotstar = dotstar_featherwing.DotStarFeatherWing()
117
-
118
- # Draw Red and Green Pixels
119
- dotstar[5, 3] = (255, 0, 0)
120
- dotstar[6, 3] = (0, 255, 0)
121
-
122
- # Rotate it off the screen
123
- for i in range(0, dotstar.columns - 1):
124
- dotstar.shift_right(True)
125
- time.sleep(.1)
126
-
127
- time.sleep(1)
128
- # Shift it off the screen
129
- for i in range(0, dotstar.columns - 1):
130
- dotstar.shift_right()
131
- time.sleep(.1)
132
-
133
- """
134
- super ()._shift_right (rotate )
135
-
136
- def shift_left (self , rotate = False ):
137
- """
138
- Shift all pixels left
139
-
140
- :param rotate: (Optional) Rotate the shifted pixels to the right side (default=False)
141
-
142
- This example shifts 2 pixels to the left
143
-
144
- .. code-block:: python
145
-
146
- import time
147
- from adafruit_featherwing import dotstar_featherwing
148
-
149
- dotstar = dotstar_featherwing.DotStarFeatherWing()
150
-
151
- # Draw Red and Green Pixels
152
- dotstar[5, 3] = (255, 0, 0)
153
- dotstar[6, 3] = (0, 255, 0)
154
-
155
- # Rotate it off the screen
156
- for i in range(0, dotstar.columns - 1):
157
- dotstar.shift_left(True)
158
- time.sleep(.1)
159
-
160
- time.sleep(1)
161
- # Shift it off the screen
162
- for i in range(0, dotstar.columns - 1):
163
- dotstar.shift_left()
164
- time.sleep(.1)
165
-
166
- """
167
- super ()._shift_left (rotate )
168
-
169
- def shift_up (self , rotate = False ):
170
- """
171
- Shift all pixels up
172
-
173
- :param rotate: (Optional) Rotate the shifted pixels to bottom (default=False)
174
-
175
- This example shifts 2 pixels up
176
-
177
- .. code-block:: python
178
-
179
- import time
180
- from adafruit_featherwing import dotstar_featherwing
181
-
182
- dotstar = dotstar_featherwing.DotStarFeatherWing()
183
-
184
- # Draw Red and Green Pixels
185
- dotstar[5, 3] = (255, 0, 0)
186
- dotstar[6, 3] = (0, 255, 0)
187
-
188
- # Rotate it off the screen
189
- for i in range(0, dotstar.rows - 1):
190
- dotstar.shift_up(True)
191
- time.sleep(.1)
192
-
193
- time.sleep(1)
194
- # Shift it off the screen
195
- for i in range(0, dotstar.rows - 1):
196
- dotstar.shift_up()
197
- time.sleep(.1)
198
-
199
- """
200
- super ()._shift_up (rotate )
201
-
202
- def shift_down (self , rotate = False ):
203
- """
204
- Shift all pixels down
205
-
206
- :param rotate: (Optional) Rotate the shifted pixels to top (default=False)
207
-
208
- This example shifts 2 pixels down
209
-
210
- .. code-block:: python
211
-
212
- import time
213
- from adafruit_featherwing import dotstar_featherwing
214
-
215
- dotstar = dotstar_featherwing.DotStarFeatherWing()
216
-
217
- # Draw Red and Green Pixels
218
- dotstar[5, 3] = (255, 0, 0)
219
- dotstar[6, 3] = (0, 255, 0)
220
-
221
- # Rotate it off the screen
222
- for i in range(0, dotstar.rows - 1):
223
- dotstar.shift_down(True)
224
- time.sleep(.1)
225
-
226
- time.sleep(1)
227
- # Shift it off the screen
228
- for i in range(0, dotstar.rows - 1):
229
- dotstar.shift_down()
230
- time.sleep(.1)
231
-
232
- """
233
- super ()._shift_down (rotate )
234
-
235
- @property
236
- def auto_write (self ):
237
- """
238
- Whether or not we are automatically updating
239
- If set to false, be sure to call show() to update
240
-
241
- This lights DotStars with and without auto_write
242
-
243
- .. code-block:: python
244
-
245
- import time
246
- from adafruit_featherwing import dotstar_featherwing
247
-
248
- dotstar = dotstar_featherwing.DotStarFeatherWing()
249
- dotstar.fill() # Clear any lit Dotstars
250
- dotstar[0, 0] = (255, 255, 255) # Set White
251
- time.sleep(1)
252
-
253
- dotstar.auto_write = False
254
- dotstar[1, 0] = (255, 255, 255) # Set White
255
- time.sleep(1)
256
- dotstar.show() # Update the DotStars
257
-
258
- """
259
- return self ._auto_write
260
-
261
- @auto_write .setter
262
- def auto_write (self , write ):
263
- if isinstance (write , bool ):
264
- self ._auto_write = write
265
-
266
- @property
267
- def brightness (self ):
268
- """
269
- Overall brightness of the display
270
-
271
- This example changes the brightness
272
-
273
- .. code-block:: python
274
-
275
- import time
276
- from adafruit_featherwing import dotstar_featherwing
277
-
278
- dotstar = dotstar_featherwing.DotStarFeatherWing()
279
- dotstar.brightness = 0
280
- dotstar.fill(0xFFFFFF)
281
- for i in range(0, 6):
282
- dotstar.brightness = (i / 10)
283
- time.sleep(.2)
284
-
285
- dotstar.brightness = 0.3
286
-
287
- """
288
- return self ._matrix .brightness
289
-
290
- @brightness .setter
291
- def brightness (self , brightness ):
292
- self ._matrix .brightness = min (max (brightness , 0.0 ), 1.0 )
293
- self ._update ()
0 commit comments