Skip to content

improving_docs #22

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
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