Skip to content

Commit 2a6b30d

Browse files
mrmcwethytannewt
authored andcommitted
Update README.rst and other associated files. (#4)
1 parent 642933a commit 2a6b30d

File tree

6 files changed

+219
-30
lines changed

6 files changed

+219
-30
lines changed

README.rst

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ Introduction
1616
1717
CircuitPython driver for the MAX7219 LED matrix driver chip.
1818

19-
.. warning:: This driver is still being updated for CircuitPython.
20-
2119
.. seealso:: See `here <https://github.com/adafruit/micropython-adafruit-max7219>`_ for the equivalent MicroPython driver.
2220

2321
Dependencies
@@ -33,7 +31,66 @@ This is easily achieved by downloading
3331
Usage Example
3432
=============
3533

36-
TODO
34+
Examples
35+
********
36+
37+
adafruit_max7219.Matrix8x8 Example
38+
----------------------------------
39+
40+
.. code-block:: python
41+
42+
from adafruit_max7219 import matrices
43+
from board import TX, RX, A2
44+
import busio
45+
import digitalio
46+
import time
47+
48+
clk = RX
49+
din = TX
50+
cs = digitalio.DigitalInOut(A2)
51+
52+
spi = busio.SPI(clk, MOSI=din)
53+
display = matrices.Matrix8x8(spi, cs)
54+
while True:
55+
display.brightness(3)
56+
57+
display.fill(1)
58+
display.pixel(3, 3)
59+
display.pixel(3, 4)
60+
display.pixel(4, 3)
61+
display.pixel(4, 4)
62+
display.show()
63+
time.sleep(3.0)
64+
65+
display.clear_all()
66+
s = 'Hello, World!'
67+
for c in range(len(s)*8):
68+
display.fill(0)
69+
display.text(s,-c,0)
70+
display.show()
71+
time.sleep(0.25)
72+
73+
74+
adafruit_max7219.BCDDigits Example
75+
----------------------------------
76+
77+
.. code-block:: python
78+
79+
from adafruit_max7219 import bcddigits
80+
from board import TX, RX, A2
81+
import bitbangio
82+
import digitalio
83+
84+
clk = RX
85+
din = TX
86+
cs = digitalio.DigitalInOut(A2)
87+
88+
spi = bitbangio.SPI(clk, MOSI=din)
89+
display = bcddigits.BCDDigits(spi, cs, nDigits=8)
90+
display.clear_all()
91+
display.show_str(0,'{:9.2f}'.format(-1234.56))
92+
display.show()
93+
3794
3895
Contributing
3996
============

adafruit_max7219/matrices.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
class Matrix8x8(max7219.MAX7219):
3636
def __init__(self, spi, cs):
3737
"""
38-
:param object spi: an spi busio or spi bitbangio object
39-
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
38+
:param object spi: an spi busio or spi bitbangio object
39+
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
4040
"""
4141
super().__init__(8,8,spi,cs)
4242

@@ -48,14 +48,18 @@ def init_display(self):
4848
(_DECODEMODE, 0),
4949
(_SHUTDOWN, 1),
5050
):
51-
self.write_cmd(cmd, data)
51+
self.write_cmd(cmd, data)
5252

5353
self.fill(0)
5454
self.show()
5555

5656
def text(self, str, x, y, col=1):
5757
"""
5858
draw text in the 8x8 matrix.
59+
60+
:param int x: x position of LED in matrix
61+
:param int y: y position of LED in matrix
62+
:param string str: string to place in to display
5963
"""
6064
self.framebuf.text(str, x, y, col)
6165

@@ -64,4 +68,3 @@ def clear_all(self):
6468
unlights all matrix leds
6569
"""
6670
self.fill(0)
67-

api.rst

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,106 @@
11

2-
.. If you created a package, create one automodule per module in the package.
2+
Module classes
3+
==============
34

4-
.. automodule:: adafruit_max7219
5-
:members:
5+
Matrices
6+
********
7+
8+
.. module:: adafruit_max7219.matrices
9+
10+
.. class:: Matrix8x8(spi, cs)
11+
12+
Driver for a single MAX7219-based 8x8 LED matrix.
13+
14+
:param object spi: an spi busio or spi bitbangio object
15+
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
16+
17+
.. method:: brightness(value)
18+
19+
control the brightness of the display
20+
21+
:param int value: 0->15 dimmest to brightest
22+
23+
.. method:: fill(color)
24+
25+
Fill the whole matrix with a specified color.
26+
27+
:param int color: None or False or 0 turn LED off, anything else turns LED on
28+
29+
.. method:: pixel(x, y, color=None)
30+
31+
Set the color of a single pixel.
32+
33+
:param int x: x postiion of LED in matrix
34+
:param int y: y position of LED in matrix
35+
:param int color: value > zero lights the decimal point, else unlights the point
36+
37+
.. method:: text(x, y, str)
38+
39+
Position and set text on display; used for text scrolling
40+
41+
:param int x: x postiion of LED in matrix
42+
:param int y: y position of LED in matrix
43+
:param string str: string to place in to display
44+
45+
.. method:: clear_all()
46+
47+
sets all leds to off; same as fill(0)
48+
49+
.. method:: show()
50+
51+
Update the display.
52+
53+
54+
BCDDigits
55+
*********
56+
57+
.. module:: adafruit_max7219.bcddigits
58+
59+
.. class:: BCDDigits(spi, cs, nDigits=1)
60+
61+
Driver for one to 8 MAX7219-based 7-Segment LED display.
62+
63+
:param object spi: an spi busio or spi bitbangio object
64+
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
65+
:param int nDigits: number of led 7-segment digits; default 1; max 8
66+
67+
.. method:: set_digit(d, v)
68+
69+
set one digit in the display
70+
71+
:param int d: the digit position; zero-based
72+
:param int v: integer ranging from 0->15
73+
74+
.. method:: show_dot(d, col=None)
75+
76+
set the decimal point for a digit
77+
78+
:param int d: the digit to set the decimal point zero-based
79+
:param int col: value > zero lights the decimal point, else unlights the point
80+
81+
.. method:: show_str(s,str)
82+
83+
displays a numeric str in the display. shows digits 0-9, -, and .
84+
85+
:param int s: start position to show the numeric string
86+
:param string str: the numeric string
87+
88+
.. method:: show_help(s)
89+
90+
display the word HELP in the display
91+
92+
:param int s: start position to show HELP
93+
94+
.. method:: brightness(value)
95+
96+
control the brightness of the display
97+
98+
:param int value: 0->15 dimmest to brightest
99+
100+
.. method:: clear_all()
101+
102+
sets all leds to off
103+
104+
.. method:: show()
105+
106+
Update the display.

conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
# General information about the project.
2929
project = u'Adafruit MAX7219 Library'
30-
copyright = u'2017 Radomir Dopieralski'
31-
author = u'Radomir Dopieralski'
30+
copyright = u'2017, Adafruit CiruitPython and Bundle contributors'
31+
author = u'Michael McWethy'
3232

3333
# The version info for the project you're documenting, acts as replacement for
3434
# |version| and |release|, also used in various other places throughout the
@@ -137,6 +137,6 @@
137137
# dir menu entry, description, category)
138138
texinfo_documents = [
139139
(master_doc, 'AdafruitMAX7219Library', u'Adafruit MAX7219 Library Documentation',
140-
author, 'AdafruitMAX7219Library', 'One line description of project.',
140+
author, 'AdafruitMAX7219Library', 'Python driver classes for MAX7219 chip',
141141
'Miscellaneous'),
142142
]

docs/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# General information about the project.
4848
project = u'Adafruit MAX7219'
49-
copyright = u'2016, Radomir Dopieralski'
49+
copyright = u'2017, Adafruit CiruitPython and Bundle contributors'
5050

5151
# The version info for the project you're documenting, acts as replacement for
5252
# |version| and |release|, also used in various other places throughout the
@@ -199,7 +199,7 @@
199199
# author, documentclass [howto, manual, or own class]).
200200
latex_documents = [
201201
('index', 'AdafruitMAX7219.tex', u'Adafruit MAX7219 Documentation',
202-
u'Radomir Dopieralski', 'manual'),
202+
u'Michael McWethy', 'manual'),
203203
]
204204

205205
# The name of an image file (relative to this directory) to place at the top of
@@ -229,7 +229,7 @@
229229
# (source start file, name, description, authors, manual section).
230230
man_pages = [
231231
('index', 'adafruitmax7219', u'Adafruit MAX7219 Documentation',
232-
[u'Radomir Dopieralski'], 1)
232+
[u'Michael McWethy'], 1)
233233
]
234234

235235
# If true, show URL addresses after external links.
@@ -243,7 +243,7 @@
243243
# dir menu entry, description, category)
244244
texinfo_documents = [
245245
('index', 'AdafruitMAX7219', u'Adafruit MAX7219 Documentation',
246-
u'Radomir Dopieralski', 'AdafruitMAX7219', 'One line description of project.',
246+
u'Michael McWethy', 'AdafruitMAX7219', 'Python driver classes for MAX7219 chip.',
247247
'Miscellaneous'),
248248
]
249249

docs/matrix.rst

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Module classes
23
==============
34

@@ -8,24 +9,39 @@ Matrices
89

910
.. class:: Matrix8x8(spi, cs)
1011

11-
Driver for a single MAX7219-based LED matrix.
12+
Driver for a single MAX7219-based 8x8 LED matrix.
13+
14+
:param object spi: an spi busio or spi bitbangio object
15+
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
1216

1317
.. method:: brightness(value)
1418

15-
Set the brightness.
19+
control the brightness of the display
20+
21+
:param int value: 0->15 dimmest to brightest
1622

1723
.. method:: fill(color)
1824

1925
Fill the whole matrix with a specified color.
2026

27+
:param int color: None or False or 0 turn LED off, anything else turns LED on
28+
2129
.. method:: pixel(x, y, color=None)
2230

2331
Set the color of a single pixel.
2432

33+
:param int x: x postiion of LED in matrix
34+
:param int y: y position of LED in matrix
35+
:param int color: value > zero lights the decimal point, else unlights the point
36+
2537
.. method:: text(x, y, str)
2638

2739
Position and set text on display; used for text scrolling
28-
40+
41+
:param int x: x postiion of LED in matrix
42+
:param int y: y position of LED in matrix
43+
:param string str: string to place in to display
44+
2945
.. method:: clear_all()
3046

3147
sets all leds to off; same as fill(0)
@@ -42,32 +58,44 @@ BCDDigits
4258

4359
.. class:: BCDDigits(spi, cs, nDigits=1)
4460

45-
Driver for a single MAX7219-based LED matrix.
61+
Driver for one to 8 MAX7219-based 7-Segment LED display.
4662

63+
:param object spi: an spi busio or spi bitbangio object
64+
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
65+
:param int nDigits: number of led 7-segment digits; default 1; max 8
4766

4867
.. method:: set_digit(d, v)
49-
68+
5069
set one digit in the display
5170

71+
:param int d: the digit position; zero-based
72+
:param int v: integer ranging from 0->15
73+
5274
.. method:: show_dot(d, col=None)
53-
75+
5476
set the decimal point for a digit
5577

78+
:param int d: the digit to set the decimal point zero-based
79+
:param int col: value > zero lights the decimal point, else unlights the point
80+
5681
.. method:: show_str(s,str)
57-
82+
5883
displays a numeric str in the display. shows digits 0-9, -, and .
5984

85+
:param int s: start position to show the numeric string
86+
:param string str: the numeric string
87+
6088
.. method:: show_help(s)
61-
89+
6290
display the word HELP in the display
63-
64-
.. method:: brightness(value)
6591

66-
Set the brightness.
92+
:param int s: start position to show HELP
6793

68-
.. method:: pixel(x, y, color=None)
94+
.. method:: brightness(value)
6995

70-
Set the color of a single pixel.
96+
control the brightness of the display
97+
98+
:param int value: 0->15 dimmest to brightest
7199

72100
.. method:: clear_all()
73101

0 commit comments

Comments
 (0)