diff --git a/readthedocs.yml b/.readthedocs.yml similarity index 100% rename from readthedocs.yml rename to .readthedocs.yml diff --git a/.travis.yml b/.travis.yml index 9a50ef8..508d24a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/README.rst b/README.rst index 4edaa4a..2d9a7ff 100644 --- a/README.rst +++ b/README.rst @@ -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. @@ -64,10 +64,49 @@ Contributions are welcome! Please read our `Code of Conduct `_ 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 `_ 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. diff --git a/adafruit_is31fl3731.py b/adafruit_is31fl3731.py index 597d455..932a9c2 100644 --- a/adafruit_is31fl3731.py +++ b/adafruit_is31fl3731.py @@ -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 -`_ + `_ + * `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings -`_ + `_ -* 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 @@ -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 @@ -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) @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/docs/_static/favicon.ico b/docs/_static/favicon.ico new file mode 100644 index 0000000..5aca983 Binary files /dev/null and b/docs/_static/favicon.ico differ diff --git a/api.rst b/docs/api.rst similarity index 100% rename from api.rst rename to docs/api.rst diff --git a/conf.py b/docs/conf.py similarity index 90% rename from conf.py rename to docs/conf.py index e53fe82..3c2051d 100644 --- a/conf.py +++ b/docs/conf.py @@ -2,7 +2,7 @@ import os import sys -sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath('..')) # -- General configuration ------------------------------------------------ @@ -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' @@ -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. @@ -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 ---------------------------------------------- @@ -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' diff --git a/docs/examples.rst b/docs/examples.rst new file mode 100644 index 0000000..9fd72fe --- /dev/null +++ b/docs/examples.rst @@ -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 `_. \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..1c32e9a --- /dev/null +++ b/docs/index.rst @@ -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 + +.. toctree:: + :caption: Other Links + + Download + CircuitPython Reference Documentation + CircuitPython Support Forum + Discord Chat + Adafruit Learning System + Adafruit Blog + Adafruit Store + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/examples/simple.py b/examples/is31fl3731_simpletest.py similarity index 100% rename from examples/simple.py rename to examples/is31fl3731_simpletest.py diff --git a/setup.py b/setup.py deleted file mode 100644 index 430f044..0000000 --- a/setup.py +++ /dev/null @@ -1,18 +0,0 @@ -from distutils.core import setup - - -setup( - name='adafruit-is31fl3731', - py_modules=['adafruit_is31fl3731'], - version="1.0.1", - description="Driver for CircuitPython for the IS31FL3731 LED matrix.", - long_description="""\ -Driver for the IS31FL3731-based charlieplexed LED matrices and CharlieWing.""", - author='Radomir Dopieralski', - author_email='micropython@sheep.art.pl', - classifiers = [ - 'Development Status :: 6 - Mature', - 'Programming Language :: Python :: 3', - 'License :: OSI Approved :: MIT License', - ], -)