The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tinkerforge::BrickletColor - Measures color (RGB value), illuminance and color temperature

CONSTANTS

DEVICE_IDENTIFIER

This constant is used to identify a Color Bricklet.

The get_identity() subroutine and the CALLBACK_ENUMERATE callback of the IP Connection have a device_identifier parameter to specify the Brick's or Bricklet's type.

DEVICE_DISPLAY_NAME

This constant represents the display name of a Color Bricklet.

CALLBACK_COLOR

This constant is used with the register_callback() subroutine to specify the CALLBACK_COLOR callback.

CALLBACK_COLOR_REACHED

This constant is used with the register_callback() subroutine to specify the CALLBACK_COLOR_REACHED callback.

CALLBACK_ILLUMINANCE

This constant is used with the register_callback() subroutine to specify the CALLBACK_ILLUMINANCE callback.

CALLBACK_COLOR_TEMPERATURE

This constant is used with the register_callback() subroutine to specify the CALLBACK_COLOR_TEMPERATURE callback.

FUNCTION_GET_COLOR

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_COLOR_CALLBACK_PERIOD

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_COLOR_CALLBACK_PERIOD

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_COLOR_CALLBACK_THRESHOLD

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_COLOR_CALLBACK_THRESHOLD

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_DEBOUNCE_PERIOD

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_DEBOUNCE_PERIOD

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_LIGHT_ON

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_LIGHT_OFF

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_IS_LIGHT_ON

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_CONFIG

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_CONFIG

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_ILLUMINANCE

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_COLOR_TEMPERATURE

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_COLOR_TEMPERATURE_CALLBACK_PERIOD

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_COLOR_TEMPERATURE_CALLBACK_PERIOD

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_IDENTITY

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTIONS

new()

Creates an object with the unique device ID *uid* and adds it to the IP Connection *ipcon*.

get_color()

Returns the measured color of the sensor.

The red (r), green (g), blue (b) and clear (c) colors are measured with four different photodiodes that are responsive at different wavelengths:

.. image:: /Images/Bricklets/bricklet_color_wavelength_chart_600.jpg :scale: 100 % :alt: Chart Responsivity / Wavelength :align: center :target: ../../_images/Bricklets/bricklet_color_wavelength_chart_600.jpg

If you want to get the color periodically, it is recommended to use the :cb:`Color` callback and set the period with :func:`Set Color Callback Period`.

set_color_callback_period()

Sets the period with which the :cb:`Color` callback is triggered periodically. A value of 0 turns the callback off.

The :cb:`Color` callback is only triggered if the color has changed since the last triggering.

get_color_callback_period()

Returns the period as set by :func:`Set Color Callback Period`.

set_color_callback_threshold()

Sets the thresholds for the :cb:`Color Reached` callback.

The following options are possible:

.. csv-table:: :header: "Option", "Description" :widths: 10, 100

 "'x'",    "Callback is turned off"
 "'o'",    "Callback is triggered when the temperature is *outside* the min and max values"
 "'i'",    "Callback is triggered when the temperature is *inside* the min and max values"
 "'<'",    "Callback is triggered when the temperature is smaller than the min value (max is ignored)"
 "'>'",    "Callback is triggered when the temperature is greater than the min value (max is ignored)"
get_color_callback_threshold()

Returns the threshold as set by :func:`Set Color Callback Threshold`.

set_debounce_period()

Sets the period with which the threshold callback

* :cb:`Color Reached`

is triggered, if the threshold

* :func:`Set Color Callback Threshold`

keeps being reached.

get_debounce_period()

Returns the debounce period as set by :func:`Set Debounce Period`.

light_on()

Turns the LED on.

light_off()

Turns the LED off.

is_light_on()

Returns the state of the LED. Possible values are:

* 0: On * 1: Off

set_config()

Sets the configuration of the sensor. Gain and integration time can be configured in this way.

For configuring the gain:

* 0: 1x Gain * 1: 4x Gain * 2: 16x Gain * 3: 60x Gain

For configuring the integration time:

* 0: 2.4ms * 1: 24ms * 2: 101ms * 3: 154ms * 4: 700ms

Increasing the gain enables the sensor to detect a color from a higher distance.

The integration time provides a trade-off between conversion time and accuracy. With a longer integration time the values read will be more accurate but it will take longer time to get the conversion results.

get_config()

Returns the configuration as set by :func:`Set Config`.

get_illuminance()

Returns the illuminance affected by the gain and integration time as set by :func:`Set Config`. To get the illuminance in Lux apply this formula::

 lux = illuminance * 700 / gain / integration_time

To get a correct illuminance measurement make sure that the color values themselves are not saturated. The color value (R, G or B) is saturated if it is equal to the maximum value of 65535. In that case you have to reduce the gain, see :func:`Set Config`.

get_color_temperature()

Returns the color temperature.

To get a correct color temperature measurement make sure that the color values themselves are not saturated. The color value (R, G or B) is saturated if it is equal to the maximum value of 65535. In that case you have to reduce the gain, see :func:`Set Config`.

set_illuminance_callback_period()

Sets the period with which the :cb:`Illuminance` callback is triggered periodically. A value of 0 turns the callback off.

The :cb:`Illuminance` callback is only triggered if the illuminance has changed since the last triggering.

get_illuminance_callback_period()

Returns the period as set by :func:`Set Illuminance Callback Period`.

set_color_temperature_callback_period()

Sets the period with which the :cb:`Color Temperature` callback is triggered periodically. A value of 0 turns the callback off.

The :cb:`Color Temperature` callback is only triggered if the color temperature has changed since the last triggering.

get_color_temperature_callback_period()

Returns the period as set by :func:`Set Color Temperature Callback Period`.

get_identity()

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'.

The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|