From 76cd9435e36d5c901597c4079cd2a3ed3f410ca2 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Fri, 23 Feb 2018 21:45:04 -0600 Subject: [PATCH 1/8] renamed example --- examples/{main.py => bme680_simpletest.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{main.py => bme680_simpletest.py} (100%) diff --git a/examples/main.py b/examples/bme680_simpletest.py similarity index 100% rename from examples/main.py rename to examples/bme680_simpletest.py From d81552520b670f99fd486d1221366b3babcc03fd Mon Sep 17 00:00:00 2001 From: sommersoft Date: Fri, 23 Feb 2018 21:48:09 -0600 Subject: [PATCH 2/8] setup docs folder --- docs/_static/favicon.ico | Bin 0 -> 4414 bytes api.rst => docs/api.rst | 0 conf.py => docs/conf.py | 15 ++++++++++--- docs/examples.rst | 8 +++++++ docs/index.rst | 47 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 docs/_static/favicon.ico rename api.rst => docs/api.rst (100%) rename conf.py => docs/conf.py (90%) create mode 100644 docs/examples.rst create mode 100644 docs/index.rst diff --git a/docs/_static/favicon.ico b/docs/_static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..5aca98376a1f7e593ebd9cf41a808512c2135635 GIT binary patch literal 4414 zcmd^BX;4#F6n=SG-XmlONeGrD5E6J{RVh+e928U#MG!$jWvO+UsvWh`x&VqGNx*en zx=qox7Dqv{kPwo%fZC$dDwVpRtz{HzTkSs8QhG0)%Y=-3@Kt!4ag|JcIo?$-F|?bXVS9UDUyev>MVZQ(H8K4#;BQW-t2CPorj8^KJrMX}QK zp+e<;4ldpXz~=)2GxNy811&)gt-}Q*yVQpsxr@VMoA##{)$1~=bZ1MmjeFw?uT(`8 z^g=09<=zW%r%buwN%iHtuKSg|+r7HkT0PYN*_u9k1;^Ss-Z!RBfJ?Un4w(awqp2b3 z%+myoFis_lTlCrGx2z$0BQdh+7?!JK#9K9@Z!VrG zNj6gK5r(b4?YDOLw|DPRoN7bd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|Nm(vWz3j*j*8ucum2;r0^-6Aca=Gv) zc%}&;!+_*S2tlnnJnz0EKeRmw-Y!@9ob!XQBwiv}^u9MkaXHvM=!<3YX;+2#5Cj5pp?FEK750S3BgeSDtaE^ zXUM@xoV6yBFKfzvY20V&Lr0yC + +.. 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` From 4cb7d7cc661b3f1ed14ede90ad1e99afdb2438d2 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Fri, 23 Feb 2018 21:49:33 -0600 Subject: [PATCH 3/8] updated .travis & .readthedocs yml --- readthedocs.yml => .readthedocs.yml | 0 .travis.yml | 5 +++-- 2 files changed, 3 insertions(+), 2 deletions(-) rename readthedocs.yml => .readthedocs.yml (100%) 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 From 8465f18089af2ee738617431e8c9f34e748b7d68 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Fri, 23 Feb 2018 21:50:42 -0600 Subject: [PATCH 4/8] updated README --- README.rst | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) 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 From b043cf5694eda18725cc7a67e0dc7ed7d1ff1a6c Mon Sep 17 00:00:00 2001 From: sommersoft Date: Fri, 23 Feb 2018 21:54:12 -0600 Subject: [PATCH 5/8] updated doc strings --- adafruit_bme680.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/adafruit_bme680.py b/adafruit_bme680.py index 701a7fa..1b3b667 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,7 +104,7 @@ 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`.""" + """Pressure in hectoPascals at sea level. Used to calibrate ``altitude``.""" self.pressure_oversample = 4 self.temperature_oversample = 8 self.humidity_oversample = 2 @@ -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)) From 2296f0524ea4b5997c384f9b166e1cddc59798a4 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Fri, 23 Feb 2018 22:54:50 -0600 Subject: [PATCH 6/8] pylint fixes --- examples/bme680_simpletest.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/bme680_simpletest.py b/examples/bme680_simpletest.py index c9ef49b..f1c095c 100644 --- a/examples/bme680_simpletest.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) From aaa757e37a6008202d6fdf027f77e167f3fe7ca8 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Fri, 23 Feb 2018 22:56:37 -0600 Subject: [PATCH 7/8] pylint flagged the updated attributes; matched them in __init__ to their names in functions; needs to be tested --- adafruit_bme680.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/adafruit_bme680.py b/adafruit_bme680.py index 1b3b667..5883395 100644 --- a/adafruit_bme680.py +++ b/adafruit_bme680.py @@ -105,10 +105,10 @@ def __init__(self): 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 + 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): @@ -300,6 +300,7 @@ def _read_calibration(self): self._heat_val = self._read(0x00, 1)[0] self._sw_err = (self._read(0x04, 1)[0] & 0xF0) / 16 + # pylint disable=pointless-string-statement """ print("T1-3: %d %d %d" % (self._temp_calibration[0], self._temp_calibration[1], @@ -326,7 +327,7 @@ def _read_calibration(self): 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] From 46b72707eb22ff1643b85f7ef828226fa84aaafb Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sat, 24 Feb 2018 10:00:31 -0600 Subject: [PATCH 8/8] pylint fix; removed large debug printout...seems leftover from Arduino lib --- adafruit_bme680.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/adafruit_bme680.py b/adafruit_bme680.py index 5883395..ea3ef74 100644 --- a/adafruit_bme680.py +++ b/adafruit_bme680.py @@ -300,34 +300,6 @@ def _read_calibration(self): self._heat_val = self._read(0x00, 1)[0] self._sw_err = (self._read(0x04, 1)[0] & 0xF0) / 16 - # pylint disable=pointless-string-statement - """ - 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]