Skip to content

improving_docs #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ To install in a virtual environment in your current project:
Usage Example
=============

.. code-block:: python
.. code-block:: python3

import time
import board
import busio
import adafruit_vcnl4040

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()
sensor = adafruit_vcnl4040.VCNL4040(i2c)

while True:
Expand Down
26 changes: 11 additions & 15 deletions adafruit_vcnl4040.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
**Software and Dependencies:**

* Adafruit CircuitPython firmware for the supported boards:
https://github.com/adafruit/circuitpython/releases
https://circuitpython.org/downloads


* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
"""

from micropython import const
Expand Down Expand Up @@ -104,10 +104,9 @@ class VCNL4040: # pylint: disable=too-few-public-methods

import time
import board
import busio
import adafruit_vcnl4040

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()
sensor = adafruit_vcnl4040.VCNL4040(i2c)

while True:
Expand All @@ -128,8 +127,8 @@ class VCNL4040: # pylint: disable=too-few-public-methods
"""Interrupt enable. Interrupt setting are close, away, close and away, or disabled. Options
are: PS_INT_DISABLE, PS_INT_CLOSE, PS_INT_AWAY, PS_INT_CLOSE_AWAY."""
proximity_bits = RWBit(0x03, 11, register_width=2)
"""Proximity data output setting. ``0`` when proximity sensor output is 12 bits, ``1`` when
proximity sensor output is 16 bits."""
"""Proximity data output setting. :const:`0` when proximity sensor output is 12 bits,
:const:`1` when proximity sensor output is 16 bits."""

# PS_THDL_LM - PS low interrupt threshold setting
proximity_low_threshold = UnaryStruct(0x06, "<H")
Expand Down Expand Up @@ -178,10 +177,9 @@ def lux(self):

import time
import board
import busio
import adafruit_vcnl4040

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()
sensor = adafruit_vcnl4040.VCNL4040(i2c)

while True:
Expand All @@ -208,10 +206,9 @@ def light_integration_time(self):

import time
import board
import busio
import adafruit_vcnl4040

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()
sensor = adafruit_vcnl4040.VCNL4040(i2c)

sensor.light_integration_time = sensor.ALS_640MS
Expand All @@ -234,7 +231,7 @@ def light_integration_time(self, new_it):
sleep(it_delay_seconds)

light_interrupt = RWBit(0x00, 1, register_width=2)
"""Ambient light sensor interrupt enable. ``True`` to enable, and ``False`` to disable."""
"""Ambient light sensor interrupt enable. `True` to enable, and `False` to disable."""

# ALS_THDL_LM - ALS low interrupt threshold setting
light_low_threshold = UnaryStruct(0x02, "<H")
Expand Down Expand Up @@ -266,10 +263,9 @@ def white(self):

import time
import board
import busio
import adafruit_vcnl4040

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()
sensor = adafruit_vcnl4040.VCNL4040(i2c)

while True:
Expand All @@ -281,7 +277,7 @@ def white(self):
# PS_MS - White channel enable/disable, PS mode, PS protection setting, LED current
# White_EN - PS_MS_H, 7th bit - White channel enable/disable
white_shutdown = RWBit(0x04, 15, register_width=2)
"""White light channel shutdown. When ``True``, white light data is disabled."""
"""White light channel shutdown. When `True`, white light data is disabled."""

def __init__(self, i2c, address=0x60):
self.i2c_device = i2cdevice.I2CDevice(i2c, address)
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ Table of Contents
.. toctree::
:caption: Tutorials

Adafruit VCNL4040 Proximity and Lux Sensor Learning Guide <https://learn.adafruit.com/adafruit-vcnl4040-proximity-sensor/>

.. toctree::
:caption: Related Products

Adafruit VCNL4040 Proximity and Lux Sensor <https://www.adafruit.com/product/4161>

.. toctree::
:caption: Other Links
Expand Down
3 changes: 1 addition & 2 deletions examples/vcnl4040_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

import time
import board
import busio
import adafruit_vcnl4040

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()
sensor = adafruit_vcnl4040.VCNL4040(i2c)

while True:
Expand Down