Skip to content

Commit be2f2d3

Browse files
authored
Merge pull request #11 from sommersoft/new_docs
Improve Ref Docs
2 parents dfabb5c + d033757 commit be2f2d3

10 files changed

+150
-19
lines changed
File renamed without changes.

.travis.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,15 +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
21+
overwrite: true
2122
on:
2223
tags: true
2324

2425
install:
25-
- pip install pylint circuitpython-build-tools
26+
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
2627

2728
script:
2829
- pylint adafruit_pca9685.py
2930
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3031
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-pca9685 --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html

README.rst

+47-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Dependencies
1717
This driver depends on:
1818

1919
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
20+
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
21+
* `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_
2022

2123
Please ensure all dependencies are available on the CircuitPython filesystem.
2224
This is easily achieved by downloading
@@ -25,7 +27,7 @@ This is easily achieved by downloading
2527
Usage Example
2628
=============
2729

28-
TODO
30+
See examples/pca9685_simpletest.py for a demo of the usage.
2931

3032
Contributing
3133
============
@@ -34,10 +36,49 @@ Contributions are welcome! Please read our `Code of Conduct
3436
<https://github.com/adafruit/Adafruit_CircuitPython_PCA9685/blob/master/CODE_OF_CONDUCT.md>`_
3537
before contributing to help this project stay welcoming.
3638

37-
API Reference
38-
=============
39+
Building locally
40+
================
41+
42+
To build this library locally you'll need to install the
43+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
44+
45+
.. code-block:: shell
46+
47+
python3 -m venv .env
48+
source .env/bin/activate
49+
pip install circuitpython-build-tools
50+
51+
Once installed, make sure you are in the virtual environment:
52+
53+
.. code-block:: shell
54+
55+
source .env/bin/activate
56+
57+
Then run the build:
58+
59+
.. code-block:: shell
60+
61+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-pca9685 --library_location .
62+
63+
Sphinx documentation
64+
-----------------------
65+
66+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
67+
install dependencies (feel free to reuse the virtual environment from above):
68+
69+
.. code-block:: shell
70+
71+
python3 -m venv .env
72+
source .env/bin/activate
73+
pip install Sphinx sphinx-rtd-theme
74+
75+
Now, once you have the virtual environment activated:
76+
77+
.. code-block:: shell
3978
40-
.. toctree::
41-
:maxdepth: 2
79+
cd docs
80+
sphinx-build -E -W -b html . _build/html
4281
43-
api
82+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
83+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
84+
locally verify it will pass.

adafruit_pca9685.py

+24-8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@
3131
outputs for specific uses instead of generic duty_cycle adjustments.
3232
3333
* Author(s): Scott Shawcroft
34+
35+
Implementation Notes
36+
--------------------
37+
38+
**Hardware:**
39+
40+
* Adafruit `16-Channel 12-bit PWM/Servo Driver - I2C interface - PCA9685
41+
<https://www.adafruit.com/product/815>`_ (Product ID: 815)
42+
43+
**Software and Dependencies:**
44+
45+
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
46+
https://github.com/adafruit/circuitpython/releases
47+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
48+
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
3449
"""
3550

3651
__version__ = "0.0.0-auto.0"
@@ -89,16 +104,17 @@ def __getitem__(self, index):
89104
return self._channels[index]
90105

91106
class PCA9685:
92-
"""Initialise the PCA9685 chip at ``address`` on ``i2c_bus``.
107+
"""
108+
Initialise the PCA9685 chip at ``address`` on ``i2c_bus``.
93109
94-
The internal reference clock is 25mhz but may vary slightly with environmental conditions and
95-
manufacturing variances. Providing a more precise ``reference_clock_speed`` can improve the
96-
accuracy of the frequency and duty_cycle computations. See the ``calibration.py`` example for
97-
how to derive this value by measuring the resulting pulse widths.
110+
The internal reference clock is 25mhz but may vary slightly with environmental conditions and
111+
manufacturing variances. Providing a more precise ``reference_clock_speed`` can improve the
112+
accuracy of the frequency and duty_cycle computations. See the ``calibration.py`` example for
113+
how to derive this value by measuring the resulting pulse widths.
98114
99-
:param ~busio.I2C i2c_bus: The I2C bus which the PCA9685 is connected to.
100-
:param int address: The I2C address of the PCA9685.
101-
:param int reference_clock_speed: The frequency of the internal reference clock in Herz.
115+
:param ~busio.I2C i2c_bus: The I2C bus which the PCA9685 is connected to.
116+
:param int address: The I2C address of the PCA9685.
117+
:param int reference_clock_speed: The frequency of the internal reference clock in Herz.
102118
"""
103119
# Registers:
104120
mode1_reg = UnaryStruct(0x00, '<B')

docs/_static/favicon.ico

4.31 KB
Binary file not shown.

api.rst renamed to docs/api.rst

File renamed without changes.

conf.py renamed to docs/conf.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
import sys
5-
sys.path.insert(0, os.path.abspath('.'))
5+
sys.path.insert(0, os.path.abspath('..'))
66

77
# -- General configuration ------------------------------------------------
88

@@ -27,7 +27,7 @@
2727
source_suffix = '.rst'
2828

2929
# The master toctree document.
30-
master_doc = 'README'
30+
master_doc = 'index'
3131

3232
# General information about the project.
3333
project = u'Adafruit PCA9685 Library'
@@ -53,7 +53,7 @@
5353
# List of patterns, relative to source directory, that match files and
5454
# directories to ignore when looking for source files.
5555
# This patterns also effect to html_static_path and html_extra_path
56-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env']
56+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
5757

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

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

7477
# -- Options for HTML output ----------------------------------------------
7578

@@ -94,6 +97,12 @@
9497
# so a file named "default.css" will overwrite the builtin "default.css".
9598
html_static_path = ['_static']
9699

100+
# The name of an image file (relative to this directory) to use as a favicon of
101+
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
102+
# pixels large.
103+
#
104+
html_favicon = '_static/favicon.ico'
105+
97106
# Output file base name for HTML help builder.
98107
htmlhelp_basename = 'AdafruitPCA9685Librarydoc'
99108

docs/examples.rst

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Simple test
2+
------------
3+
4+
Ensure your device works with this simple test.
5+
6+
.. literalinclude:: ../examples/pca9685_simpletest.py
7+
:caption: examples/pca9685_simpletest.py
8+
:linenos:
9+
10+
.. literalinclude:: ../examples/calibration.py
11+
:caption: examples/calibration.py
12+
:linenos:
13+
14+
.. literalinclude:: ../examples/servo.py
15+
:caption: examples/servo.py
16+
:linenos:

docs/index.rst

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.. include:: ../README.rst
2+
3+
Table of Contents
4+
=================
5+
6+
.. toctree::
7+
:maxdepth: 4
8+
:hidden:
9+
10+
self
11+
12+
.. toctree::
13+
:caption: Examples
14+
15+
examples
16+
17+
.. toctree::
18+
:caption: API Reference
19+
:maxdepth: 3
20+
21+
api
22+
23+
.. toctree::
24+
:caption: Tutorials
25+
26+
.. toctree::
27+
:caption: Related Products
28+
29+
Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface - PCA9685 <https://www.adafruit.com/product/815>
30+
31+
.. toctree::
32+
:caption: Other Links
33+
34+
Download <https://github.com/adafruit/Adafruit_CircuitPython_PCA9685/releases/latest>
35+
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
36+
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
37+
Discord Chat <https://adafru.it/discord>
38+
Adafruit Learning System <https://learn.adafruit.com>
39+
Adafruit Blog <https://blog.adafruit.com>
40+
Adafruit Store <https://www.adafruit.com>
41+
42+
Indices and tables
43+
==================
44+
45+
* :ref:`genindex`
46+
* :ref:`modindex`
47+
* :ref:`search`
File renamed without changes.

0 commit comments

Comments
 (0)