Skip to content

Commit 70f54b0

Browse files
committed
improving_docs
1 parent 2c85363 commit 70f54b0

File tree

8 files changed

+86
-21
lines changed

8 files changed

+86
-21
lines changed

README.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ To install in a virtual environment in your current project:
5656
Usage Example
5757
=============
5858

59-
.. code-block:: python
59+
.. code-block:: python3
6060
6161
import board
62-
import busio
6362
import digitalio
6463
from adafruit_apds9960.apds9960 import APDS9960
6564
66-
i2c = busio.I2C(board.SCL, board.SDA)
65+
i2c = board.I2C()
6766
int_pin = digitalio.DigitalInOut(board.D5)
6867
apds = APDS9960(i2c, interrupt_pin=int_pin)
6968
@@ -85,30 +84,29 @@ Basics
8584

8685
Of course, you must import i2c bus device, board pins, and the library:
8786

88-
.. code:: python
87+
.. code:: python3
8988
9089
91-
from board import SCL, SDA, A1
90+
import board
9291
from adafruit_apds9960.apds9960 import APDS9960
93-
import busio
9492
import digitalio
9593
9694
To set-up the device to gather data, initialize the I2CDevice using SCL
9795
and SDA pins. Then initialize the library. Optionally provide an interrupt
9896
pin for proximity detection.
9997

100-
.. code:: python
98+
.. code:: python3
10199
102-
int_pin = digitalio.DigitalInOut(A1)
103-
i2c = busio.I2C(SCL, SDA)
100+
int_pin = digitalio.DigitalInOut(board.A1)
101+
i2c = board.I2C()
104102
apds = APDS9960(i2c, interrupt_pin=int_pin)
105103
106104
Gestures
107105
--------
108106

109107
To get a gesture, see if a gesture is available first, then get the gesture Code
110108

111-
.. code:: python
109+
.. code:: python3
112110
113111
gesture = apds.gesture()
114112
if gesture == 1:
@@ -126,7 +124,7 @@ Color Measurement
126124
To get a color measure, enable color measures, wait for color data,
127125
then get the color data.
128126

129-
.. code:: python
127+
.. code:: python3
130128
131129
apds.enable_color = True
132130
@@ -141,7 +139,7 @@ Proximity Detection
141139

142140
To check for a object in proximity, see if a gesture is available first, then get the gesture Code
143141

144-
.. code:: python
142+
.. code:: python3
145143
146144
apds.enable_proximity = True
147145

adafruit_apds9960/apds9960.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@
1010
detection.
1111
1212
* Author(s): Michael McWethy
13+
14+
Implementation Notes
15+
--------------------
16+
17+
**Hardware:**
18+
19+
* Adafruit `APDS9960 Proximity, Light, RGB, and Gesture Sensor
20+
<https://www.adafruit.com/product/3595>`_ (Product ID: 3595)
21+
22+
**Software and Dependencies:**
23+
24+
* Adafruit CircuitPython firmware for the supported boards:
25+
https://circuitpython.org/downloads
26+
27+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
1328
"""
1429
import time
1530
import digitalio
@@ -81,6 +96,38 @@
8196
class APDS9960:
8297
"""
8398
APDS9900 provide basic driver services for the ASDS9960 breakout board
99+
100+
:param ~busio.I2C i2c: The I2C bus the BME280 is connected to
101+
:param ~microcontroller.Pin interrupt_pin: Interrupt pin. Defaults to `None`
102+
:param int address: The I2C device address. Defaults to :const:`0x39`
103+
:param int integration_time: integration time. Defaults to :const:`0x01`
104+
:param int gain: Device gain. Defaults to :const:`0x01`
105+
:param int rotation: rotation of the device. Defaults to :const:`0`
106+
107+
108+
**Quickstart: Importing and using the APDS9960**
109+
110+
Here is an example of using the :class:`APDS9960` class.
111+
First you will need to import the libraries to use the sensor
112+
113+
.. code-block:: python
114+
115+
import board
116+
from adafruit_apds9960.apds9960 import APDS9960
117+
118+
Once this is done you can define your `board.I2C` object and define your sensor object
119+
120+
.. code-block:: python
121+
122+
i2c = board.I2C() # uses board.SCL and board.SDA
123+
apds = APDS9960(i2c)
124+
125+
Now you have access to the :attr:`sensor.proximity` attribute
126+
127+
.. code-block:: python
128+
129+
proximity = apds.proximity
130+
84131
"""
85132

86133
_gesture_enable = RWBit(APDS9960_ENABLE, 6)

docs/examples.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,32 @@ Ensure your device works with this simple test.
77
:caption: examples/apds9960_color_simpletest.py
88
:linenos:
99

10+
11+
Gesture Example
12+
---------------
13+
14+
Show how to use the device with simple gestures
15+
1016
.. literalinclude:: ../examples/apds9960_gesture_simpletest.py
1117
:caption: examples/apds9960_gesture_simpletest.py
1218
:linenos:
1319

20+
21+
Proximity Example
22+
-----------------
23+
24+
Example showing proximity feature
25+
1426
.. literalinclude:: ../examples/apds9960_proximity_simpletest.py
1527
:caption: examples/apds9960_proximity_simpletest.py
1628
:linenos:
29+
30+
31+
Color Example
32+
---------------
33+
34+
Example showing how to get RGB values
35+
36+
.. literalinclude:: ../examples/apds9960_color_simpletest.py
37+
:caption: examples/apds9960_color_simpletest.py
38+
:linenos:

docs/index.rst

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

26+
Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor Learning Guide <https://learn.adafruit.com/adafruit-apds9960-breakout>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

examples/apds9960_color_simpletest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
import time
55
import board
6-
import busio
76
from adafruit_apds9960.apds9960 import APDS9960
87
from adafruit_apds9960 import colorutility
98

10-
i2c = busio.I2C(board.SCL, board.SDA)
9+
i2c = board.I2C()
1110
apds = APDS9960(i2c)
1211
apds.enable_color = True
1312

examples/apds9960_gesture_simpletest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
22
# SPDX-License-Identifier: MIT
33

4-
from board import SCL, SDA
5-
import busio
4+
import board
65
from adafruit_apds9960.apds9960 import APDS9960
76

8-
i2c = busio.I2C(SCL, SDA)
7+
i2c = board.I2C()
98

109
apds = APDS9960(i2c)
1110
apds.enable_proximity = True

examples/apds9960_proximity_simpletest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
# SPDX-License-Identifier: MIT
33

44
import board
5-
import busio
65
import digitalio
76
from adafruit_apds9960.apds9960 import APDS9960
87

9-
i2c = busio.I2C(board.SCL, board.SDA)
8+
i2c = board.I2C()
109
int_pin = digitalio.DigitalInOut(board.D5)
1110
apds = APDS9960(i2c, interrupt_pin=int_pin)
1211

examples/apds9960_simpletest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
import time
55
import board
6-
import busio
76
from adafruit_apds9960.apds9960 import APDS9960
87

9-
i2c = busio.I2C(board.SCL, board.SDA)
8+
i2c = board.I2C()
109
apds = APDS9960(i2c)
1110

1211
apds.enable_proximity = True

0 commit comments

Comments
 (0)