File tree 3 files changed +40
-30
lines changed
3 files changed +40
-30
lines changed Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2021 Tim Cocks for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ """
6
+ `adafruit_featherwing.auto_writeable`
7
+ ====================================================
8
+
9
+ Superclass for the helpers pixelmatrix and matrix_featherwing
10
+
11
+ * Author(s): Tim Cocks
12
+ """
13
+
14
+
15
+ class AutoWriteable :
16
+ """Superclass for matrix_featherwing and pixelmatrix."""
17
+
18
+ def __init__ (self ):
19
+ self ._auto_write = True
20
+
21
+ @property
22
+ def auto_write (self ):
23
+ """
24
+ Whether or not we are automatically updating
25
+ If set to false, be sure to call show() to update
26
+ """
27
+ return self ._auto_write
28
+
29
+ @auto_write .setter
30
+ def auto_write (self , write ):
31
+ if isinstance (write , bool ):
32
+ self ._auto_write = write
Original file line number Diff line number Diff line change 18
18
import board
19
19
import adafruit_ht16k33 .matrix as matrix
20
20
21
+ from adafruit_featherwing .auto_writeable import AutoWriteable
21
22
22
- class MatrixFeatherWing :
23
+
24
+ class MatrixFeatherWing (AutoWriteable ):
23
25
"""Class representing an `Adafruit 8x16 LED Matrix FeatherWing
24
26
<https://www.adafruit.com/product/3155>`_.
25
27
26
28
Automatically uses the feather's I2C bus."""
27
29
28
30
def __init__ (self , address = 0x70 , i2c = None ):
31
+
29
32
if i2c is None :
30
33
i2c = board .I2C ()
31
34
self ._matrix = matrix .Matrix16x8 (i2c , address )
32
35
self ._matrix .auto_write = False
33
36
self .columns = 16
34
37
self .rows = 8
35
- self . _auto_write = True
38
+ super (). __init__ ()
36
39
37
40
def __getitem__ (self , key ):
38
41
"""
@@ -125,19 +128,6 @@ def shift_down(self, rotate=False):
125
128
self ._matrix .shift_down (rotate )
126
129
self ._update ()
127
130
128
- @property
129
- def auto_write (self ):
130
- """
131
- Whether or not we are automatically updating
132
- If set to false, be sure to call show() to update
133
- """
134
- return self ._auto_write
135
-
136
- @auto_write .setter
137
- def auto_write (self , write ):
138
- if isinstance (write , bool ):
139
- self ._auto_write = write
140
-
141
131
@property
142
132
def blink_rate (self ):
143
133
"""
Original file line number Diff line number Diff line change 16
16
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
17
17
18
18
# pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
19
+ from adafruit_featherwing .auto_writeable import AutoWriteable
19
20
20
21
21
- class PixelMatrix :
22
+ class PixelMatrix ( AutoWriteable ) :
22
23
"""Base Class for DotStar and NeoPixel FeatherWings
23
24
24
25
The feather uses pins D13 and D11"""
@@ -27,7 +28,7 @@ def __init__(self):
27
28
self .rows = 0
28
29
self .columns = 0
29
30
self ._matrix = None
30
- self . _auto_write = True
31
+ super (). __init__ ()
31
32
32
33
def __setitem__ (self , indices , value ):
33
34
"""
@@ -158,19 +159,6 @@ def shift_down(self, rotate=False):
158
159
self ._matrix [(self .rows - 1 ) * self .columns + x ] = last_pixel
159
160
self ._update ()
160
161
161
- @property
162
- def auto_write (self ):
163
- """
164
- Whether or not we are automatically updating
165
- If set to false, be sure to call show() to update
166
- """
167
- return self ._auto_write
168
-
169
- @auto_write .setter
170
- def auto_write (self , write ):
171
- if isinstance (write , bool ):
172
- self ._auto_write = write
173
-
174
162
@property
175
163
def brightness (self ):
176
164
"""
You can’t perform that action at this time.
0 commit comments