Skip to content

Commit 000283a

Browse files
committed
improving_docs
1 parent 56c1a61 commit 000283a

File tree

4 files changed

+54
-40
lines changed

4 files changed

+54
-40
lines changed

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,13 @@ To install in a virtual environment in your current project:
5555
Usage Example
5656
=============
5757

58-
.. code-block:: python
58+
.. code-block:: python3
5959
6060
import time
6161
import board
62-
import busio
6362
from adafruit_veml6070 import VEML6070
6463
65-
with busio.I2C(board.SCL, board.SDA) as i2c:
64+
with board.I2C() as i2c:
6665
uv = VEML6070(i2c)
6766
# Alternative constructors with parameters
6867
#uv = VEML6070(i2c, 'VEML6070_1_T')

adafruit_veml6070.py

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# https://github.com/adafruit/Adafruit_VEML6070
2222

2323
"""
24-
`adafruit_veml6070` - VEML6070 UV Sensor
24+
`adafruit_veml6070`
2525
====================================================
2626
2727
CircuitPython library to support VEML6070 UV Index sensor.
@@ -38,9 +38,10 @@
3838
3939
**Software and Dependencies:**
4040
41-
* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
42-
https://github.com/adafruit/circuitpython/releases
43-
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
41+
* Adafruit CircuitPython firmware for the supported boards:
42+
https://circuitpython.org/downloads
43+
44+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
4445
4546
**Notes:**
4647
@@ -84,34 +85,44 @@ class VEML6070:
8485
"""
8586
Driver base for the VEML6070 UV Light Sensor
8687
87-
:param i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
88-
:param str _veml6070_it: The integration time you'd like to set initially. Availble
89-
options: ``VEML6070_HALF_T``, ``VEML6070_1_T``, ``VEML6070_2_T``, and
90-
``VEML6070_4_T``. The higher the '_x_' value, the more accurate
88+
:param ~busio.I2C i2c_bus: The I2C bus the device is connected to
89+
:param str _veml6070_it: The integration time you'd like to set initially. Available
90+
options: :const:`VEML6070_HALF_T`, :const:`VEML6070_1_T`,
91+
:const:`VEML6070_2_T`, and
92+
:const:`VEML6070_4_T`. The higher the '_x_' value, the more accurate
9193
the reading is (at the cost of less samples per reading).
92-
Defaults to ``VEML6070_1_T`` if parameter not passed. To change
93-
setting after intialization, use
94-
``[veml6070].set_integration_time(new_it)``.
95-
:param bool ack: The inital setting of ``ACKnowledge`` on alert. Defaults to ``False``
96-
if parameter not passed. To change setting after intialization,
97-
use ``[veml6070].set_ack(new_ack)``.
94+
Defaults to :const:`VEML6070_1_T` if parameter not passed. To change
95+
setting after initialization,
96+
``VEML6070.set_integration_time(new_it)``.
97+
:param bool ack: The initial setting of ``ACKnowledge`` on alert. Defaults to `False`
98+
if parameter not passed. To change setting after initialization,
99+
use ``VEML6070.set_ack(new_ack)``.
100+
101+
102+
**Quickstart: Importing and using the device VEML6070**
103+
104+
Here is an example of using the :class:`VEML6070` class.
105+
First you will need to import the libraries to use the sensor
106+
107+
.. code-block:: python
98108
99-
Example:
109+
import board
110+
import adafruit_veml6070
100111
101-
.. code-block:: python
112+
Once this is done you can define your `board.I2C` object and define your sensor object
102113
103-
from board import *
104-
import busio, veml6070, time
114+
.. code-block:: python
105115
106-
with busio.I2C(SCL, SDA) as i2c:
107-
uv = veml6070.VEML6070(i2c, 'VEML6070_1_T', True)
116+
i2c = board.I2C() # uses board.SCL and board.SDA
117+
uv = adafruit_veml6070.VEML6070(i2c)
118+
119+
Now you have access to the :attr:`uv_raw` attribute and the calculate the risk level
120+
121+
.. code-block:: python
122+
123+
uv_raw = uv.uv_raw
124+
risk_level = uv.get_index(uv_raw)
108125
109-
# take 10 readings
110-
for j in range(10):
111-
uv_raw = uv.uv_raw
112-
risk_level = uv.get_index(uv_raw)
113-
print('Reading: ', uv_raw, ' | Risk Level: ', risk_level)
114-
time.sleep(1)
115126
"""
116127

117128
def __init__(self, i2c_bus, _veml6070_it="VEML6070_1_T", ack=False):
@@ -191,8 +202,8 @@ def ack(self, new_ack):
191202
def ack_threshold(self):
192203
"""
193204
The ACKnowledge Threshold, which alerts the host controller to value changes
194-
greater than the threshold. Available settings are: ``0`` = 102 steps; ``1`` = 145 steps.
195-
``0`` is the default setting.
205+
greater than the threshold. Available settings are: :const:`0` = 102 steps;
206+
:const:`1` = 145 steps. :const:`0` is the default setting.
196207
"""
197208
return self._ack_thd
198209

@@ -215,8 +226,8 @@ def integration_time(self):
215226
"""
216227
The Integration Time of the sensor, which is the refresh interval of the
217228
sensor. The higher the refresh interval, the more accurate the reading is (at
218-
the cost of less sampling). The available settings are: ``VEML6070_HALF_T``,
219-
``VEML6070_1_T``, ``VEML6070_2_T``, ``VEML6070_4_T``.
229+
the cost of less sampling). The available settings are: :const:`VEML6070_HALF_T`,
230+
:const:`VEML6070_1_T`, :const:`VEML6070_2_T`, :const:`VEML6070_4_T`.
220231
"""
221232
return self._it
222233

@@ -249,7 +260,7 @@ def sleep(self):
249260

250261
def wake(self):
251262
"""
252-
Wakes the VEML6070 from sleep. ``[veml6070].uv_raw`` will also wake from sleep.
263+
Wakes the VEML6070 from sleep. :class:`VEML6070.uv_raw` will also wake from sleep.
253264
"""
254265
self.buf[0] = (
255266
self._ack << 5
@@ -262,17 +273,20 @@ def wake(self):
262273

263274
def get_index(self, _raw):
264275
"""
265-
Calculates the UV Risk Level based on the captured UV reading. Requres the ``_raw``
266-
argument (from ``veml6070.uv_raw``). Risk level is available for Integration Times (IT)
276+
Calculates the UV Risk Level based on the captured UV reading. Requires the ``_raw``
277+
argument (from :meth:`veml6070.uv_raw`). Risk level is available for Integration Times (IT)
267278
1, 2, & 4. The result is automatically scaled to the current IT setting.
268279
269-
LEVEL* UV Index
270-
===== ========
280+
========= ========
281+
LEVEL* UV Index
282+
========= ========
271283
LOW 0-2
272284
MODERATE 3-5
273285
HIGH 6-7
274286
VERY HIGH 8-10
275287
EXTREME >=11
288+
========= ========
289+
276290
277291
* Not to be considered as accurate condition reporting.
278292
Calculation is based on VEML6070 Application Notes:

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+
Adafruit VEML6070 UV Index Sensor Breakout Learning Guide <https://learn.adafruit.com/adafruit-veml6070-uv-light-sensor-breakout>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

examples/veml6070_simpletest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
# VEML6070 Driver Example Code
55

66
import time
7-
import busio
87
import board
98
import adafruit_veml6070
109

11-
with busio.I2C(board.SCL, board.SDA) as i2c:
10+
with board.I2C() as i2c:
1211
uv = adafruit_veml6070.VEML6070(i2c)
1312
# Alternative constructors with parameters
1413
# uv = adafruit_veml6070.VEML6070(i2c, 'VEML6070_1_T')

0 commit comments

Comments
 (0)