Skip to content

Commit b4d48d8

Browse files
authored
Merge pull request #10 from sommersoft/new_docs
Improve Ref Docs
2 parents cc55284 + 2909428 commit b4d48d8

13 files changed

+170
-78
lines changed
File renamed without changes.

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ deploy:
1616
provider: releases
1717
api_key: $GITHUB_TOKEN
1818
file_glob: true
19-
file: bundles/*
19+
file: $TRAVIS_BUILD_DIR/bundles/*
2020
skip_cleanup: true
2121
overwrite: true
2222
on:
2323
tags: true
2424

2525
install:
26-
- pip install pylint circuitpython-build-tools
26+
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
2727

2828
script:
2929
- pylint adafruit_max7219/*.py
3030
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py)
3131
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-max7219 --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html

README.rst

+23-11
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ This is easily achieved by downloading
2727
Usage Example
2828
=============
2929

30-
Examples
31-
********
32-
3330
adafruit_max7219.Matrix8x8 Example
3431
----------------------------------
3532

@@ -87,14 +84,6 @@ adafruit_max7219.BCDDigits Example
8784
display.show_str(0,'{:9.2f}'.format(-1234.56))
8885
display.show()
8986
90-
API Reference
91-
=============
92-
93-
.. toctree::
94-
:maxdepth: 2
95-
96-
api
97-
9887
Contributing
9988
============
10089

@@ -125,3 +114,26 @@ Then run the build:
125114
.. code-block:: shell
126115
127116
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-max7219 --library_location .
117+
118+
Sphinx documentation
119+
-----------------------
120+
121+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
122+
install dependencies (feel free to reuse the virtual environment from above):
123+
124+
.. code-block:: shell
125+
126+
python3 -m venv .env
127+
source .env/bin/activate
128+
pip install Sphinx sphinx-rtd-theme
129+
130+
Now, once you have the virtual environment activated:
131+
132+
.. code-block:: shell
133+
134+
cd docs
135+
sphinx-build -E -W -b html . _build/html
136+
137+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
138+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
139+
locally verify it will pass.

adafruit_max7219/bcddigits.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323

2424
"""
25-
:mod:`adafruit_max7219.bcddigits.BCDDigits`
25+
`adafruit_max7219.bcddigits.BCDDigits`
2626
====================================================
2727
"""
2828
from adafruit_max7219 import max7219
@@ -40,14 +40,12 @@ class BCDDigits(max7219.MAX7219):
4040
"""
4141
Basic support for display on a 7-Segment BCD display controlled
4242
by a Max7219 chip using SPI.
43+
44+
:param object spi: an spi busio or spi bitbangio object
45+
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
46+
:param int nDigits: number of led 7-segment digits; default 1; max 8
4347
"""
4448
def __init__(self, spi, cs, nDigits=1):
45-
"""
46-
:param object spi: an spi busio or spi bitbangio object
47-
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select
48-
signal
49-
:param int nDigits: number of led 7-segment digits; default 1; max 8
50-
"""
5149
self._ndigits = nDigits
5250
super().__init__(self._ndigits, 8, spi, cs)
5351

@@ -66,7 +64,8 @@ def init_display(self):
6664

6765
def set_digit(self, dpos, value):
6866
"""
69-
set one digit in the display
67+
Display one digit.
68+
7069
:param int dpos: the digit position; zero-based
7170
:param int value: integer ranging from 0->15
7271
"""
@@ -78,7 +77,8 @@ def set_digit(self, dpos, value):
7877

7978
def set_digits(self, start, values):
8079
"""
81-
set the display from a list
80+
Display digits from a list.
81+
8282
:param int s: digit to start display zero-based
8383
:param list ds: list of integer values ranging from 0->15
8484
"""
@@ -89,7 +89,8 @@ def set_digits(self, start, values):
8989

9090
def show_dot(self, dpos, bit_value=None):
9191
"""
92-
set the decimal point for a digit
92+
The decimal point for a digit.
93+
9394
:param int dpos: the digit to set the decimal point zero-based
9495
:param int value: value > zero lights the decimal point, else unlights the point
9596
"""
@@ -99,15 +100,16 @@ def show_dot(self, dpos, bit_value=None):
99100

100101
def clear_all(self):
101102
"""
102-
clear all digits and decimal points
103+
Clear all digits and decimal points.
103104
"""
104105
self.fill(1)
105106
for i in range(self._ndigits):
106107
self.show_dot(i)
107108

108109
def show_str(self, start, strg):
109110
"""
110-
displays a numeric str in the display. shows digits 0-9, -, and .
111+
Displays a numeric str in the display. Shows digits ``0-9``, ``-``, and ``.``.
112+
111113
:param int start: start position to show the numeric string
112114
:param string str: the numeric string
113115
"""
@@ -127,7 +129,8 @@ def show_str(self, start, strg):
127129

128130
def show_help(self, start):
129131
"""
130-
display the word HELP in the display
132+
Display the word HELP in the display.
133+
131134
:param int start: start position to show HELP
132135
"""
133136
digits = [12, 11, 13, 14]

adafruit_max7219/matrices.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323

2424
"""
25-
:mod:`adafruit_max7219.matrices.Matrix8x8`
25+
`adafruit_max7219.matrices.Matrix8x8`
2626
====================================================
2727
"""
2828
from adafruit_max7219 import max7219
@@ -37,12 +37,13 @@
3737
_DISPLAYTEST = const(15)
3838

3939
class Matrix8x8(max7219.MAX7219):
40-
"""Driver for a 8x8 LED matrix based on the MAX7219 chip"""
40+
"""
41+
Driver for a 8x8 LED matrix based on the MAX7219 chip.
42+
43+
:param object spi: an spi busio or spi bitbangio object
44+
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
45+
"""
4146
def __init__(self, spi, cs):
42-
"""
43-
:param object spi: an spi busio or spi bitbangio object
44-
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
45-
"""
4647
super().__init__(8, 8, spi, cs)
4748

4849
def init_display(self):
@@ -59,7 +60,7 @@ def init_display(self):
5960

6061
def text(self, strg, xpos, ypos, bit_value=1):
6162
"""
62-
draw text in the 8x8 matrix.
63+
Draw text in the 8x8 matrix.
6364
6465
:param int xpos: x position of LED in matrix
6566
:param int ypos: y position of LED in matrix
@@ -70,6 +71,6 @@ def text(self, strg, xpos, ypos, bit_value=1):
7071

7172
def clear_all(self):
7273
"""
73-
unlights all matrix leds
74+
Clears all matrix leds.
7475
"""
7576
self.fill(0)

adafruit_max7219/max7219.py

+35-25
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,36 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222
"""
23-
`adafruit_max7219.MAX7219` - MAX7219 LED Matrix/Digit Display Driver
23+
`adafruit_max7219.max7219` - MAX7219 LED Matrix/Digit Display Driver
2424
========================================================================
2525
CircuitPython library to support MAX7219 LED Matrix/Digit Display Driver.
2626
This library supports the use of the MAX7219-based display in CircuitPython,
2727
either an 8x8 matrix or a 8 digit 7-segment numeric display.
2828
29-
see also
30-
========
29+
See Also
30+
=========
3131
* matrices.Maxtrix8x8 is a class support an 8x8 led matrix display
3232
* bcddigits.BCDDigits is a class that support the 8 digit 7-segment display
3333
3434
Beware that most CircuitPython compatible hardware are 3.3v logic level! Make
3535
sure that the input pin is 5v tolerant.
36+
3637
* Author(s): Michael McWethy
3738
3839
Implementation Notes
3940
--------------------
4041
**Hardware:**
42+
4143
* Adafruit `MAX7219CNG LED Matrix/Digit Display Driver -
42-
MAX7219 <https://www.adafruit.com/product/453>`_ (Product ID: 453)
44+
MAX7219 <https://www.adafruit.com/product/453>`_ (Product ID: 453)
45+
4346
**Software and Dependencies:**
44-
* Adafruit CircuitPython firmware (1.0.0+) for the ESP8622 and M0-based boards:
45-
https://github.com/adafruit/circuitpython/releases
47+
48+
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
49+
https://github.com/adafruit/circuitpython/releases
50+
4651
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
52+
4753
**Notes:**
4854
#. Datasheet: https://cdn-shop.adafruit.com/datasheets/MAX7219.pdf
4955
"""
@@ -63,18 +69,19 @@
6369

6470

6571
class MAX7219:
66-
""" MAX2719 - driver for displays based on max719 chip_select"""
72+
"""
73+
MAX2719 - driver for displays based on max719 chip_select
74+
75+
:param int width: the number of pixels wide
76+
:param int height: the number of pixels high
77+
:param object spi: an spi busio or spi bitbangio object
78+
:param ~digitalio.DigitalInOut chip_select: digital in/out to use as chip select signal
79+
:param baudrate: for SPIDevice baudrate (default 8000000)
80+
:param polarity: for SPIDevice polarity (default 0)
81+
:param phase: for SPIDevice phase (default 0)
82+
"""
6783
def __init__(self, width, height, spi, cs, *,
6884
baudrate=8000000, polarity=0, phase=0):
69-
"""
70-
:param int width: the number of pixels wide
71-
:param int height: the number of pixels high
72-
:param object spi: an spi busio or spi bitbangio object
73-
:param ~digitalio.DigitalInOut chip_select: digital in/out to use as chip select signal
74-
:param baudrate: for SPIDevice baudrate (default 8000000)
75-
:param polarity: for SPIDevice polarity (default 0)
76-
:param phase: for SPIDevice phase (default 0)
77-
"""
7885

7986
self._chip_select = cs
8087
self._chip_select.direction = digitalio.Direction.OUTPUT
@@ -91,12 +98,13 @@ def __init__(self, width, height, spi, cs, *,
9198
self.init_display()
9299

93100
def init_display(self):
94-
"""must be implement by derived class"""
101+
"""Must be implemented by derived class (``matrices``, ``bcddigits``)"""
95102
pass
96103

97104
def brightness(self, value):
98105
"""
99-
control the brightness of the display
106+
Controls the brightness of the display.
107+
100108
:param int value: 0->15 dimmest to brightest
101109
"""
102110
if not 0 <= value <= 15:
@@ -105,34 +113,36 @@ def brightness(self, value):
105113

106114
def show(self):
107115
"""
108-
update the display with recent changes in buffer
116+
Updates the display.
109117
"""
110118
for ypos in range(8):
111119
self.write_cmd(_DIGIT0 + ypos, self._buffer[ypos])
112120

113121
def fill(self, bit_value):
114122
"""
115-
set all buffer bits to a col
116-
:param bit_value: int value > 0 set the buffer bit, else clears the buffer bit
123+
Fill the display buffer.
124+
125+
:param int bit_value: value > 0 set the buffer bit, else clears the buffer bit
117126
"""
118127
self.framebuf.fill(bit_value)
119128

120129
def pixel(self, xpos, ypos, bit_value=None):
121130
"""
122-
set one buffer bit
131+
Set one buffer bit
132+
123133
:param xpos: x position to set bit
124134
:param ypos: y position to set bit
125-
:param bit_value: int value > 0 sets the buffer bit, else clears the buffer bit
135+
:param int bit_value: value > 0 sets the buffer bit, else clears the buffer bit
126136
"""
127137
bit_value = 0x01 if bit_value else 0x00
128138
self.framebuf.pixel(xpos, ypos, bit_value)
129139

130140
def scroll(self, delta_x, delta_y):
131-
"""scolls the display using delta_x,delta_y"""
141+
"""Srcolls the display using delta_x,delta_y."""
132142
self.framebuf.scroll(delta_x, delta_y)
133143

134144
def write_cmd(self, cmd, data):
135-
"""writes a command to spi device"""
145+
"""Writes a command to spi device."""
136146
#print('cmd {} data {}'.format(cmd,data))
137147
self._chip_select.value = False
138148
with self._spi_device as my_spi_device:

api.rst

-15
This file was deleted.

docs/_static/favicon.ico

4.31 KB
Binary file not shown.

docs/api.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
.. If you created a package, create one automodule per module in the package.
3+
4+
.. automodule:: adafruit_max7219.max7219
5+
:members:
6+
7+
.. automodule:: adafruit_max7219.matrices
8+
:members:
9+
10+
.. automodule:: adafruit_max7219.bcddigits
11+
:members:

0 commit comments

Comments
 (0)