Skip to content

Commit 775e238

Browse files
authored
Merge pull request #15 from jposada202020/improving_docs
improving_docs
2 parents 46d677e + 9c3f19a commit 775e238

File tree

9 files changed

+72
-13
lines changed

9 files changed

+72
-13
lines changed

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,13 @@ To install in a virtual environment in your current project:
6262
Usage Example
6363
=============
6464

65-
.. code-block:: python
65+
.. code-block:: python3
6666
6767
from time import sleep
6868
import board
69-
import busio
7069
from adafruit_as7341 import AS7341
7170
72-
i2c = busio.I2C(board.SCL, board.SDA)
71+
i2c = board.I2C() # uses board.SCL and board.SDA
7372
sensor = AS7341(i2c)
7473
7574

adafruit_as7341.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,39 @@ class Gain(CV):
199199
class AS7341: # pylint:disable=too-many-instance-attributes
200200
"""Library for the AS7341 Sensor
201201
202+
:param ~busio.I2C i2c_bus: The I2C bus the device is connected to
203+
:param int address: The I2C device address. Defaults to :const:`0x39`
202204
203-
:param ~busio.I2C i2c_bus: The I2C bus the AS7341 is connected to.
204-
:param address: The I2C address of the sensor
205+
206+
**Quickstart: Importing and using the device**
207+
208+
Here is an example of using the :class:`AS7341`.
209+
First you will need to import the libraries to use the sensor
210+
211+
.. code-block:: python
212+
213+
import board
214+
from adafruit_as7341 import AS7341
215+
216+
Once this is done you can define your `board.I2C` object and define your sensor object
217+
218+
.. code-block:: python
219+
220+
i2c = board.I2C() # uses board.SCL and board.SDA
221+
sensor = AS7341(i2c)
222+
223+
Now you have access to the different channels
224+
225+
.. code-block:: python
226+
227+
channel_415nm = channel_415nm
228+
channel_445nm = channel_445nm
229+
channel_480nm = channel_480nm
230+
channel_515nm = channel_515nm
231+
channel_555nm = channel_555nm
232+
channel_590nm = channel_590nm
233+
channel_630nm = channel_630nm
234+
channel_680nm = channel_680nm
205235
206236
"""
207237

@@ -331,7 +361,7 @@ def _wait_for_data(self, timeout=1.0):
331361
start = monotonic()
332362
while not self._data_ready_bit:
333363
if monotonic() - start > timeout:
334-
raise RuntimeError("Timeout occoured waiting for sensor data")
364+
raise RuntimeError("Timeout occurred waiting for sensor data")
335365
sleep(0.001)
336366

337367
def _write_register(self, addr, data):
@@ -579,7 +609,7 @@ def _set_smux(self, smux_addr, smux_out1, smux_out2):
579609

580610
@property
581611
def gain(self):
582-
"""The ADC gain multiplier. Must be a valid `adafruit_as7341.Gain`"""
612+
"""The ADC gain multiplier. Must be a valid :meth:`adafruit_as7341.Gain`"""
583613
return self._gain
584614

585615
@gain.setter

docs/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
77
.. automodule:: adafruit_as7341
88
:members:
9+
:exclude-members: CV, Gain

docs/examples.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,30 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/as7341_simpletest.py
77
:caption: examples/as7341_simpletest.py
88
:linenos:
9+
10+
LED test
11+
--------
12+
13+
Testing the LED
14+
15+
.. literalinclude:: ../examples/as7341_led_test.py
16+
:caption: examples/as7341_led_test.py
17+
:linenos:
18+
19+
Flicker Detection
20+
-----------------
21+
22+
Showing how to use flicker detection
23+
24+
.. literalinclude:: ../examples/as7341_flicker_detection.py
25+
:caption: examples/as7341_flicker_detection.py
26+
:linenos:
27+
28+
Batched Readings Example
29+
------------------------
30+
31+
Example in how to get all the channel readings at the same time
32+
33+
.. literalinclude:: ../examples/as7341_batched_readings.py
34+
:caption: examples/as7341_batched_readings.py
35+
:linenos:

docs/index.rst

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

26+
Adafruit AS7341 10-Channel Light / Color Sensor Breakout Learning Guide <https://learn.adafruit.com/adafruit-as7341-10-channel-light-color-sensor-breakout/overview>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

31+
Adafruit AS7341 10-Channel Light / Color Sensor Breakout <https://www.adafruit.com/product/4698>
32+
2933
.. toctree::
3034
:caption: Other Links
3135

examples/as7341_batched_readings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
# SPDX-License-Identifier: MIT
33
from time import sleep
44
import board
5-
import busio
65
from adafruit_as7341 import AS7341
76

8-
i2c = busio.I2C(board.SCL, board.SDA)
7+
i2c = board.I2C() # uses board.SCL and board.SDA
98
sensor = AS7341(i2c)
109

1110

examples/as7341_flicker_detection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
# SPDX-License-Identifier: MIT
33
from time import sleep
44
import board
5-
import busio
65
from adafruit_as7341 import AS7341
76

8-
i2c = busio.I2C(board.SCL, board.SDA)
7+
i2c = board.I2C() # uses board.SCL and board.SDA
98
sensor = AS7341(i2c)
109
sensor.flicker_detection_enabled = True
1110

examples/as7341_led_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
i2c = board.I2C()
99
sensor = adafruit_as7341.AS7341(i2c)
10+
1011
print("out of init!")
1112
print("Current current is")
1213
print(sensor.led_current)

examples/as7341_simpletest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
# SPDX-License-Identifier: MIT
33
from time import sleep
44
import board
5-
import busio
65
from adafruit_as7341 import AS7341
76

8-
i2c = busio.I2C(board.SCL, board.SDA)
7+
i2c = board.I2C() # uses board.SCL and board.SDA
98
sensor = AS7341(i2c)
109

1110

0 commit comments

Comments
 (0)