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 7854eef..e1db249 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,15 +16,16 @@ deploy: provider: releases api_key: $GITHUB_TOKEN file_glob: true - file: bundles/* + file: $TRAVIS_BUILD_DIR/bundles/* skip_cleanup: true on: tags: true install: - - pip install pylint circuitpython-build-tools + - pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme script: - pylint adafruit_bme680.py - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py) - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-bme680 --library_location . + - cd docs && sphinx-build -E -W -b html . _build/html diff --git a/README.rst b/README.rst index a723e09..ed916d9 100644 --- a/README.rst +++ b/README.rst @@ -61,10 +61,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-bme680 --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. \ No newline at end of file diff --git a/adafruit_bme680.py b/adafruit_bme680.py index 701a7fa..ea3ef74 100644 --- a/adafruit_bme680.py +++ b/adafruit_bme680.py @@ -24,8 +24,8 @@ # pylint: disable=too-many-instance-attributes """ -`adafruit_bme680` -==================================================== +`adafruit_bme680` - Adafruit BME680 - Temperature, Humidity, Pressure & Gas Sensor +=================================================================================== CircuitPython driver from BME680 air quality sensor @@ -104,11 +104,11 @@ def __init__(self): # set up heater self._write(_BME680_BME680_RES_WAIT_0, [0x73, 0x64, 0x65]) self.sea_level_pressure = 1013.25 - """Pressure in hectoPascals at sea level. Used to calibrate `altitude`.""" - self.pressure_oversample = 4 - self.temperature_oversample = 8 - self.humidity_oversample = 2 - self.filter_size = 3 + """Pressure in hectoPascals at sea level. Used to calibrate ``altitude``.""" + self._pressure_oversample = 4 + self._temp_oversample = 8 + self._humidity_oversample = 2 + self._filter = 3 self._adc_pres = None self._adc_temp = None @@ -145,7 +145,7 @@ def humidity_oversample(self, sample_rate): @property def temperature_oversample(self): """The oversampling for temperature sensor""" - return _BME680_SAMPLERATES[self._pressure_oversample] + return _BME680_SAMPLERATES[self._temp_oversample] @temperature_oversample.setter def temperature_oversample(self, sample_rate): @@ -223,8 +223,8 @@ def humidity(self): @property def altitude(self): - """The altitude based on current `pressure` vs the sea level pressure - (`sea_level_pressure`) - which you must enter ahead of time)""" + """The altitude based on current ``pressure`` vs the sea level pressure + (``sea_level_pressure``) - which you must enter ahead of time)""" pressure = self.pressure # in Si units for hPascal return 44330 * (1.0 - math.pow(pressure / self.sea_level_pressure, 0.1903)) @@ -300,33 +300,6 @@ def _read_calibration(self): self._heat_val = self._read(0x00, 1)[0] self._sw_err = (self._read(0x04, 1)[0] & 0xF0) / 16 - """ - print("T1-3: %d %d %d" % (self._temp_calibration[0], - self._temp_calibration[1], - self._temp_calibration[2])) - print("P1-3: %d %d %d" % (self._pressure_calibration[0], - self._pressure_calibration[1], - self._pressure_calibration[2])) - print("P4-6: %d %d %d" % (self._pressure_calibration[3], - self._pressure_calibration[4], - self._pressure_calibration[5])) - print("P7-9: %d %d %d" % (self._pressure_calibration[6], - self._pressure_calibration[7], - self._pressure_calibration[8])) - print("P10: %d" % self._pressure_calibration[9]) - print("H1-3: %d %d %d" % (self._humidity_calibration[0], - self._humidity_calibration[1], - self._humidity_calibration[2])) - print("H4-7: %d %d %d %d" % (self._humidity_calibration[3], - self._humidity_calibration[4], - self._humidity_calibration[5], - self._humidity_calibration[6])) - print("G1-3: %d %d %d" % (self._gas_calibration[0], - self._gas_calibration[1], - self._gas_calibration[2])) - print("HR %d HV %d SWERR %d" % (self._heat_range, self._heat_val, self._sw_err)) - """ - def _read_byte(self, register): """Read a byte register value and return it""" return self._read(register, 1)[0] 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 ff2d555..62a2bc6 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 ------------------------------------------------ @@ -25,7 +25,7 @@ source_suffix = '.rst' # The master toctree document. -master_doc = 'README' +master_doc = 'index' # General information about the project. project = u'Adafruit BME680 Library' @@ -51,7 +51,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. @@ -68,6 +68,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 ---------------------------------------------- @@ -92,6 +95,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 = 'AdafruitBME680Librarydoc' diff --git a/docs/examples.rst b/docs/examples.rst new file mode 100644 index 0000000..6f9ae55 --- /dev/null +++ b/docs/examples.rst @@ -0,0 +1,8 @@ +Simple test +------------ + +Ensure your device works with this simple test. + +.. literalinclude:: ../examples/bme680_simpletest.py + :caption: examples/bme680_simpletest.py + :linenos: diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..8c4ff7e --- /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 + + Adafruit BME680 - Temperature, Humidity, Pressure and Gas Sensor + +.. 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/main.py b/examples/bme680_simpletest.py similarity index 97% rename from examples/main.py rename to examples/bme680_simpletest.py index c9ef49b..f1c095c 100644 --- a/examples/main.py +++ b/examples/bme680_simpletest.py @@ -1,7 +1,6 @@ -import gc +import time from busio import I2C import adafruit_bme680 -import time import board # Create library object using our Bus I2C port @@ -17,5 +16,5 @@ print("Humidity: %0.1f %%" % bme680.humidity) print("Pressure: %0.3f hPa" % bme680.pressure) print("Altitude = %0.2f meters" % bme680.altitude) - + time.sleep(1)