Skip to content

Commit a6381c7

Browse files
authored
Merge pull request #16 from jposada202020/improving_docs
improving_docs
2 parents 9735612 + e739455 commit a6381c7

File tree

3 files changed

+90
-7
lines changed

3 files changed

+90
-7
lines changed

adafruit_as726x.py

+84-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@
99
Driver for the AS726x spectral sensors
1010
1111
* Author(s): Dean Miller
12+
13+
Implementation Notes
14+
--------------------
15+
16+
**Hardware:**
17+
18+
* Adafruit `AS7262 6-Channel Visible Light / Color Sensor Breakout
19+
<https://www.adafruit.com/product/3779>`_ (Product ID: 3779)
20+
21+
**Software and Dependencies:**
22+
23+
* Adafruit CircuitPython firmware for the supported boards:
24+
https://circuitpython.org/downloads
25+
26+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
27+
1228
"""
1329

1430
import time
@@ -281,8 +297,10 @@ def integration_time(self, val):
281297
def start_measurement(self):
282298
"""Begin a measurement.
283299
284-
This will set the device to One Shot mode and values will not change after `data_ready`
285-
until `start_measurement` is called again or the `conversion_mode` is changed."""
300+
This will set the device to One Shot mode and values will
301+
not change after `data_ready` until :meth:`start_measurement`
302+
is called again or the :meth:`conversion_mode` is changed.
303+
"""
286304
state = self._virtual_read(_AS726X_CONTROL_SETUP)
287305
state &= ~(0x02)
288306
self._virtual_write(_AS726X_CONTROL_SETUP, state)
@@ -382,7 +400,39 @@ def _virtual_write(self, addr, value):
382400
class AS726x_I2C(AS726x):
383401
"""AS726x spectral sensor via I2C.
384402
385-
:param ~busio.I2C i2c_bus: The I2C bus connected to the sensor
403+
:param ~busio.I2C i2c_bus: The I2C bus the AS726x is connected to
404+
:param int address: The I2C device address. Defaults to :const:`0x49`
405+
406+
407+
**Quickstart: Importing and using the AS726x**
408+
409+
Here is an example of using the :class:`AS726x_I2C` class.
410+
First you will need to import the libraries to use the sensor
411+
412+
.. code-block:: python
413+
414+
import board
415+
from adafruit_as726x import AS726x_I2C
416+
417+
Once this is done you can define your `board.I2C` object and define your sensor object
418+
419+
.. code-block:: python
420+
421+
i2c = board.I2C() # uses board.SCL and board.SDA
422+
sensor = AS726x_I2C(i2c)
423+
424+
Now you have access to the different color attributes
425+
426+
.. code-block:: python
427+
428+
violet = sensor.violet
429+
blue = sensor.blue
430+
green = sensor.green
431+
yellow = sensor.yellow
432+
orange = sensor.orange
433+
red = sensor.red
434+
435+
386436
"""
387437

388438
def __init__(self, i2c_bus, address=_AS726X_ADDRESS):
@@ -449,6 +499,37 @@ class AS726x_UART(AS726x):
449499
"""AS726x spectral sensor via UART.
450500
451501
:param ~busio.UART uart: The UART connected to the sensor
502+
503+
504+
**Quickstart: Importing and using the AS726x**
505+
506+
Here is an example of using the :class:`AS726x_I2C` class.
507+
First you will need to import the libraries to use the sensor
508+
509+
.. code-block:: python
510+
511+
import board
512+
from adafruit_as726x import AS726x_UART
513+
514+
Once this is done you can define your `board.UART` object and define your sensor object
515+
516+
.. code-block:: python
517+
518+
uart = board.UART() # uses board.SCL and board.SDA
519+
sensor = AS726x_UART(uart)
520+
521+
Now you have access to the different color attributes
522+
523+
.. code-block:: python
524+
525+
violet = sensor.violet
526+
blue = sensor.blue
527+
green = sensor.green
528+
yellow = sensor.yellow
529+
orange = sensor.orange
530+
red = sensor.red
531+
532+
452533
"""
453534

454535
def __init__(self, uart):

docs/index.rst

+4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit AS7262 6-Channel Visible Light / Color Sensor Breakout Learning Guide <https://learn.adafruit.com/adafruit-as7262-6-channel-visible-light-sensor>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

31+
Adafruit AS7262 6-Channel Visible Light / Color Sensor Breakout <https://www.adafruit.com/product/3779>
32+
2933
.. toctree::
3034
:caption: Other Links
3135

examples/as726x_simpletest.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
# SPDX-License-Identifier: MIT
33

44
import time
5-
65
import board
7-
import busio
86

97
# for I2C use:
108
from adafruit_as726x import AS726x_I2C
@@ -24,11 +22,11 @@ def graph_map(x):
2422

2523

2624
# for I2C use:
27-
i2c = busio.I2C(board.SCL, board.SDA)
25+
i2c = board.I2C()
2826
sensor = AS726x_I2C(i2c)
2927

3028
# for UART use:
31-
# uart = busio.UART(board.TX, board.RX)
29+
# uart = board.UART()
3230
# sensor = AS726x_UART(uart)
3331

3432
sensor.conversion_mode = sensor.MODE_2

0 commit comments

Comments
 (0)