Skip to content

Commit

Permalink
Merge pull request #9 from sommersoft/new_docs
Browse files Browse the repository at this point in the history
Improve Ref Docs
  • Loading branch information
kattni authored Mar 1, 2018
2 parents e5f5164 + cf4191f commit dd6811e
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 61 deletions.
File renamed without changes.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ deploy:
provider: releases
api_key: $GITHUB_TOKEN
file_glob: true
file: bundles/*
file: $TRAVIS_BUILD_DIR/bundles/*
skip_cleanup: true
overwrite: true
on:
tags: true

install:
- pip install pylint circuitpython-build-tools
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme

script:
- pylint adafruit_is31fl3731.py
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-is31fl3731 --library_location .
- cd docs && sphinx-build -E -W -b html . _build/html
55 changes: 47 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Introduction
:target: https://circuitpython.readthedocs.io/projects/is31fl3731/en/latest/
:alt: Documentation Status

.. image :: https://badges.gitter.im/adafruit/circuitpython.svg
:target: https://gitter.im/adafruit/circuitpython?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
:alt: Gitter
.. image :: https://img.shields.io/discord/327254708534116352.svg
:target: https://discord.gg/nBQh6qu
:alt: Discord
CircuitPython driver for the IS31FL3731 charlieplex IC.

Expand Down Expand Up @@ -64,10 +64,49 @@ Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/Adafruit_CircuitPython_is31fl3731/blob/master/CODE_OF_CONDUCT.md>`_
before contributing to help this project stay welcoming.

API Reference
=============
Building locally
================

To build this library locally you'll need to install the
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.

.. code-block:: shell
python3 -m venv .env
source .env/bin/activate
pip install circuitpython-build-tools
Once installed, make sure you are in the virtual environment:

.. code-block:: shell
source .env/bin/activate
Then run the build:

.. code-block:: shell
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-is31fl3731 --library_location .
Sphinx documentation
-----------------------

Sphinx is used to build the documentation based on rST files and comments in the code. First,
install dependencies (feel free to reuse the virtual environment from above):

.. code-block:: shell
python3 -m venv .env
source .env/bin/activate
pip install Sphinx sphinx-rtd-theme
Now, once you have the virtual environment activated:

.. code-block:: shell
.. toctree::
:maxdepth: 2
cd docs
sphinx-build -E -W -b html . _build/html
api
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
locally verify it will pass.
84 changes: 54 additions & 30 deletions adafruit_is31fl3731.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,24 @@
CircuitPython driver for the IS31FL3731 charlieplex IC.
This driver supports the following hardware:
* Author(s): Tony DiCola
Implementation Notes
--------------------
**Hardware:**
* `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731
<https://www.adafruit.com/product/2946>`_
<https://www.adafruit.com/product/2946>`_
* `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings
<https://www.adafruit.com/product/2965>`_
<https://www.adafruit.com/product/2965>`_
* Author(s): Tony DiCola
**Software and Dependencies:**
* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
https://github.com/adafruit/circuitpython/releases
"""

# imports
Expand Down Expand Up @@ -68,9 +78,11 @@
_COLOR_OFFSET = const(0x24)

class Matrix:
"""The Matrix class support the main function for driving the 16x9 matrix Display
:param ~adafruit_bus_device.i2c_device i2c_device: the connected i2c bus i2c_device
:param address: the device address; defaults to 0x74
"""
The Matrix class support the main function for driving the 16x9 matrix Display
:param ~adafruit_bus_device.i2c_device i2c_device: the connected i2c bus i2c_device
:param address: the device address; defaults to 0x74
"""
width = 16
height = 9
Expand Down Expand Up @@ -144,16 +156,20 @@ def reset(self):
self.sleep(False)

def sleep(self, value):
"""Set the Software Shutdown Register bit
:param value: True to set software shutdown bit; False unset
"""
Set the Software Shutdown Register bit
:param value: True to set software shutdown bit; False unset
"""
return self._register(_CONFIG_BANK, _SHUTDOWN_REGISTER, not value)

def autoplay(self, delay=0, loops=0, frames=0):
"""Start autoplay
:param delay: in ms
:param loops: number of loops - 0->7
:param frames: number of frames: 0->7
"""
Start autoplay
:param delay: in ms
:param loops: number of loops - 0->7
:param frames: number of frames: 0->7
"""
if delay == 0:
self._mode(_PICTURE_MODE)
Expand All @@ -171,12 +187,14 @@ def autoplay(self, delay=0, loops=0, frames=0):


def fade(self, fade_in=None, fade_out=None, pause=0):
"""Start and stop the fade feature. If both fade_in and fade_out are None (the
"""
Start and stop the fade feature. If both fade_in and fade_out are None (the
default), the breath feature is used for fading. if fade_in is None, then
fade_in = fade_out. If fade_out is None, then fade_out = fade_in
:param fade_in: positive number; 0->100
:param fade-out: positive number; 0->100
:param pause: breath register 2 pause value
:param fade_in: positive number; 0->100
:param fade-out: positive number; 0->100
:param pause: breath register 2 pause value
"""
if fade_in is None and fade_out is None:
self._register(_CONFIG_BANK, _BREATH2_REGISTER, 0)
Expand All @@ -197,9 +215,11 @@ def fade(self, fade_in=None, fade_out=None, pause=0):
self._register(_CONFIG_BANK, _BREATH2_REGISTER, 1 << 4 | pause)

def frame(self, frame=None, show=True):
"""Set the current frame
:param frame: frame number; 0-7 or None. If None function returns current frame
:param show: True to show the frame; False to don't force a show
"""
Set the current frame
:param frame: frame number; 0-7 or None. If None function returns current frame
:param show: True to show the frame; False to not show.
"""
if frame is None:
return self._frame
Expand Down Expand Up @@ -246,10 +266,12 @@ def blink(self, rate=None):
return None

def fill(self, color=None, blink=None, frame=None):
"""Fill the display with a brightness level
:param color: brightness 0->255
:param blink: True if blinking is required
:param frame: which frame to fill 0->7
"""
Fill the display with a brightness level
:param color: brightness 0->255
:param blink: True if blinking is required
:param frame: which frame to fill 0->7
"""
if frame is None:
frame = self._frame
Expand Down Expand Up @@ -279,12 +301,14 @@ def pixel_addr(x, y):

#pylint: disable-msg=too-many-arguments
def pixel(self, x, y, color=None, blink=None, frame=None):
"""Set blink or brightness for an x,y pixel
:param x: horizontal pixel position
:param y: vertical pixel position
:param color: brightness value 0->255
:param blink: True to blink
:param frame: the frame to set the pixel
"""
Blink or brightness for x-, y-pixel
:param x: horizontal pixel position
:param y: vertical pixel position
:param color: brightness value 0->255
:param blink: True to blink
:param frame: the frame to set the pixel
"""
if not 0 <= x <= self.width:
return None
Expand Down
Binary file added docs/_static/favicon.ico
Binary file not shown.
File renamed without changes.
15 changes: 12 additions & 3 deletions conf.py → docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os
import sys
sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('..'))

# -- General configuration ------------------------------------------------

Expand All @@ -28,7 +28,7 @@
source_suffix = '.rst'

# The master toctree document.
master_doc = 'README'
master_doc = 'index'

# General information about the project.
project = u'Adafruit IS31FL3731 Library'
Expand All @@ -54,7 +54,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -71,6 +71,9 @@
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False

# If this is True, todo emits a warning for each TODO entries. The default is False.
todo_emit_warnings = True


# -- Options for HTML output ----------------------------------------------

Expand All @@ -95,6 +98,12 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
html_favicon = '_static/favicon.ico'

# Output file base name for HTML help builder.
htmlhelp_basename = 'AdafruitIS31FL3731Librarydoc'

Expand Down
11 changes: 11 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Simple test
------------

Ensure your device works with this simple test.

.. literalinclude:: ../examples/is31fl3731_simpletest.py
:caption: examples/is31fl3731_simpletest.py
:linenos:


For other examples, see the GitHub `examples folder <https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731/tree/master/examples>`_.
47 changes: 47 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.. include:: ../README.rst

Table of Contents
=================

.. toctree::
:maxdepth: 4
:hidden:

self

.. toctree::
:caption: Examples

examples

.. toctree::
:caption: API Reference
:maxdepth: 3

api

.. toctree::
:caption: Tutorials

.. toctree::
:caption: Related Products

Charlieplex Devices <https://www.adafruit.com/?q=charlieplex>

.. toctree::
:caption: Other Links

Download <https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731/releases/latest>
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
Discord Chat <https://adafru.it/discord>
Adafruit Learning System <https://learn.adafruit.com>
Adafruit Blog <https://blog.adafruit.com>
Adafruit Store <https://www.adafruit.com>

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
File renamed without changes.
18 changes: 0 additions & 18 deletions setup.py

This file was deleted.

0 comments on commit dd6811e

Please sign in to comment.