diff --git a/README.rst b/README.rst index a08e920..e9c0d4e 100644 --- a/README.rst +++ b/README.rst @@ -62,14 +62,13 @@ To install in a virtual environment in your current project: Usage Example ============= -.. code-block:: python +.. code-block:: python3 from time import sleep import board - import busio from adafruit_as7341 import AS7341 - i2c = busio.I2C(board.SCL, board.SDA) + i2c = board.I2C() # uses board.SCL and board.SDA sensor = AS7341(i2c) diff --git a/adafruit_as7341.py b/adafruit_as7341.py index 935c570..020fa78 100644 --- a/adafruit_as7341.py +++ b/adafruit_as7341.py @@ -199,9 +199,39 @@ class Gain(CV): class AS7341: # pylint:disable=too-many-instance-attributes """Library for the AS7341 Sensor + :param ~busio.I2C i2c_bus: The I2C bus the device is connected to + :param int address: The I2C device address. Defaults to :const:`0x39` - :param ~busio.I2C i2c_bus: The I2C bus the AS7341 is connected to. - :param address: The I2C address of the sensor + + **Quickstart: Importing and using the device** + + Here is an example of using the :class:`AS7341`. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + from adafruit_as7341 import AS7341 + + 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 = AS7341(i2c) + + Now you have access to the different channels + + .. code-block:: python + + channel_415nm = channel_415nm + channel_445nm = channel_445nm + channel_480nm = channel_480nm + channel_515nm = channel_515nm + channel_555nm = channel_555nm + channel_590nm = channel_590nm + channel_630nm = channel_630nm + channel_680nm = channel_680nm """ @@ -331,7 +361,7 @@ def _wait_for_data(self, timeout=1.0): start = monotonic() while not self._data_ready_bit: if monotonic() - start > timeout: - raise RuntimeError("Timeout occoured waiting for sensor data") + raise RuntimeError("Timeout occurred waiting for sensor data") sleep(0.001) def _write_register(self, addr, data): @@ -579,7 +609,7 @@ def _set_smux(self, smux_addr, smux_out1, smux_out2): @property def gain(self): - """The ADC gain multiplier. Must be a valid `adafruit_as7341.Gain`""" + """The ADC gain multiplier. Must be a valid :meth:`adafruit_as7341.Gain`""" return self._gain @gain.setter diff --git a/docs/api.rst b/docs/api.rst index a6e89d9..a8478db 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -6,3 +6,4 @@ .. automodule:: adafruit_as7341 :members: + :exclude-members: CV, Gain diff --git a/docs/examples.rst b/docs/examples.rst index c968baf..3129057 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -6,3 +6,30 @@ Ensure your device works with this simple test. .. literalinclude:: ../examples/as7341_simpletest.py :caption: examples/as7341_simpletest.py :linenos: + +LED test +-------- + +Testing the LED + +.. literalinclude:: ../examples/as7341_led_test.py + :caption: examples/as7341_led_test.py + :linenos: + +Flicker Detection +----------------- + +Showing how to use flicker detection + +.. literalinclude:: ../examples/as7341_flicker_detection.py + :caption: examples/as7341_flicker_detection.py + :linenos: + +Batched Readings Example +------------------------ + +Example in how to get all the channel readings at the same time + +.. literalinclude:: ../examples/as7341_batched_readings.py + :caption: examples/as7341_batched_readings.py + :linenos: diff --git a/docs/index.rst b/docs/index.rst index 6463af2..7a174ee 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,9 +23,13 @@ Table of Contents .. toctree:: :caption: Tutorials + Adafruit AS7341 10-Channel Light / Color Sensor Breakout Learning Guide + .. toctree:: :caption: Related Products + Adafruit AS7341 10-Channel Light / Color Sensor Breakout + .. toctree:: :caption: Other Links diff --git a/examples/as7341_batched_readings.py b/examples/as7341_batched_readings.py index 4f8ed0c..c39c756 100644 --- a/examples/as7341_batched_readings.py +++ b/examples/as7341_batched_readings.py @@ -2,10 +2,9 @@ # SPDX-License-Identifier: MIT from time import sleep import board -import busio from adafruit_as7341 import AS7341 -i2c = busio.I2C(board.SCL, board.SDA) +i2c = board.I2C() # uses board.SCL and board.SDA sensor = AS7341(i2c) diff --git a/examples/as7341_flicker_detection.py b/examples/as7341_flicker_detection.py index a641951..5a9d1a8 100644 --- a/examples/as7341_flicker_detection.py +++ b/examples/as7341_flicker_detection.py @@ -2,10 +2,9 @@ # SPDX-License-Identifier: MIT from time import sleep import board -import busio from adafruit_as7341 import AS7341 -i2c = busio.I2C(board.SCL, board.SDA) +i2c = board.I2C() # uses board.SCL and board.SDA sensor = AS7341(i2c) sensor.flicker_detection_enabled = True diff --git a/examples/as7341_led_test.py b/examples/as7341_led_test.py index 4c83aa5..086c199 100644 --- a/examples/as7341_led_test.py +++ b/examples/as7341_led_test.py @@ -7,6 +7,7 @@ i2c = board.I2C() sensor = adafruit_as7341.AS7341(i2c) + print("out of init!") print("Current current is") print(sensor.led_current) diff --git a/examples/as7341_simpletest.py b/examples/as7341_simpletest.py index 724a74a..1a52c31 100644 --- a/examples/as7341_simpletest.py +++ b/examples/as7341_simpletest.py @@ -2,10 +2,9 @@ # SPDX-License-Identifier: MIT from time import sleep import board -import busio from adafruit_as7341 import AS7341 -i2c = busio.I2C(board.SCL, board.SDA) +i2c = board.I2C() # uses board.SCL and board.SDA sensor = AS7341(i2c)