public class BrickletColor extends Device
Modifier and Type | Class and Description |
---|---|
class |
BrickletColor.Color |
class |
BrickletColor.ColorCallbackThreshold |
static interface |
BrickletColor.ColorListener
This listener is triggered periodically with the period that is set by
setColorCallbackPeriod(long) . |
static interface |
BrickletColor.ColorReachedListener
This listener is triggered when the threshold as set by
setColorCallbackThreshold(char, int, int, int, int, int, int, int, int) is reached. |
static interface |
BrickletColor.ColorTemperatureListener
This listener is triggered periodically with the period that is set by
setColorTemperatureCallbackPeriod(long) . |
class |
BrickletColor.Config |
static interface |
BrickletColor.IlluminanceListener
This listener is triggered periodically with the period that is set by
setIlluminanceCallbackPeriod(long) . |
Device.Identity
Constructor and Description |
---|
BrickletColor(String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addColorListener(BrickletColor.ColorListener listener)
Adds a Color listener.
|
void |
addColorReachedListener(BrickletColor.ColorReachedListener listener)
Adds a ColorReached listener.
|
void |
addColorTemperatureListener(BrickletColor.ColorTemperatureListener listener)
Adds a ColorTemperature listener.
|
void |
addIlluminanceListener(BrickletColor.IlluminanceListener listener)
Adds a Illuminance listener.
|
BrickletColor.Color |
getColor()
Returns the measured color of the sensor.
|
long |
getColorCallbackPeriod()
Returns the period as set by
setColorCallbackPeriod(long) . |
BrickletColor.ColorCallbackThreshold |
getColorCallbackThreshold()
Returns the threshold as set by
setColorCallbackThreshold(char, int, int, int, int, int, int, int, int) . |
int |
getColorTemperature()
Returns the color temperature.
|
long |
getColorTemperatureCallbackPeriod()
Returns the period as set by
setColorTemperatureCallbackPeriod(long) . |
BrickletColor.Config |
getConfig()
Returns the configuration as set by
setConfig(short, short) . |
long |
getDebouncePeriod()
Returns the debounce period as set by
setDebouncePeriod(long) . |
Device.Identity |
getIdentity()
Returns the UID, the UID where the Bricklet is connected to,
the position, the hardware and firmware version as well as the
device identifier.
|
long |
getIlluminance()
Returns the illuminance affected by the gain and integration time as
set by
setConfig(short, short) . |
long |
getIlluminanceCallbackPeriod()
Returns the period as set by
setIlluminanceCallbackPeriod(long) . |
short |
isLightOn()
Returns the state of the LED.
|
void |
lightOff()
Turns the LED off.
|
void |
lightOn()
Turns the LED on.
|
void |
removeColorListener(BrickletColor.ColorListener listener)
Removes a Color listener.
|
void |
removeColorReachedListener(BrickletColor.ColorReachedListener listener)
Removes a ColorReached listener.
|
void |
removeColorTemperatureListener(BrickletColor.ColorTemperatureListener listener)
Removes a ColorTemperature listener.
|
void |
removeIlluminanceListener(BrickletColor.IlluminanceListener listener)
Removes a Illuminance listener.
|
void |
setColorCallbackPeriod(long period)
Sets the period with which the
BrickletColor.ColorListener listener is triggered
periodically. |
void |
setColorCallbackThreshold(char option,
int minR,
int maxR,
int minG,
int maxG,
int minB,
int maxB,
int minC,
int maxC)
Sets the thresholds for the
BrickletColor.ColorReachedListener listener. |
void |
setColorTemperatureCallbackPeriod(long period)
Sets the period with which the
BrickletColor.ColorTemperatureListener listener is
triggered periodically. |
void |
setConfig(short gain,
short integrationTime)
Sets the configuration of the sensor.
|
void |
setDebouncePeriod(long debounce)
Sets the period with which the threshold listener
*
BrickletColor.ColorReachedListener
is triggered, if the threshold
* setColorCallbackThreshold(char, int, int, int, int, int, int, int, int)
keeps being reached. |
void |
setIlluminanceCallbackPeriod(long period)
Sets the period with which the
BrickletColor.IlluminanceListener listener is triggered
periodically. |
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
public static final int DEVICE_IDENTIFIER
public static final String DEVICE_DISPLAY_NAME
public static final byte FUNCTION_GET_COLOR
public static final byte FUNCTION_SET_COLOR_CALLBACK_PERIOD
public static final byte FUNCTION_GET_COLOR_CALLBACK_PERIOD
public static final byte FUNCTION_SET_COLOR_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_COLOR_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_DEBOUNCE_PERIOD
public static final byte FUNCTION_GET_DEBOUNCE_PERIOD
public static final byte FUNCTION_LIGHT_ON
public static final byte FUNCTION_LIGHT_OFF
public static final byte FUNCTION_IS_LIGHT_ON
public static final byte FUNCTION_SET_CONFIG
public static final byte FUNCTION_GET_CONFIG
public static final byte FUNCTION_GET_ILLUMINANCE
public static final byte FUNCTION_GET_COLOR_TEMPERATURE
public static final byte FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_COLOR_TEMPERATURE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_COLOR_TEMPERATURE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_IDENTITY
public static final char THRESHOLD_OPTION_OFF
public static final char THRESHOLD_OPTION_OUTSIDE
public static final char THRESHOLD_OPTION_INSIDE
public static final char THRESHOLD_OPTION_SMALLER
public static final char THRESHOLD_OPTION_GREATER
public static final short LIGHT_ON
public static final short LIGHT_OFF
public static final short GAIN_1X
public static final short GAIN_4X
public static final short GAIN_16X
public static final short GAIN_60X
public static final short INTEGRATION_TIME_2MS
public static final short INTEGRATION_TIME_24MS
public static final short INTEGRATION_TIME_101MS
public static final short INTEGRATION_TIME_154MS
public static final short INTEGRATION_TIME_700MS
public BrickletColor(String uid, IPConnection ipcon)
public BrickletColor.Color getColor() throws TinkerforgeException
BrickletColor.ColorListener
listener and set the period with
setColorCallbackPeriod(long)
.TinkerforgeException
public void setColorCallbackPeriod(long period) throws TinkerforgeException
BrickletColor.ColorListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletColor.ColorListener
listener is only triggered if the color has changed since the
last triggering.TinkerforgeException
public long getColorCallbackPeriod() throws TinkerforgeException
setColorCallbackPeriod(long)
.TinkerforgeException
public void setColorCallbackThreshold(char option, int minR, int maxR, int minG, int maxG, int minB, int maxB, int minC, int maxC) throws TinkerforgeException
BrickletColor.ColorReachedListener
listener.
The following options are possible:
\verbatim
"Option", "Description"
"'x'", "Listener is turned off"
"'o'", "Listener is triggered when the temperature is *outside* the min and max values"
"'i'", "Listener is triggered when the temperature is *inside* the min and max values"
"'<'", "Listener is triggered when the temperature is smaller than the min value (max is ignored)"
"'>'", "Listener is triggered when the temperature is greater than the min value (max is ignored)"
\endverbatimTinkerforgeException
public BrickletColor.ColorCallbackThreshold getColorCallbackThreshold() throws TinkerforgeException
setColorCallbackThreshold(char, int, int, int, int, int, int, int, int)
.TinkerforgeException
public void setDebouncePeriod(long debounce) throws TinkerforgeException
BrickletColor.ColorReachedListener
is triggered, if the threshold
* setColorCallbackThreshold(char, int, int, int, int, int, int, int, int)
keeps being reached.TinkerforgeException
public long getDebouncePeriod() throws TinkerforgeException
setDebouncePeriod(long)
.TinkerforgeException
public void lightOn() throws TinkerforgeException
TinkerforgeException
public void lightOff() throws TinkerforgeException
TinkerforgeException
public short isLightOn() throws TinkerforgeException
TinkerforgeException
public void setConfig(short gain, short integrationTime) throws TinkerforgeException
TinkerforgeException
public BrickletColor.Config getConfig() throws TinkerforgeException
setConfig(short, short)
.TinkerforgeException
public long getIlluminance() throws TinkerforgeException
setConfig(short, short)
. 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 setConfig(short, short)
.TinkerforgeException
public int getColorTemperature() throws TinkerforgeException
setConfig(short, short)
.TinkerforgeException
public void setIlluminanceCallbackPeriod(long period) throws TinkerforgeException
BrickletColor.IlluminanceListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletColor.IlluminanceListener
listener is only triggered if the illuminance has changed
since the last triggering.TinkerforgeException
public long getIlluminanceCallbackPeriod() throws TinkerforgeException
setIlluminanceCallbackPeriod(long)
.TinkerforgeException
public void setColorTemperatureCallbackPeriod(long period) throws TinkerforgeException
BrickletColor.ColorTemperatureListener
listener is
triggered periodically. A value of 0 turns the listener off.
The BrickletColor.ColorTemperatureListener
listener is only triggered if the color temperature
has changed since the last triggering.TinkerforgeException
public long getColorTemperatureCallbackPeriod() throws TinkerforgeException
setColorTemperatureCallbackPeriod(long)
.TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addColorListener(BrickletColor.ColorListener listener)
public void removeColorListener(BrickletColor.ColorListener listener)
public void addColorReachedListener(BrickletColor.ColorReachedListener listener)
public void removeColorReachedListener(BrickletColor.ColorReachedListener listener)
public void addIlluminanceListener(BrickletColor.IlluminanceListener listener)
public void removeIlluminanceListener(BrickletColor.IlluminanceListener listener)
public void addColorTemperatureListener(BrickletColor.ColorTemperatureListener listener)
public void removeColorTemperatureListener(BrickletColor.ColorTemperatureListener listener)
Copyright © 2022 Tinkerforge GmbH. All rights reserved.