Skip to content

improving_docs #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 42 additions & 7 deletions adafruit_tcs34725.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
`adafruit_tcs34725`
====================================================

CircuitPython module for the TCS34725 color sensor. Ported from the
micropython-adafruit-tcs34725 module by Radomir Dopieralski:
https://github.com/adafruit/micropython-adafruit-tcs34725
CircuitPython module for the TCS34725 color sensor.
Ported from the
`micropython-adafruit-tcs34725 <https://github.com/adafruit/micropython-adafruit-tcs34725>`_
module by Radomir Dopieralski


See examples/tcs34725_simpletest.py for an example of the usage.

Expand All @@ -27,8 +29,9 @@

**Software and Dependencies:**

* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
https://github.com/adafruit/circuitpython/releases
* Adafruit CircuitPython firmware for the supported boards:
https://circuitpython.org/downloads

* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
"""
import time
Expand Down Expand Up @@ -65,7 +68,39 @@


class TCS34725:
"""Driver for the TCS34725 color sensor."""
"""Driver for the TCS34725 color sensor.

:param ~busio.I2C i2c: The I2C bus the device is connected to
:param int address: The I2C device address. Defaults to :const:`0x29`


**Quickstart: Importing and using the device**

Here is an example of using the :class:`TCS34725`.
First you will need to import the libraries to use the sensor

.. code-block:: python

import board
import adafruit_tcs34725

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 = adafruit_tcs34725.TCS34725(i2c)


Now you have access to the :attr:`color_temperature`, :attr:`lux` attributes

.. code-block:: python

temp = sensor.color_temperature
lux = sensor.lux


"""

# Class-level buffer for reading and writing data with the sensor.
# This reduces memory allocations but means the code is not re-entrant or
Expand Down Expand Up @@ -318,7 +353,7 @@ def _temperature_and_lux_dn40(self):
def glass_attenuation(self):
"""The Glass Attenuation (FA) factor used to compensate for lower light
levels at the device due to the possible presence of glass. The GA is
the inverse of the glass transmissivity (T), so GA = 1/T. A transmissivity
the inverse of the glass transmissivity (T), so :math:`GA = 1/T`. A transmissivity
of 50% gives GA = 1 / 0.50 = 2. If no glass is present, use GA = 1.
See Application Note: DN40-Rev 1.0 – Lux and CCT Calculations using
ams Color Sensors for more details.
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Table of Contents
.. toctree::
:caption: Tutorials

Adafruit Color Sensors <https://learn.adafruit.com/adafruit-color-sensors/overview>

.. toctree::
:caption: Related Products

Expand Down
7 changes: 2 additions & 5 deletions examples/tcs34725_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
# Simple demo of the TCS34725 color sensor.
# Will detect the color from the sensor and print it out every second.
import time

import board
import busio

import adafruit_tcs34725


# Initialize I2C bus and sensor.
i2c = busio.I2C(board.SCL, board.SDA)
# Create sensor object, communicating over the board's default I2C bus
i2c = board.I2C() # uses board.SCL and board.SDA
sensor = adafruit_tcs34725.TCS34725(i2c)

# Main loop reading color and printing it every second.
Expand Down