From e73945558daa96a399fef010cd23c2dc80313650 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Sun, 25 Apr 2021 16:38:04 -0400 Subject: [PATCH] improving_docs --- adafruit_as726x.py | 87 +++++++++++++++++++++++++++++++++-- docs/index.rst | 4 ++ examples/as726x_simpletest.py | 6 +-- 3 files changed, 90 insertions(+), 7 deletions(-) diff --git a/adafruit_as726x.py b/adafruit_as726x.py index 4507b1a..cd6dbf2 100644 --- a/adafruit_as726x.py +++ b/adafruit_as726x.py @@ -9,6 +9,22 @@ Driver for the AS726x spectral sensors * Author(s): Dean Miller + +Implementation Notes +-------------------- + +**Hardware:** + +* Adafruit `AS7262 6-Channel Visible Light / Color Sensor Breakout + `_ (Product ID: 3779) + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the supported boards: + https://circuitpython.org/downloads + +* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice + """ import time @@ -281,8 +297,10 @@ def integration_time(self, val): def start_measurement(self): """Begin a measurement. - This will set the device to One Shot mode and values will not change after `data_ready` - until `start_measurement` is called again or the `conversion_mode` is changed.""" + This will set the device to One Shot mode and values will + not change after `data_ready` until :meth:`start_measurement` + is called again or the :meth:`conversion_mode` is changed. + """ state = self._virtual_read(_AS726X_CONTROL_SETUP) state &= ~(0x02) self._virtual_write(_AS726X_CONTROL_SETUP, state) @@ -382,7 +400,39 @@ def _virtual_write(self, addr, value): class AS726x_I2C(AS726x): """AS726x spectral sensor via I2C. - :param ~busio.I2C i2c_bus: The I2C bus connected to the sensor + :param ~busio.I2C i2c_bus: The I2C bus the AS726x is connected to + :param int address: The I2C device address. Defaults to :const:`0x49` + + + **Quickstart: Importing and using the AS726x** + + Here is an example of using the :class:`AS726x_I2C` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + from adafruit_as726x import AS726x_I2C + + 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 = AS726x_I2C(i2c) + + Now you have access to the different color attributes + + .. code-block:: python + + violet = sensor.violet + blue = sensor.blue + green = sensor.green + yellow = sensor.yellow + orange = sensor.orange + red = sensor.red + + """ def __init__(self, i2c_bus, address=_AS726X_ADDRESS): @@ -449,6 +499,37 @@ class AS726x_UART(AS726x): """AS726x spectral sensor via UART. :param ~busio.UART uart: The UART connected to the sensor + + + **Quickstart: Importing and using the AS726x** + + Here is an example of using the :class:`AS726x_I2C` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + from adafruit_as726x import AS726x_UART + + Once this is done you can define your `board.UART` object and define your sensor object + + .. code-block:: python + + uart = board.UART() # uses board.SCL and board.SDA + sensor = AS726x_UART(uart) + + Now you have access to the different color attributes + + .. code-block:: python + + violet = sensor.violet + blue = sensor.blue + green = sensor.green + yellow = sensor.yellow + orange = sensor.orange + red = sensor.red + + """ def __init__(self, uart): diff --git a/docs/index.rst b/docs/index.rst index c39933a..d782707 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,9 +23,13 @@ Table of Contents .. toctree:: :caption: Tutorials + Adafruit AS7262 6-Channel Visible Light / Color Sensor Breakout Learning Guide + .. toctree:: :caption: Related Products + Adafruit AS7262 6-Channel Visible Light / Color Sensor Breakout + .. toctree:: :caption: Other Links diff --git a/examples/as726x_simpletest.py b/examples/as726x_simpletest.py index 24b8b25..78a0214 100644 --- a/examples/as726x_simpletest.py +++ b/examples/as726x_simpletest.py @@ -2,9 +2,7 @@ # SPDX-License-Identifier: MIT import time - import board -import busio # for I2C use: from adafruit_as726x import AS726x_I2C @@ -24,11 +22,11 @@ def graph_map(x): # for I2C use: -i2c = busio.I2C(board.SCL, board.SDA) +i2c = board.I2C() sensor = AS726x_I2C(i2c) # for UART use: -# uart = busio.UART(board.TX, board.RX) +# uart = board.UART() # sensor = AS726x_UART(uart) sensor.conversion_mode = sensor.MODE_2