Skip to content

Commit 66cc0eb

Browse files
authored
Merge pull request #35 from jposada202020/improving_docs
improving_docs
2 parents 758e486 + c6e4c55 commit 66cc0eb

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

adafruit_tcs34725.py

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
`adafruit_tcs34725`
77
====================================================
88
9-
CircuitPython module for the TCS34725 color sensor. Ported from the
10-
micropython-adafruit-tcs34725 module by Radomir Dopieralski:
11-
https://github.com/adafruit/micropython-adafruit-tcs34725
9+
CircuitPython module for the TCS34725 color sensor.
10+
Ported from the
11+
`micropython-adafruit-tcs34725 <https://github.com/adafruit/micropython-adafruit-tcs34725>`_
12+
module by Radomir Dopieralski
13+
1214
1315
See examples/tcs34725_simpletest.py for an example of the usage.
1416
@@ -27,8 +29,9 @@
2729
2830
**Software and Dependencies:**
2931
30-
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
31-
https://github.com/adafruit/circuitpython/releases
32+
* Adafruit CircuitPython firmware for the supported boards:
33+
https://circuitpython.org/downloads
34+
3235
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
3336
"""
3437
import time
@@ -65,7 +68,39 @@
6568

6669

6770
class TCS34725:
68-
"""Driver for the TCS34725 color sensor."""
71+
"""Driver for the TCS34725 color sensor.
72+
73+
:param ~busio.I2C i2c: The I2C bus the device is connected to
74+
:param int address: The I2C device address. Defaults to :const:`0x29`
75+
76+
77+
**Quickstart: Importing and using the device**
78+
79+
Here is an example of using the :class:`TCS34725`.
80+
First you will need to import the libraries to use the sensor
81+
82+
.. code-block:: python
83+
84+
import board
85+
import adafruit_tcs34725
86+
87+
Once this is done you can define your `board.I2C` object and define your sensor object
88+
89+
.. code-block:: python
90+
91+
i2c = board.I2C() # uses board.SCL and board.SDA
92+
sensor = adafruit_tcs34725.TCS34725(i2c)
93+
94+
95+
Now you have access to the :attr:`color_temperature`, :attr:`lux` attributes
96+
97+
.. code-block:: python
98+
99+
temp = sensor.color_temperature
100+
lux = sensor.lux
101+
102+
103+
"""
69104

70105
# Class-level buffer for reading and writing data with the sensor.
71106
# This reduces memory allocations but means the code is not re-entrant or
@@ -318,7 +353,7 @@ def _temperature_and_lux_dn40(self):
318353
def glass_attenuation(self):
319354
"""The Glass Attenuation (FA) factor used to compensate for lower light
320355
levels at the device due to the possible presence of glass. The GA is
321-
the inverse of the glass transmissivity (T), so GA = 1/T. A transmissivity
356+
the inverse of the glass transmissivity (T), so :math:`GA = 1/T`. A transmissivity
322357
of 50% gives GA = 1 / 0.50 = 2. If no glass is present, use GA = 1.
323358
See Application Note: DN40-Rev 1.0 – Lux and CCT Calculations using
324359
ams Color Sensors for more details.

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 Color Sensors <https://learn.adafruit.com/adafruit-color-sensors/overview>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

examples/tcs34725_simpletest.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
# Simple demo of the TCS34725 color sensor.
55
# Will detect the color from the sensor and print it out every second.
66
import time
7-
87
import board
9-
import busio
10-
118
import adafruit_tcs34725
129

1310

14-
# Initialize I2C bus and sensor.
15-
i2c = busio.I2C(board.SCL, board.SDA)
11+
# Create sensor object, communicating over the board's default I2C bus
12+
i2c = board.I2C() # uses board.SCL and board.SDA
1613
sensor = adafruit_tcs34725.TCS34725(i2c)
1714

1815
# Main loop reading color and printing it every second.

0 commit comments

Comments
 (0)