File tree Expand file tree Collapse file tree 3 files changed +40
-30
lines changed Expand file tree Collapse file tree 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 1818import board
1919import adafruit_ht16k33 .matrix as matrix
2020
21+ from adafruit_featherwing .auto_writeable import AutoWriteable
2122
22- class MatrixFeatherWing :
23+
24+ class MatrixFeatherWing (AutoWriteable ):
2325 """Class representing an `Adafruit 8x16 LED Matrix FeatherWing
2426 <https://www.adafruit.com/product/3155>`_.
2527
2628 Automatically uses the feather's I2C bus."""
2729
2830 def __init__ (self , address = 0x70 , i2c = None ):
31+
2932 if i2c is None :
3033 i2c = board .I2C ()
3134 self ._matrix = matrix .Matrix16x8 (i2c , address )
3235 self ._matrix .auto_write = False
3336 self .columns = 16
3437 self .rows = 8
35- self . _auto_write = True
38+ super (). __init__ ()
3639
3740 def __getitem__ (self , key ):
3841 """
@@ -125,19 +128,6 @@ def shift_down(self, rotate=False):
125128 self ._matrix .shift_down (rotate )
126129 self ._update ()
127130
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-
141131 @property
142132 def blink_rate (self ):
143133 """
Original file line number Diff line number Diff line change 1616__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
1717
1818# pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
19+ from adafruit_featherwing .auto_writeable import AutoWriteable
1920
2021
21- class PixelMatrix :
22+ class PixelMatrix ( AutoWriteable ) :
2223 """Base Class for DotStar and NeoPixel FeatherWings
2324
2425 The feather uses pins D13 and D11"""
@@ -27,7 +28,7 @@ def __init__(self):
2728 self .rows = 0
2829 self .columns = 0
2930 self ._matrix = None
30- self . _auto_write = True
31+ super (). __init__ ()
3132
3233 def __setitem__ (self , indices , value ):
3334 """
@@ -158,19 +159,6 @@ def shift_down(self, rotate=False):
158159 self ._matrix [(self .rows - 1 ) * self .columns + x ] = last_pixel
159160 self ._update ()
160161
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-
174162 @property
175163 def brightness (self ):
176164 """
You can’t perform that action at this time.
0 commit comments