-
Notifications
You must be signed in to change notification settings - Fork 6
Improve Ref Docs #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Ref Docs #10
Changes from 13 commits
cf1bec3
6e76138
fca9733
42f1198
1636605
3c0a6e1
beec536
9d60dda
f029f95
ada5c79
028aae6
64c5c4d
7e33c16
2909428
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
# | ||
|
||
""" | ||
:mod:`adafruit_max7219.bcddigits.BCDDigits` | ||
`adafruit_max7219.bcddigits.BCDDigits` | ||
==================================================== | ||
""" | ||
from adafruit_max7219 import max7219 | ||
|
@@ -40,14 +40,12 @@ class BCDDigits(max7219.MAX7219): | |
""" | ||
Basic support for display on a 7-Segment BCD display controlled | ||
by a Max7219 chip using SPI. | ||
|
||
:param object spi: an spi busio or spi bitbangio object | ||
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal | ||
:param int nDigits: number of led 7-segment digits; default 1; max 8 | ||
""" | ||
def __init__(self, spi, cs, nDigits=1): | ||
""" | ||
:param object spi: an spi busio or spi bitbangio object | ||
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select | ||
signal | ||
:param int nDigits: number of led 7-segment digits; default 1; max 8 | ||
""" | ||
self._ndigits = nDigits | ||
super().__init__(self._ndigits, 8, spi, cs) | ||
|
||
|
@@ -66,7 +64,8 @@ def init_display(self): | |
|
||
def set_digit(self, dpos, value): | ||
""" | ||
set one digit in the display | ||
Set one digit in the display. | ||
|
||
:param int dpos: the digit position; zero-based | ||
:param int value: integer ranging from 0->15 | ||
""" | ||
|
@@ -78,7 +77,8 @@ def set_digit(self, dpos, value): | |
|
||
def set_digits(self, start, values): | ||
""" | ||
set the display from a list | ||
Set the display from a list. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Display digits from a list." |
||
|
||
:param int s: digit to start display zero-based | ||
:param list ds: list of integer values ranging from 0->15 | ||
""" | ||
|
@@ -89,7 +89,8 @@ def set_digits(self, start, values): | |
|
||
def show_dot(self, dpos, bit_value=None): | ||
""" | ||
set the decimal point for a digit | ||
Set the decimal point for a digit. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "The decimal point for a digit." |
||
|
||
:param int dpos: the digit to set the decimal point zero-based | ||
:param int value: value > zero lights the decimal point, else unlights the point | ||
""" | ||
|
@@ -99,15 +100,16 @@ def show_dot(self, dpos, bit_value=None): | |
|
||
def clear_all(self): | ||
""" | ||
clear all digits and decimal points | ||
Clear all digits and decimal points. | ||
""" | ||
self.fill(1) | ||
for i in range(self._ndigits): | ||
self.show_dot(i) | ||
|
||
def show_str(self, start, strg): | ||
""" | ||
displays a numeric str in the display. shows digits 0-9, -, and . | ||
Displays a numeric str in the display. Shows digits ``0-9``, ``-``, and ``.``. | ||
|
||
:param int start: start position to show the numeric string | ||
:param string str: the numeric string | ||
""" | ||
|
@@ -127,7 +129,8 @@ def show_str(self, start, strg): | |
|
||
def show_help(self, start): | ||
""" | ||
display the word HELP in the display | ||
Display the word HELP in the display. | ||
|
||
:param int start: start position to show HELP | ||
""" | ||
digits = [12, 11, 13, 14] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,30 +20,36 @@ | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
""" | ||
`adafruit_max7219.MAX7219` - MAX7219 LED Matrix/Digit Display Driver | ||
`adafruit_max7219.max7219` - MAX7219 LED Matrix/Digit Display Driver | ||
======================================================================== | ||
CircuitPython library to support MAX7219 LED Matrix/Digit Display Driver. | ||
This library supports the use of the MAX7219-based display in CircuitPython, | ||
either an 8x8 matrix or a 8 digit 7-segment numeric display. | ||
|
||
see also | ||
======== | ||
See Also | ||
========= | ||
* matrices.Maxtrix8x8 is a class support an 8x8 led matrix display | ||
* bcddigits.BCDDigits is a class that support the 8 digit 7-segment display | ||
|
||
Beware that most CircuitPython compatible hardware are 3.3v logic level! Make | ||
sure that the input pin is 5v tolerant. | ||
|
||
* Author(s): Michael McWethy | ||
|
||
Implementation Notes | ||
-------------------- | ||
**Hardware:** | ||
|
||
* Adafruit `MAX7219CNG LED Matrix/Digit Display Driver - | ||
MAX7219 <https://www.adafruit.com/product/453>`_ (Product ID: 453) | ||
MAX7219 <https://www.adafruit.com/product/453>`_ (Product ID: 453) | ||
|
||
**Software and Dependencies:** | ||
* Adafruit CircuitPython firmware (1.0.0+) for the ESP8622 and M0-based boards: | ||
https://github.com/adafruit/circuitpython/releases | ||
|
||
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards: | ||
https://github.com/adafruit/circuitpython/releases | ||
|
||
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice | ||
|
||
**Notes:** | ||
#. Datasheet: https://cdn-shop.adafruit.com/datasheets/MAX7219.pdf | ||
""" | ||
|
@@ -63,18 +69,19 @@ | |
|
||
|
||
class MAX7219: | ||
""" MAX2719 - driver for displays based on max719 chip_select""" | ||
""" | ||
MAX2719 - driver for displays based on max719 chip_select | ||
|
||
:param int width: the number of pixels wide | ||
:param int height: the number of pixels high | ||
:param object spi: an spi busio or spi bitbangio object | ||
:param ~digitalio.DigitalInOut chip_select: digital in/out to use as chip select signal | ||
:param baudrate: for SPIDevice baudrate (default 8000000) | ||
:param polarity: for SPIDevice polarity (default 0) | ||
:param phase: for SPIDevice phase (default 0) | ||
""" | ||
def __init__(self, width, height, spi, cs, *, | ||
baudrate=8000000, polarity=0, phase=0): | ||
""" | ||
:param int width: the number of pixels wide | ||
:param int height: the number of pixels high | ||
:param object spi: an spi busio or spi bitbangio object | ||
:param ~digitalio.DigitalInOut chip_select: digital in/out to use as chip select signal | ||
:param baudrate: for SPIDevice baudrate (default 8000000) | ||
:param polarity: for SPIDevice polarity (default 0) | ||
:param phase: for SPIDevice phase (default 0) | ||
""" | ||
|
||
self._chip_select = cs | ||
self._chip_select.direction = digitalio.Direction.OUTPUT | ||
|
@@ -91,12 +98,13 @@ def __init__(self, width, height, spi, cs, *, | |
self.init_display() | ||
|
||
def init_display(self): | ||
"""must be implement by derived class""" | ||
"""Must be implemented by derived class (``matrices``, ``bcddigits``)""" | ||
pass | ||
|
||
def brightness(self, value): | ||
""" | ||
control the brightness of the display | ||
Controls the brightness of the display. | ||
|
||
:param int value: 0->15 dimmest to brightest | ||
""" | ||
if not 0 <= value <= 15: | ||
|
@@ -105,21 +113,23 @@ def brightness(self, value): | |
|
||
def show(self): | ||
""" | ||
update the display with recent changes in buffer | ||
Updates the display with recent changes in buffer. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Updates the display." |
||
""" | ||
for ypos in range(8): | ||
self.write_cmd(_DIGIT0 + ypos, self._buffer[ypos]) | ||
|
||
def fill(self, bit_value): | ||
""" | ||
set all buffer bits to a col | ||
Sets all buffer bits to a col | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be changed, but I'm not entirely sure what it does, so I'm not entirely sure what to set it to. If you can't think of something reasonable, then leave it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I know what it's doing, but haven't worked with a MAX7219 before so I can't say for sure. I made it a little more understandable, but still vague. I can put in an issue to have mrmcwethy clear up the docstring, and what it does... |
||
|
||
:param bit_value: int value > 0 set the buffer bit, else clears the buffer bit | ||
""" | ||
self.framebuf.fill(bit_value) | ||
|
||
def pixel(self, xpos, ypos, bit_value=None): | ||
""" | ||
set one buffer bit | ||
Set one buffer bit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I know what it's doing, but haven't worked with a MAX7219 before so I can't say for sure. I made it a little more understandable, but still vague. I can put in an issue to have mrmcwethy clear up the docstring, and what it does... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Thanks! |
||
|
||
:param xpos: x position to set bit | ||
:param ypos: y position to set bit | ||
:param bit_value: int value > 0 sets the buffer bit, else clears the buffer bit | ||
|
@@ -128,11 +138,11 @@ def pixel(self, xpos, ypos, bit_value=None): | |
self.framebuf.pixel(xpos, ypos, bit_value) | ||
|
||
def scroll(self, delta_x, delta_y): | ||
"""scolls the display using delta_x,delta_y""" | ||
"""Scolls the display using delta_x,delta_y.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Scrolls" |
||
self.framebuf.scroll(delta_x, delta_y) | ||
|
||
def write_cmd(self, cmd, data): | ||
"""writes a command to spi device""" | ||
"""Writes a command to spi device.""" | ||
#print('cmd {} data {}'.format(cmd,data)) | ||
self._chip_select.value = False | ||
with self._spi_device as my_spi_device: | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
.. If you created a package, create one automodule per module in the package. | ||
|
||
.. automodule:: adafruit_max7219.max7219 | ||
:members: | ||
|
||
.. automodule:: adafruit_max7219.matrices | ||
:members: | ||
|
||
.. automodule:: adafruit_max7219.bcddigits | ||
:members: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Display one digit."