Skip to content

Commit 562c9a3

Browse files
committed
solving_docs
1 parent 587688c commit 562c9a3

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

README.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ Additons
133133
1. Add rotation func
134134

135135
.. code-block:: python
136-
136+
137137
matrix = matrices.Matrix8x8(spi, cs)
138138
matrix.rotation(2)
139-
140-
141-

adafruit_max7219/matrices.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
`adafruit_max7219.matrices.Matrix8x8`
77
====================================================
88
"""
9+
import time
910
from micropython import const
1011
from adafruit_max7219 import max7219
11-
import time
12+
1213

1314
__version__ = "0.0.0-auto.0"
1415
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MAX7219.git"
@@ -27,8 +28,8 @@ class Matrix8x8(max7219.MAX7219):
2728
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
2829
"""
2930

30-
def __init__(self, spi, cs,num=1):
31-
super().__init__(8, 8, spi, cs,num=num)
31+
def __init__(self, spi, cs, num=1):
32+
super().__init__(8, 8, spi, cs, num=num)
3233

3334
def init_display(self):
3435
for cmd, data in (
@@ -38,7 +39,7 @@ def init_display(self):
3839
(_DECODEMODE, 0),
3940
(_SHUTDOWN, 1),
4041
):
41-
self._write([cmd,data]*self.num)
42+
self._write([cmd, data] * self.num)
4243

4344
self.fill(0)
4445
self.show()
@@ -70,9 +71,9 @@ def display_str(self, data, delay=1):
7071
"""
7172
i = -1
7273
for char in data:
73-
i+=1
74+
i += 1
7475
self.fill(0)
75-
self.text(char,1,0)
76-
self.show_char_position(i%self.num)
77-
if i%self.num == self.num -1:
76+
self.text(char, 1, 0)
77+
self.show_char_position(i % self.num)
78+
if i % self.num == self.num - 1:
7879
time.sleep(delay)

adafruit_max7219/max7219.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
MAX7219_REG_NOOP = 0x0
5454

5555

56-
5756
class MAX7219:
5857
"""
5958
MAX2719 - driver for displays based on max719 chip_select
@@ -68,7 +67,7 @@ class MAX7219:
6867
"""
6968

7069
def __init__(
71-
self, width, height, spi, cs, *, baudrate=8000000, polarity=0, phase=0,num=1
70+
self, width, height, spi, cs, *, baudrate=8000000, polarity=0, phase=0, num=1
7271
):
7372

7473
self._chip_select = cs
@@ -85,7 +84,6 @@ def __init__(
8584
self.height = height
8685
self.num = num
8786

88-
8987
self.init_display()
9088

9189
def init_display(self):
@@ -147,26 +145,28 @@ def rotation(self, direction):
147145
"""
148146
self.framebuf.rotation = direction
149147

150-
151148
def _write(self, data):
152149
"""
153-
Send the bytes (which should comprise of alternating command, data values) over the SPI device.
154-
150+
Send the bytes (which should comprise of alternating command, data values)
151+
over the SPI device.
152+
155153
:param data: command collections
156154
"""
157155

158-
self._chip_select.value=False
156+
self._chip_select.value = False
159157
with self._spi_device as my_spi_device:
160158
my_spi_device.write(bytes(data))
161-
self._chip_select.value=True
162-
159+
self._chip_select.value = True
163160

164-
def show_char_position(self,position=0):
161+
def show_char_position(self, position=0):
165162
"""
166163
write data to the position that is one of multi led matrix
167164
168165
:param position: the position of matrix, value begin 0.
169166
170167
"""
171168
for ypos in range(8):
172-
self._write([_DIGIT0 + ypos, self._buffer[ypos]]+([MAX7219_REG_NOOP, 0] *(position)))
169+
self._write(
170+
[_DIGIT0 + ypos, self._buffer[ypos]]
171+
+ ([MAX7219_REG_NOOP, 0] * (position))
172+
)
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
from adafruit_max7219 import matrices
1+
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
25
import board
36
import busio
47
import digitalio
8+
from adafruit_max7219 import matrices
59

610
clk = board.IO4
711
din = board.IO2
812
cs = digitalio.DigitalInOut(board.IO3)
913

1014
spi = busio.SPI(clk, MOSI=din)
11-
display = matrices.Matrix8x8(spi, cs,4)
12-
display.framebuf.rotation =1 # rotate screen
15+
display = matrices.Matrix8x8(spi, cs, 4)
16+
display.framebuf.rotation = 1 # rotate screen
1317

1418
display.clear_all()
1519
while True:
16-
display.display_str('abc7568123456789asdfghj',2)
20+
display.display_str("abc7568123456789asdfghj", 2)

0 commit comments

Comments
 (0)