Skip to content

Commit 92125ae

Browse files
authored
Merge pull request #18 from jposada202020/improving_docs
improving_docs
2 parents 463dddd + 4d3adc1 commit 92125ae

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

adafruit_vcnl4010.py

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
2222
**Software and Dependencies:**
2323
24-
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
25-
https://github.com/adafruit/circuitpython/releases
24+
* Adafruit CircuitPython firmware for the supported boards:
25+
https://circuitpython.org/downloads
26+
2627
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
2728
"""
2829
from micropython import const
@@ -67,7 +68,38 @@
6768

6869

6970
class VCNL4010:
70-
"""Vishay VCNL4010 proximity and ambient light sensor."""
71+
"""Vishay VCNL4010 proximity and ambient light sensor.
72+
73+
:param ~busio.I2C i2c: The I2C bus the VCNL4010 is connected to
74+
:param int address: (optional) The I2C address of the device. Defaults to :const:`0x13`
75+
76+
**Quickstart: Importing and using the VCNL4010**
77+
78+
Here is an example of using the :class:`VCNL4010` class.
79+
First you will need to import the libraries to use the sensor
80+
81+
.. code-block:: python
82+
83+
import board
84+
import adafruit_vcnl4010
85+
86+
Once this is done you can define your `board.I2C` object and define your sensor object
87+
88+
.. code-block:: python
89+
90+
i2c = board.I2C() # uses board.SCL and board.SDA
91+
sensor = adafruit_vcnl4010.VCNL4010(i2c)
92+
93+
Now you have access to the :attr:`sensor.proximity` and
94+
:attr:`ambient_lux` attributes
95+
96+
97+
.. code-block:: python
98+
99+
proximity = sensor.proximity
100+
ambient_lux = sensor.ambient_lux
101+
102+
"""
71103

72104
# Class-level buffer for reading and writing data with the sensor.
73105
# This reduces memory allocations but means the code is not re-entrant or
@@ -127,7 +159,7 @@ def led_current_mA(self):
127159
supports current changes in 10mA increments, i.e. a value of 123 mA will
128160
actually use 120 mA. See the datasheet for how the LED current impacts
129161
proximity measurements, and the led_current property to explicitly set
130-
values without quanitization or unit conversion.
162+
values without quantization or unit conversion.
131163
"""
132164
return self.led_current * 10
133165

@@ -186,7 +218,7 @@ def proximity(self):
186218
def ambient(self):
187219
"""The detected ambient light in front of the sensor. This is
188220
a unit-less unsigned 16-bit value (0-65535) with higher values for
189-
more detected light. See the ambient_lux property for a value in lux.
221+
more detected light. See the :attr:`ambient_lux property` for a value in lux.
190222
"""
191223
# Clear interrupt.
192224
status = self._read_u8(_VCNL4010_INTSTAT)

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
VCNL4010 Proximity/Light sensor Learning Guide <https://learn.adafruit.com/using-vcnl4010-proximity-sensor/>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

examples/vcnl4010_simpletest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
# Simple demo of the VCNL4010 proximity and light sensor.
55
# Will print the proximity and ambient light every second.
66
import time
7-
87
import board
9-
import busio
10-
118
import adafruit_vcnl4010
129

1310

14-
# Initialize I2C bus and VCNL4010 module.
15-
i2c = busio.I2C(board.SCL, board.SDA)
11+
i2c = board.I2C()
1612
sensor = adafruit_vcnl4010.VCNL4010(i2c)
1713

1814
# You can optionally adjust the sensor LED current. The default is 200mA

0 commit comments

Comments
 (0)