Skip to content

Commit

Permalink
Update README.rst and other associated files. (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmcwethy authored and tannewt committed Sep 5, 2017
1 parent 642933a commit 2a6b30d
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 30 deletions.
63 changes: 60 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Introduction
CircuitPython driver for the MAX7219 LED matrix driver chip.

.. warning:: This driver is still being updated for CircuitPython.

.. seealso:: See `here <https://github.com/adafruit/micropython-adafruit-max7219>`_ for the equivalent MicroPython driver.

Dependencies
Expand All @@ -33,7 +31,66 @@ This is easily achieved by downloading
Usage Example
=============

TODO
Examples
********

adafruit_max7219.Matrix8x8 Example
----------------------------------

.. code-block:: python
from adafruit_max7219 import matrices
from board import TX, RX, A2
import busio
import digitalio
import time
clk = RX
din = TX
cs = digitalio.DigitalInOut(A2)
spi = busio.SPI(clk, MOSI=din)
display = matrices.Matrix8x8(spi, cs)
while True:
display.brightness(3)
display.fill(1)
display.pixel(3, 3)
display.pixel(3, 4)
display.pixel(4, 3)
display.pixel(4, 4)
display.show()
time.sleep(3.0)
display.clear_all()
s = 'Hello, World!'
for c in range(len(s)*8):
display.fill(0)
display.text(s,-c,0)
display.show()
time.sleep(0.25)
adafruit_max7219.BCDDigits Example
----------------------------------

.. code-block:: python
from adafruit_max7219 import bcddigits
from board import TX, RX, A2
import bitbangio
import digitalio
clk = RX
din = TX
cs = digitalio.DigitalInOut(A2)
spi = bitbangio.SPI(clk, MOSI=din)
display = bcddigits.BCDDigits(spi, cs, nDigits=8)
display.clear_all()
display.show_str(0,'{:9.2f}'.format(-1234.56))
display.show()
Contributing
============
Expand Down
11 changes: 7 additions & 4 deletions adafruit_max7219/matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
class Matrix8x8(max7219.MAX7219):
def __init__(self, spi, cs):
"""
:param object spi: an spi busio or spi bitbangio object
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
:param object spi: an spi busio or spi bitbangio object
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
"""
super().__init__(8,8,spi,cs)

Expand All @@ -48,14 +48,18 @@ def init_display(self):
(_DECODEMODE, 0),
(_SHUTDOWN, 1),
):
self.write_cmd(cmd, data)
self.write_cmd(cmd, data)

self.fill(0)
self.show()

def text(self, str, x, y, col=1):
"""
draw text in the 8x8 matrix.
:param int x: x position of LED in matrix
:param int y: y position of LED in matrix
:param string str: string to place in to display
"""
self.framebuf.text(str, x, y, col)

Expand All @@ -64,4 +68,3 @@ def clear_all(self):
unlights all matrix leds
"""
self.fill(0)

107 changes: 104 additions & 3 deletions api.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,106 @@

.. If you created a package, create one automodule per module in the package.
Module classes
==============

.. automodule:: adafruit_max7219
:members:
Matrices
********

.. module:: adafruit_max7219.matrices

.. class:: Matrix8x8(spi, cs)

Driver for a single MAX7219-based 8x8 LED matrix.

:param object spi: an spi busio or spi bitbangio object
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal

.. method:: brightness(value)

control the brightness of the display

:param int value: 0->15 dimmest to brightest

.. method:: fill(color)

Fill the whole matrix with a specified color.

:param int color: None or False or 0 turn LED off, anything else turns LED on

.. method:: pixel(x, y, color=None)

Set the color of a single pixel.

:param int x: x postiion of LED in matrix
:param int y: y position of LED in matrix
:param int color: value > zero lights the decimal point, else unlights the point

.. method:: text(x, y, str)

Position and set text on display; used for text scrolling

:param int x: x postiion of LED in matrix
:param int y: y position of LED in matrix
:param string str: string to place in to display

.. method:: clear_all()

sets all leds to off; same as fill(0)

.. method:: show()

Update the display.


BCDDigits
*********

.. module:: adafruit_max7219.bcddigits

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

Driver for one to 8 MAX7219-based 7-Segment LED display.

: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

.. method:: set_digit(d, v)

set one digit in the display

:param int d: the digit position; zero-based
:param int v: integer ranging from 0->15

.. method:: show_dot(d, col=None)

set the decimal point for a digit

:param int d: the digit to set the decimal point zero-based
:param int col: value > zero lights the decimal point, else unlights the point

.. method:: show_str(s,str)

displays a numeric str in the display. shows digits 0-9, -, and .

:param int s: start position to show the numeric string
:param string str: the numeric string

.. method:: show_help(s)

display the word HELP in the display

:param int s: start position to show HELP

.. method:: brightness(value)

control the brightness of the display

:param int value: 0->15 dimmest to brightest

.. method:: clear_all()

sets all leds to off

.. method:: show()

Update the display.
6 changes: 3 additions & 3 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

# General information about the project.
project = u'Adafruit MAX7219 Library'
copyright = u'2017 Radomir Dopieralski'
author = u'Radomir Dopieralski'
copyright = u'2017, Adafruit CiruitPython and Bundle contributors'
author = u'Michael McWethy'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -137,6 +137,6 @@
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AdafruitMAX7219Library', u'Adafruit MAX7219 Library Documentation',
author, 'AdafruitMAX7219Library', 'One line description of project.',
author, 'AdafruitMAX7219Library', 'Python driver classes for MAX7219 chip',
'Miscellaneous'),
]
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

# General information about the project.
project = u'Adafruit MAX7219'
copyright = u'2016, Radomir Dopieralski'
copyright = u'2017, Adafruit CiruitPython and Bundle contributors'

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

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

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

Expand Down
54 changes: 41 additions & 13 deletions docs/matrix.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Module classes
==============

Expand All @@ -8,24 +9,39 @@ Matrices

.. class:: Matrix8x8(spi, cs)

Driver for a single MAX7219-based LED matrix.
Driver for a single MAX7219-based 8x8 LED matrix.

:param object spi: an spi busio or spi bitbangio object
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal

.. method:: brightness(value)

Set the brightness.
control the brightness of the display

:param int value: 0->15 dimmest to brightest

.. method:: fill(color)

Fill the whole matrix with a specified color.

:param int color: None or False or 0 turn LED off, anything else turns LED on

.. method:: pixel(x, y, color=None)

Set the color of a single pixel.

:param int x: x postiion of LED in matrix
:param int y: y position of LED in matrix
:param int color: value > zero lights the decimal point, else unlights the point

.. method:: text(x, y, str)

Position and set text on display; used for text scrolling


:param int x: x postiion of LED in matrix
:param int y: y position of LED in matrix
:param string str: string to place in to display

.. method:: clear_all()

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

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

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

: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

.. method:: set_digit(d, v)

set one digit in the display

:param int d: the digit position; zero-based
:param int v: integer ranging from 0->15

.. method:: show_dot(d, col=None)

set the decimal point for a digit

:param int d: the digit to set the decimal point zero-based
:param int col: value > zero lights the decimal point, else unlights the point

.. method:: show_str(s,str)

displays a numeric str in the display. shows digits 0-9, -, and .

:param int s: start position to show the numeric string
:param string str: the numeric string

.. method:: show_help(s)

display the word HELP in the display

.. method:: brightness(value)

Set the brightness.
:param int s: start position to show HELP

.. method:: pixel(x, y, color=None)
.. method:: brightness(value)

Set the color of a single pixel.
control the brightness of the display

:param int value: 0->15 dimmest to brightest

.. method:: clear_all()

Expand Down

0 comments on commit 2a6b30d

Please sign in to comment.