From 8f293ec898f82ef3edcf9149e90272820fb97b56 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sun, 4 Mar 2018 16:37:04 -0600 Subject: [PATCH 1/8] renamed example; 1 learn guide will need updates --- examples/{simpletest.py => vcnl4010_simpletest.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{simpletest.py => vcnl4010_simpletest.py} (100%) diff --git a/examples/simpletest.py b/examples/vcnl4010_simpletest.py similarity index 100% rename from examples/simpletest.py rename to examples/vcnl4010_simpletest.py From c30a2de34667fba3b0906b87c9fe9fd41fd58ce1 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sun, 4 Mar 2018 16:39:23 -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 | 48 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 68 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?!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oQV zsdDb3@k2e`C$1I5ML5U0Qs0C1GAp^?!*`=|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 441fe467a4da7bdbc196fbc1b4f5bbe5f0fcf36d Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sun, 4 Mar 2018 16:40:18 -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 b9d68cb..a2f0259 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_vcnl4010.py - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py) - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-vcnl4010 --library_location . + - cd docs && sphinx-build -E -W -b html . _build/html From a505ab336eb2439cf089577e105f8c7b7aeef631 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sun, 4 Mar 2018 16:41:33 -0600 Subject: [PATCH 4/8] updated README --- README.rst | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 24ad347..33cec99 100644 --- a/README.rst +++ b/README.rst @@ -10,6 +10,10 @@ Introduction :target: https://discord.gg/nBQh6qu :alt: Discord +.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_VCNL4010.svg?branch=master + :target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_VCNL4010 + :alt: Build Status + CircuitPython module for the VCNL4010 proximity and light sensor. Dependencies @@ -26,15 +30,7 @@ This is easily achieved by downloading Usage Example ============= -See examples/simpletest.py for an example of the usage. - -API Reference -============= - -.. toctree:: - :maxdepth: 2 - - api +See examples/vcnl4010_simpletest.py for an example of the usage. Contributing ============ @@ -66,3 +62,26 @@ Then run the build: .. code-block:: shell circuitpython-build-bundles --filename_prefix adafruit-circuitpython-vcnl4010 --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 + + cd docs + sphinx-build -E -W -b html . _build/html + +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. From e142d70ec2506697995b8e87e2755c17788aefd2 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sun, 4 Mar 2018 16:44:20 -0600 Subject: [PATCH 5/8] updated info docstring; removed 'get/set' in docstrings --- adafruit_vcnl4010.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/adafruit_vcnl4010.py b/adafruit_vcnl4010.py index 7ba9cea..8d996a6 100644 --- a/adafruit_vcnl4010.py +++ b/adafruit_vcnl4010.py @@ -24,9 +24,23 @@ ==================================================== CircuitPython module for the VCNL4010 proximity and light sensor. See -examples/simpletest.py for an example of the usage. +examples/vcnl4010_simpletest.py for an example of the usage. * Author(s): Tony DiCola + +Implementation Notes +-------------------- + +**Hardware:** + +* Adafruit `VCNL4010 Proximity/Light sensor breakout + `_ (Product ID: 466) + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards: + https://github.com/adafruit/circuitpython/releases +* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice """ from micropython import const @@ -114,7 +128,7 @@ def _write_u8(self, address, val): @property def led_current(self): - """Get and set the current of the LED. The value is in units of 10mA + """The current of the LED. The value is in units of 10mA and can only be set to 0 (0mA/off) to 20 (200mA). See the datasheet for how LED current impacts proximity measurements. The default is 200mA. @@ -128,7 +142,7 @@ def led_current(self, val): @property def led_current_mA(self): - """Get and set the current of the LED in milli-amps. The value here is + """The current of the LED in milli-amps. The value here is specified in a milliamps from 0-200. Note that this value will be quantized down to a smaller less-accurate value as the chip only supports current changes in 10mA increments, i.e. a value of 123 mA will @@ -144,7 +158,7 @@ def led_current_mA(self, val): @property def frequency(self): - """Get and set the frequency of proximity measurements. Must be a value + """The frequency of proximity measurements. Must be a value of: - FREQUENCY_3M125: 3.125 Mhz - FREQUENCY_1M5625: 1.5625 Mhz @@ -168,7 +182,7 @@ def frequency(self, val): # pylint: disable=inconsistent-return-statements @property def proximity(self): - """Get the detected proximity of an object in front of the sensor. This + """Returns the detected proximity of an object in front of the sensor. This is a unit-less unsigned 16-bit value (0-65535) INVERSELY proportional to the distance of an object in front of the sensor (up to a max of ~200mm). For example a value of 10 is an object farther away than a @@ -189,7 +203,7 @@ def proximity(self): @property def ambient(self): - """Get the detected ambient light in front of the sensor. This is + """Returns the detected ambient light in front of the sensor. This is a unit-less unsigned 16-bit value (0-65535) with higher values for more detected light. See the ambient_lux property for a value in lux. """ @@ -208,7 +222,7 @@ def ambient(self): @property def ambient_lux(self): - """Get the detected ambient light in front of the sensor as a value in + """Returns the detected ambient light in front of the sensor as a value in lux. """ return self.ambient * _VCNL4010_AMBIENT_LUX_SCALE From a670761084705866d65e0c59861eab666983f412 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sun, 4 Mar 2018 16:53:28 -0600 Subject: [PATCH 6/8] sphinx fix --- adafruit_vcnl4010.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/adafruit_vcnl4010.py b/adafruit_vcnl4010.py index 8d996a6..f4a3005 100644 --- a/adafruit_vcnl4010.py +++ b/adafruit_vcnl4010.py @@ -158,12 +158,14 @@ def led_current_mA(self, val): @property def frequency(self): - """The frequency of proximity measurements. Must be a value - of: - - FREQUENCY_3M125: 3.125 Mhz - - FREQUENCY_1M5625: 1.5625 Mhz - - FREQUENCY_781K25: 781.25 Khz - - FREQUENCY_390K625: 390.625 Khz (default) + """ + The frequency of proximity measurements. Must be a value of: + + - FREQUENCY_3M125: 3.125 Mhz + - FREQUENCY_1M5625: 1.5625 Mhz + - FREQUENCY_781K25: 781.25 Khz + - FREQUENCY_390K625: 390.625 Khz (default) + See the datasheet for how frequency changes the proximity detection accuracy. """ From 2bf51887e2db38245572a6cbce8db502b92e7dd5 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Sun, 4 Mar 2018 16:56:47 -0600 Subject: [PATCH 7/8] sphinx fix; how did i miss that --- adafruit_vcnl4010.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_vcnl4010.py b/adafruit_vcnl4010.py index f4a3005..6d8e080 100644 --- a/adafruit_vcnl4010.py +++ b/adafruit_vcnl4010.py @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. """ -`Adafruit_VCNL4010` +`adafruit_vcnl4010` ==================================================== CircuitPython module for the VCNL4010 proximity and light sensor. See From ff79ea04251c13ec1a30b5fda23da45e63f1dd8a Mon Sep 17 00:00:00 2001 From: sommersoft Date: Tue, 6 Mar 2018 20:53:37 -0600 Subject: [PATCH 8/8] updated docstrings; removed 'returns' --- adafruit_vcnl4010.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adafruit_vcnl4010.py b/adafruit_vcnl4010.py index 6d8e080..2662c1c 100644 --- a/adafruit_vcnl4010.py +++ b/adafruit_vcnl4010.py @@ -184,7 +184,7 @@ def frequency(self, val): # pylint: disable=inconsistent-return-statements @property def proximity(self): - """Returns the detected proximity of an object in front of the sensor. This + """The detected proximity of an object in front of the sensor. This is a unit-less unsigned 16-bit value (0-65535) INVERSELY proportional to the distance of an object in front of the sensor (up to a max of ~200mm). For example a value of 10 is an object farther away than a @@ -205,7 +205,7 @@ def proximity(self): @property def ambient(self): - """Returns the detected ambient light in front of the sensor. This is + """The detected ambient light in front of the sensor. This is a unit-less unsigned 16-bit value (0-65535) with higher values for more detected light. See the ambient_lux property for a value in lux. """ @@ -224,7 +224,7 @@ def ambient(self): @property def ambient_lux(self): - """Returns the detected ambient light in front of the sensor as a value in + """The detected ambient light in front of the sensor as a value in lux. """ return self.ambient * _VCNL4010_AMBIENT_LUX_SCALE