Skip to content

Commit

Permalink
Merge pull request #22 from jposada202020/improving_docs
Browse files Browse the repository at this point in the history
improving_docs
  • Loading branch information
evaherrada committed Apr 26, 2021
2 parents 3790550 + f49165e commit bd37ad8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
48 changes: 41 additions & 7 deletions adafruit_tsl2591.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
**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
* Adafruit CircuitPython firmware for the supported boards:
https://circuitpython.org/downloads
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
"""
from micropython import const

Expand Down Expand Up @@ -79,9 +80,38 @@

class TSL2591:
"""TSL2591 high precision light sensor.
:param busio.I2C i2c: The I2C bus connected to the sensor
:param int address: The I2C address of the sensor. If not specified
the sensor default will be used.
:param ~busio.I2C i2c: The I2C bus the device is connected to
:param int address: The I2C device address. Defaults to :const:`0x29`
**Quickstart: Importing and using the device**
Here is an example of using the :class:`TSL2591` class.
First you will need to import the libraries to use the sensor
.. code-block:: python
import board
import adafruit_tsl2591
Once this is done you can define your `board.I2C` object and define your sensor object
.. code-block:: python
i2c = board.I2C() # uses board.SCL and board.SDA
sensor = adafruit_tsl2591.TSL2591(i2c)
Now you have access to the :attr:`lux`, :attr:`infrared`
:attr:`visible` and :attr:`full_spectrum` attributes
.. code-block:: python
lux = sensor.lux
infrared = sensor.infrared
visible = sensor.visible
full_spectrum = sensor.full_spectrum
"""

# Class-level buffer to reduce memory usage and allocations.
Expand Down Expand Up @@ -229,7 +259,11 @@ def visible(self):
@property
def lux(self):
"""Read the sensor and calculate a lux value from both its infrared
and visible light channels. Note: ``lux`` is not calibrated!
and visible light channels.
.. note::
:attr:`lux` is not calibrated!
"""
channel_0, channel_1 = self.raw_luminosity

Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Table of Contents
.. toctree::
:caption: Tutorials

Adafruit TSL2591 High Dynamic Range Digital Light Sensor Learning Guide <https://learn.adafruit.com/adafruit-tsl2591>

.. toctree::
:caption: Related Products

Expand Down
7 changes: 2 additions & 5 deletions examples/tsl2591_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
# Simple demo of the TSL2591 sensor. Will print the detected light value
# every second.
import time

import board
import busio

import adafruit_tsl2591

# Initialize the I2C bus.
i2c = busio.I2C(board.SCL, board.SDA)
# Create sensor object, communicating over the board's default I2C bus
i2c = board.I2C() # uses board.SCL and board.SDA

# Initialize the sensor.
sensor = adafruit_tsl2591.TSL2591(i2c)
Expand Down

0 comments on commit bd37ad8

Please sign in to comment.