Package com.tinkerforge
Class BrickletAmbientLightV2
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletAmbientLightV2
-
public class BrickletAmbientLightV2 extends Device
Measures ambient light up to 64000lux
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletAmbientLightV2.Configuration
class
BrickletAmbientLightV2.IlluminanceCallbackThreshold
static interface
BrickletAmbientLightV2.IlluminanceListener
This listener is triggered periodically with the period that is set bysetIlluminanceCallbackPeriod(long)
.static interface
BrickletAmbientLightV2.IlluminanceReachedListener
This listener is triggered when the threshold as set bysetIlluminanceCallbackThreshold(char, long, long)
is reached.-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BrickletAmbientLightV2(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIlluminanceListener(BrickletAmbientLightV2.IlluminanceListener listener)
Adds a Illuminance listener.void
addIlluminanceReachedListener(BrickletAmbientLightV2.IlluminanceReachedListener listener)
Adds a IlluminanceReached listener.BrickletAmbientLightV2.Configuration
getConfiguration()
Returns the configuration as set bysetConfiguration(short, short)
.long
getDebouncePeriod()
Returns the debounce period as set bysetDebouncePeriod(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 of the ambient light sensor.long
getIlluminanceCallbackPeriod()
Returns the period as set bysetIlluminanceCallbackPeriod(long)
.BrickletAmbientLightV2.IlluminanceCallbackThreshold
getIlluminanceCallbackThreshold()
Returns the threshold as set bysetIlluminanceCallbackThreshold(char, long, long)
.void
removeIlluminanceListener(BrickletAmbientLightV2.IlluminanceListener listener)
Removes a Illuminance listener.void
removeIlluminanceReachedListener(BrickletAmbientLightV2.IlluminanceReachedListener listener)
Removes a IlluminanceReached listener.void
setConfiguration(short illuminanceRange, short integrationTime)
Sets the configuration.void
setDebouncePeriod(long debounce)
Sets the period with which the threshold listeners *BrickletAmbientLightV2.IlluminanceReachedListener
, are triggered, if the thresholds *setIlluminanceCallbackThreshold(char, long, long)
, keep being reached.void
setIlluminanceCallbackPeriod(long period)
Sets the period with which theBrickletAmbientLightV2.IlluminanceListener
listener is triggered periodically.void
setIlluminanceCallbackThreshold(char option, long min, long max)
Sets the thresholds for theBrickletAmbientLightV2.IlluminanceReachedListener
listener.-
Methods inherited from class com.tinkerforge.DeviceBase
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
-
-
-
-
Field Detail
-
DEVICE_IDENTIFIER
public static final int DEVICE_IDENTIFIER
- See Also:
- Constant Field Values
-
DEVICE_DISPLAY_NAME
public static final java.lang.String DEVICE_DISPLAY_NAME
- See Also:
- Constant Field Values
-
FUNCTION_GET_ILLUMINANCE
public static final byte FUNCTION_GET_ILLUMINANCE
- See Also:
- Constant Field Values
-
FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_SET_DEBOUNCE_PERIOD
public static final byte FUNCTION_SET_DEBOUNCE_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_DEBOUNCE_PERIOD
public static final byte FUNCTION_GET_DEBOUNCE_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_CONFIGURATION
public static final byte FUNCTION_SET_CONFIGURATION
- See Also:
- Constant Field Values
-
FUNCTION_GET_CONFIGURATION
public static final byte FUNCTION_GET_CONFIGURATION
- See Also:
- Constant Field Values
-
FUNCTION_GET_IDENTITY
public static final byte FUNCTION_GET_IDENTITY
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_OFF
public static final char THRESHOLD_OPTION_OFF
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_OUTSIDE
public static final char THRESHOLD_OPTION_OUTSIDE
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_INSIDE
public static final char THRESHOLD_OPTION_INSIDE
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_SMALLER
public static final char THRESHOLD_OPTION_SMALLER
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_GREATER
public static final char THRESHOLD_OPTION_GREATER
- See Also:
- Constant Field Values
-
ILLUMINANCE_RANGE_UNLIMITED
public static final short ILLUMINANCE_RANGE_UNLIMITED
- See Also:
- Constant Field Values
-
ILLUMINANCE_RANGE_64000LUX
public static final short ILLUMINANCE_RANGE_64000LUX
- See Also:
- Constant Field Values
-
ILLUMINANCE_RANGE_32000LUX
public static final short ILLUMINANCE_RANGE_32000LUX
- See Also:
- Constant Field Values
-
ILLUMINANCE_RANGE_16000LUX
public static final short ILLUMINANCE_RANGE_16000LUX
- See Also:
- Constant Field Values
-
ILLUMINANCE_RANGE_8000LUX
public static final short ILLUMINANCE_RANGE_8000LUX
- See Also:
- Constant Field Values
-
ILLUMINANCE_RANGE_1300LUX
public static final short ILLUMINANCE_RANGE_1300LUX
- See Also:
- Constant Field Values
-
ILLUMINANCE_RANGE_600LUX
public static final short ILLUMINANCE_RANGE_600LUX
- See Also:
- Constant Field Values
-
INTEGRATION_TIME_50MS
public static final short INTEGRATION_TIME_50MS
- See Also:
- Constant Field Values
-
INTEGRATION_TIME_100MS
public static final short INTEGRATION_TIME_100MS
- See Also:
- Constant Field Values
-
INTEGRATION_TIME_150MS
public static final short INTEGRATION_TIME_150MS
- See Also:
- Constant Field Values
-
INTEGRATION_TIME_200MS
public static final short INTEGRATION_TIME_200MS
- See Also:
- Constant Field Values
-
INTEGRATION_TIME_250MS
public static final short INTEGRATION_TIME_250MS
- See Also:
- Constant Field Values
-
INTEGRATION_TIME_300MS
public static final short INTEGRATION_TIME_300MS
- See Also:
- Constant Field Values
-
INTEGRATION_TIME_350MS
public static final short INTEGRATION_TIME_350MS
- See Also:
- Constant Field Values
-
INTEGRATION_TIME_400MS
public static final short INTEGRATION_TIME_400MS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletAmbientLightV2
public BrickletAmbientLightV2(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid. and adds it to the IP Connection \c ipcon.
-
-
Method Detail
-
getIlluminance
public long getIlluminance() throws TinkerforgeException
Returns the illuminance of the ambient light sensor. The measurement range goes up to about 100000lux, but above 64000lux the precision starts to drop. .. versionchanged:: 2.0.2$nbsp;(Plugin) An illuminance of 0lux indicates an error condition where the sensor cannot perform a reasonable measurement. This can happen with very dim or very bright light conditions. In bright light conditions this might indicate that the sensor is saturated and the configuration should be modified (setConfiguration(short, short)
) to better match the light conditions. If you want to get the illuminance periodically, it is recommended to use theBrickletAmbientLightV2.IlluminanceListener
listener and set the period withsetIlluminanceCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setIlluminanceCallbackPeriod
public void setIlluminanceCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletAmbientLightV2.IlluminanceListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletAmbientLightV2.IlluminanceListener
listener is only triggered if the illuminance has changed since the last triggering.- Throws:
TinkerforgeException
-
getIlluminanceCallbackPeriod
public long getIlluminanceCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetIlluminanceCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setIlluminanceCallbackThreshold
public void setIlluminanceCallbackThreshold(char option, long min, long max) throws TinkerforgeException
Sets the thresholds for theBrickletAmbientLightV2.IlluminanceReachedListener
listener. The following options are possible: \verbatim "Option", "Description" "'x'", "Listener is turned off" "'o'", "Listener is triggered when the illuminance is *outside* the min and max values" "'i'", "Listener is triggered when the illuminance is *inside* the min and max values" "'<'", "Listener is triggered when the illuminance is smaller than the min value (max is ignored)" "'>'", "Listener is triggered when the illuminance is greater than the min value (max is ignored)" \endverbatim- Throws:
TinkerforgeException
-
getIlluminanceCallbackThreshold
public BrickletAmbientLightV2.IlluminanceCallbackThreshold getIlluminanceCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetIlluminanceCallbackThreshold(char, long, long)
.- Throws:
TinkerforgeException
-
setDebouncePeriod
public void setDebouncePeriod(long debounce) throws TinkerforgeException
Sets the period with which the threshold listeners *BrickletAmbientLightV2.IlluminanceReachedListener
, are triggered, if the thresholds *setIlluminanceCallbackThreshold(char, long, long)
, keep being reached.- Throws:
TinkerforgeException
-
getDebouncePeriod
public long getDebouncePeriod() throws TinkerforgeException
Returns the debounce period as set bysetDebouncePeriod(long)
.- Throws:
TinkerforgeException
-
setConfiguration
public void setConfiguration(short illuminanceRange, short integrationTime) throws TinkerforgeException
Sets the configuration. It is possible to configure an illuminance range between 0-600lux and 0-64000lux and an integration time between 50ms and 400ms. .. versionadded:: 2.0.2$nbsp;(Plugin) The unlimited illuminance range allows to measure up to about 100000lux, but above 64000lux the precision starts to drop. A smaller illuminance range increases the resolution of the data. A longer integration time will result in less noise on the data. .. versionchanged:: 2.0.2$nbsp;(Plugin) If the actual measure illuminance is out-of-range then the current illuminance range maximum +0.01lux is reported bygetIlluminance()
and theBrickletAmbientLightV2.IlluminanceListener
listener. For example, 800001 for the 0-8000lux range. .. versionchanged:: 2.0.2$nbsp;(Plugin) With a long integration time the sensor might be saturated before the measured value reaches the maximum of the selected illuminance range. In this case 0lux is reported bygetIlluminance()
and theBrickletAmbientLightV2.IlluminanceListener
listener. If the measurement is out-of-range or the sensor is saturated then you should configure the next higher illuminance range. If the highest range is already in use, then start to reduce the integration time.- Throws:
TinkerforgeException
-
getConfiguration
public BrickletAmbientLightV2.Configuration getConfiguration() throws TinkerforgeException
Returns the configuration as set bysetConfiguration(short, short)
.- Throws:
TinkerforgeException
-
getIdentity
public Device.Identity getIdentity() throws TinkerforgeException
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|- Specified by:
getIdentity
in classDevice
- Throws:
TinkerforgeException
-
addIlluminanceListener
public void addIlluminanceListener(BrickletAmbientLightV2.IlluminanceListener listener)
Adds a Illuminance listener.
-
removeIlluminanceListener
public void removeIlluminanceListener(BrickletAmbientLightV2.IlluminanceListener listener)
Removes a Illuminance listener.
-
addIlluminanceReachedListener
public void addIlluminanceReachedListener(BrickletAmbientLightV2.IlluminanceReachedListener listener)
Adds a IlluminanceReached listener.
-
removeIlluminanceReachedListener
public void removeIlluminanceReachedListener(BrickletAmbientLightV2.IlluminanceReachedListener listener)
Removes a IlluminanceReached listener.
-
-