Skip to content

Commit bd37ad8

Browse files
authored
Merge pull request #22 from jposada202020/improving_docs
improving_docs
2 parents 3790550 + f49165e commit bd37ad8

File tree

3 files changed

+45
-12
lines changed

3 files changed

+45
-12
lines changed

adafruit_tsl2591.py

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

@@ -79,9 +80,38 @@
7980

8081
class TSL2591:
8182
"""TSL2591 high precision light sensor.
82-
:param busio.I2C i2c: The I2C bus connected to the sensor
83-
:param int address: The I2C address of the sensor. If not specified
84-
the sensor default will be used.
83+
84+
:param ~busio.I2C i2c: The I2C bus the device is connected to
85+
:param int address: The I2C device address. Defaults to :const:`0x29`
86+
87+
88+
**Quickstart: Importing and using the device**
89+
90+
Here is an example of using the :class:`TSL2591` class.
91+
First you will need to import the libraries to use the sensor
92+
93+
.. code-block:: python
94+
95+
import board
96+
import adafruit_tsl2591
97+
98+
Once this is done you can define your `board.I2C` object and define your sensor object
99+
100+
.. code-block:: python
101+
102+
i2c = board.I2C() # uses board.SCL and board.SDA
103+
sensor = adafruit_tsl2591.TSL2591(i2c)
104+
105+
Now you have access to the :attr:`lux`, :attr:`infrared`
106+
:attr:`visible` and :attr:`full_spectrum` attributes
107+
108+
.. code-block:: python
109+
110+
lux = sensor.lux
111+
infrared = sensor.infrared
112+
visible = sensor.visible
113+
full_spectrum = sensor.full_spectrum
114+
85115
"""
86116

87117
# Class-level buffer to reduce memory usage and allocations.
@@ -229,7 +259,11 @@ def visible(self):
229259
@property
230260
def lux(self):
231261
"""Read the sensor and calculate a lux value from both its infrared
232-
and visible light channels. Note: ``lux`` is not calibrated!
262+
and visible light channels.
263+
264+
.. note::
265+
:attr:`lux` is not calibrated!
266+
233267
"""
234268
channel_0, channel_1 = self.raw_luminosity
235269

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 TSL2591 High Dynamic Range Digital Light Sensor Learning Guide <https://learn.adafruit.com/adafruit-tsl2591>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

examples/tsl2591_simpletest.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
# Simple demo of the TSL2591 sensor. Will print the detected light value
55
# every second.
66
import time
7-
87
import board
9-
import busio
10-
118
import adafruit_tsl2591
129

13-
# Initialize the I2C bus.
14-
i2c = busio.I2C(board.SCL, board.SDA)
10+
# Create sensor object, communicating over the board's default I2C bus
11+
i2c = board.I2C() # uses board.SCL and board.SDA
1512

1613
# Initialize the sensor.
1714
sensor = adafruit_tsl2591.TSL2591(i2c)

0 commit comments

Comments
 (0)