1
1
# SPDX-FileCopyrightText: 2016 Philip R. Moyer for Adafruit Industries
2
2
# SPDX-FileCopyrightText: 2016 Radomir Dopieralski for Adafruit Industries
3
+ # SPDX-FileCopyrightText: 2021 bluejazzCHN for Adafruit Industries
3
4
#
4
5
# SPDX-License-Identifier: MIT
5
6
24
25
--------------------
25
26
**Hardware:**
26
27
27
- * Adafruit ` MAX7219CNG LED Matrix/Digit Display Driver -
28
+ * ` Adafruit MAX7219CNG LED Matrix/Digit Display Driver -
28
29
MAX7219 <https://www.adafruit.com/product/453>`_ (Product ID: 453)
29
30
30
31
**Software and Dependencies:**
31
32
32
33
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
33
34
https://github.com/adafruit/circuitpython/releases
34
35
35
- * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
36
+ * Adafruit's Bus Device library:
37
+ https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
36
38
37
39
**Notes:**
38
40
#. Datasheet: https://cdn-shop.adafruit.com/datasheets/MAX7219.pdf
56
58
class MAX7219 :
57
59
"""
58
60
MAX2719 - driver for displays based on max719 chip_select
59
-
60
61
:param int width: the number of pixels wide
61
62
:param int height: the number of pixels high
62
63
:param object spi: an spi busio or spi bitbangio object
@@ -99,12 +100,14 @@ def brightness(self, value):
99
100
raise ValueError ("Brightness out of range" )
100
101
self .write_cmd (_INTENSITY , value )
101
102
102
- def show (self ):
103
+ def show (self , number = 1 , t_num = 1 ):
103
104
"""
104
105
Updates the display.
106
+ :param int number: which one is in the cascaded matrixs, default is 1.
107
+ :param int t_num: total number of cascaded Matrixs,default is 1.
105
108
"""
106
109
for ypos in range (8 ):
107
- self .write_cmd (_DIGIT0 + ypos , self ._buffer [ypos ])
110
+ self .write_cmd (_DIGIT0 + ypos , self ._buffer [ypos ], number , t_num )
108
111
109
112
def fill (self , bit_value ):
110
113
"""
@@ -129,18 +132,30 @@ def scroll(self, delta_x, delta_y):
129
132
"""Srcolls the display using delta_x,delta_y."""
130
133
self .framebuf .scroll (delta_x , delta_y )
131
134
132
- def write_cmd (self , cmd , data ):
135
+ def write_cmd (self , cmd , data , number = 1 , t_num = 1 ):
133
136
# pylint: disable=no-member
134
- """Writes a command to spi device."""
137
+ """Writes a command to spi device.
138
+ :param int number: whichi one is in the cascaded matrixs, default is 1.
139
+ :param int t_num: total number of cascaded Matrixs,default is 1.
140
+ """
135
141
# print('cmd {} data {}'.format(cmd,data))
136
142
self ._chip_select .value = False
143
+
144
+ # send Noop to ones behind number Matrix
137
145
with self ._spi_device as my_spi_device :
146
+ for i in range (number , t_num ):
147
+ my_spi_device .write (bytearray ([0 , 0 ]))
148
+
138
149
my_spi_device .write (bytearray ([cmd , data ]))
139
150
151
+ # send Noop to all before number, if you want to know why, please ref to MAX7219.pdf.
152
+ for i in range (0 , number - 1 ):
153
+ my_spi_device .write (bytearray ([0 , 0 ]))
154
+ i = i - i
155
+
140
156
def rotation (self , direction ):
141
157
"""
142
158
Set display direction
143
-
144
159
:param direction:set int to change display direction, value 0 (default), 1, 2, 3
145
160
"""
146
161
self .framebuf .rotation = direction
0 commit comments