From 860b0355eb8b01e46fa48eb99b3273a36d065116 Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 21 Feb 2018 10:44:43 -0500 Subject: [PATCH 1/2] Fix autodoc --- README.rst | 32 ++++++++++++++++++++++++++++++-- conf.py | 2 +- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 72eef5b..78862ab 100644 --- a/README.rst +++ b/README.rst @@ -23,10 +23,38 @@ Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading `the Adafruit library and driver bundle `_. -Usage Example +Usage Notes ============= -TODO +See `the guide `_ +for wiring and installation instructions. + +First, import the library: + +.. code:: python + import busio + import adafruit_sgp30 + +Next, initialize the I2C bus object: + +.. code:: python + from board import * + i2c_bus = busio.I2C(board.SCL, board.SDA, frequency=100000) + +Since we have the I2C bus object, we can now use it to instantiate the SGP30 object: + +.. code:: python + sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c_bus) + +Reading from the Sensor +-------------- + +To read from the sensor: + +.. code:: python + co2eq, tvoc = sgp30.iaq_measure() + print("CO2eq = %d ppm \t TVOC = %d ppb" % (co2eq, tvoc)) + API Reference ============= diff --git a/conf.py b/conf.py index 5303696..72a11cb 100644 --- a/conf.py +++ b/conf.py @@ -18,7 +18,7 @@ # Uncomment the below if you use native CircuitPython modules such as # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. -# autodoc_mock_imports = ["digitalio", "busio"] +autodoc_mock_imports = ["adafruit_bus_device", "micropython"] intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/bus_device/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} From 533ccd8a2c994a5390012813c5cd4226d0319457 Mon Sep 17 00:00:00 2001 From: brentrubell Date: Wed, 21 Feb 2018 19:38:26 -0500 Subject: [PATCH 2/2] Updated README.rst code->code-block --- README.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 78862ab..df75950 100644 --- a/README.rst +++ b/README.rst @@ -31,19 +31,22 @@ for wiring and installation instructions. First, import the library: -.. code:: python +.. code-block:: python + import busio import adafruit_sgp30 Next, initialize the I2C bus object: -.. code:: python +.. code-block:: python + from board import * i2c_bus = busio.I2C(board.SCL, board.SDA, frequency=100000) Since we have the I2C bus object, we can now use it to instantiate the SGP30 object: -.. code:: python +.. code-block:: python + sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c_bus) Reading from the Sensor @@ -51,7 +54,8 @@ Reading from the Sensor To read from the sensor: -.. code:: python +.. code-block:: python + co2eq, tvoc = sgp30.iaq_measure() print("CO2eq = %d ppm \t TVOC = %d ppb" % (co2eq, tvoc))