From f49165e0e4f468c6731ea1f21061c13233bb38b5 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Sun, 25 Apr 2021 16:11:33 -0400 Subject: [PATCH] improving_docs --- adafruit_tsl2591.py | 48 +++++++++++++++++++++++++++++----- docs/index.rst | 2 ++ examples/tsl2591_simpletest.py | 7 ++--- 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/adafruit_tsl2591.py b/adafruit_tsl2591.py index 29aa271..1b07580 100644 --- a/adafruit_tsl2591.py +++ b/adafruit_tsl2591.py @@ -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 @@ -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. @@ -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 diff --git a/docs/index.rst b/docs/index.rst index fe88a9c..31faaa0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,6 +23,8 @@ Table of Contents .. toctree:: :caption: Tutorials + Adafruit TSL2591 High Dynamic Range Digital Light Sensor Learning Guide + .. toctree:: :caption: Related Products diff --git a/examples/tsl2591_simpletest.py b/examples/tsl2591_simpletest.py index 70c36e6..3a7fbc4 100644 --- a/examples/tsl2591_simpletest.py +++ b/examples/tsl2591_simpletest.py @@ -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)