Skip to content
This repository has been archived by the owner on Dec 16, 2018. It is now read-only.

Latest commit

 

History

History
98 lines (63 loc) · 3.45 KB

tcs34725.rst

File metadata and controls

98 lines (63 loc) · 3.45 KB

tcs34725 module

.. module:: tcs34725

TCS34725

The basic class for handling the communication with the sensor.

The i2c parameter is an initialized I²C bus, and the optional address specifies which sensor to connect to, if you have more than one and have changed their addresses with the Addr pin.

May raise a RuntimeError if connected to a wrong model of sensor.

.. method:: active([True|False])

    Get or set the power status of the sensor.

    If called without any parameters, returns the current status (``True``
    for active, ``False`` for inactive). If called with a parameter, sets
    the status.

    The functions that require the sensor to be active will activate it
    for the time necessary, and then return it to the previous state.

.. method:: gain([1|4|16|60])

    Get or set the measurement gain of the sensor.

.. method:: integration_time([value])

    Get or set the integraton time for measurements in milliseconds,
    from 2.4ms to 614.4ms in steps of 2.4ms.

.. method:: sensor_id()

    Return the internal ID of the sensor, describing its model and
    revision number.

.. method:: read([raw])

    Read a measurement from the sensor.

    If ``raw`` is ``False`` (the deafult), returns a tuple of floating
    point values denoting color temperature in kelvins and luminosity in
    lux. If it's ``True``, returns a 4-tuple of integer numbers,
    corresponding to the readings of the red, green, blue and clear
    channels.

    If at the moment of calling this method, the sensor is inactive,
    it will be activated, the method will block for a time necessary for
    the sensor to make the measurement, and then return and deactivate
    the sensor. If the sensor was active, the library may still wait for
    the sensor to complete the measurement, if it's not ready.

.. method:: threshold([cycles] [, min_value] [, max_value])

    Get or set the interrupt settings.

    If called without arguments, returns a triple of values.

    The ``cycles`` argument specifies how many cycles are needed to trigger
    the interrupt. When set to 0, each measurement will do it. If set to 1,
    2, 3, or 5-60 (in increments of 5), the interrupt will be triggered
    only when so many measurements in a row fall out of bounds. When set to
    -1, interrupts are disabled.

    The ``min_value`` and ``max_value`` specify the window for the clear
    channel to fit in.

    Whenever the interrupt is activated, the ``Int`` pin of the sensor will
    be pulled low and stay in that state until cleared. You can connect it
    to one of the pins and set a pin interrupt to detect that event.

    Note that for the interrupt pin to work, the sensor must stay active.

.. method:: interrupt([False])

    Get or set the status of interrupt.

    Without arguments, returns ``True`` if an interrupt is triggered,
    otherwise returns ``False``.

    When ``False`` is passed as an argument, clears the interrupt.
.. function:: html_rgb(data)

        Convert the 4-tuple values returned by ``read(raw=True)`` to a
        3-tuple of 8 bit RGB values.

.. function:: html_hex(data)

        Convert the 4-tuple values returned by ``read(raw=True)`` to a
        string of the HTML hex values for the color.