Package com.tinkerforge
Class BrickletAmbientLight
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletAmbientLight
-
public class BrickletAmbientLight extends Device
Measures ambient light up to 900lux
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletAmbientLight.AnalogValueCallbackThreshold
static interface
BrickletAmbientLight.AnalogValueListener
This listener is triggered periodically with the period that is set bysetAnalogValueCallbackPeriod(long)
.static interface
BrickletAmbientLight.AnalogValueReachedListener
This listener is triggered when the threshold as set bysetAnalogValueCallbackThreshold(char, int, int)
is reached.class
BrickletAmbientLight.IlluminanceCallbackThreshold
static interface
BrickletAmbientLight.IlluminanceListener
This listener is triggered periodically with the period that is set bysetIlluminanceCallbackPeriod(long)
.static interface
BrickletAmbientLight.IlluminanceReachedListener
This listener is triggered when the threshold as set bysetIlluminanceCallbackThreshold(char, int, int)
is reached.-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEVICE_DISPLAY_NAME
static int
DEVICE_IDENTIFIER
static byte
FUNCTION_GET_ANALOG_VALUE
static byte
FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD
static byte
FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD
static byte
FUNCTION_GET_DEBOUNCE_PERIOD
static byte
FUNCTION_GET_IDENTITY
static byte
FUNCTION_GET_ILLUMINANCE
static byte
FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD
static byte
FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD
static byte
FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD
static byte
FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD
static byte
FUNCTION_SET_DEBOUNCE_PERIOD
static byte
FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD
static byte
FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD
static char
THRESHOLD_OPTION_GREATER
static char
THRESHOLD_OPTION_INSIDE
static char
THRESHOLD_OPTION_OFF
static char
THRESHOLD_OPTION_OUTSIDE
static char
THRESHOLD_OPTION_SMALLER
-
Constructor Summary
Constructors Constructor Description BrickletAmbientLight(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid.
-
Method Summary
-
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_GET_ANALOG_VALUE
public static final byte FUNCTION_GET_ANALOG_VALUE
- 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_ANALOG_VALUE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_ANALOG_VALUE_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_ANALOG_VALUE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_ANALOG_VALUE_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_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
-
-
Constructor Detail
-
BrickletAmbientLight
public BrickletAmbientLight(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 int getIlluminance() throws TinkerforgeException
Returns the illuminance of the ambient light sensor. If you want to get the illuminance periodically, it is recommended to use theBrickletAmbientLight.IlluminanceListener
listener and set the period withsetIlluminanceCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
getAnalogValue
public int getAnalogValue() throws TinkerforgeException
Returns the value as read by a 12-bit analog-to-digital converter. \note The value returned bygetIlluminance()
is averaged over several samples to yield less noise, whilegetAnalogValue()
gives back raw unfiltered analog values. The only reason to usegetAnalogValue()
is, if you need the full resolution of the analog-to-digital converter. Also, the analog-to-digital converter covers three different ranges that are set dynamically depending on the light intensity. It is impossible to distinguish between these ranges with the analog value. If you want the analog value periodically, it is recommended to use theBrickletAmbientLight.AnalogValueListener
listener and set the period withsetAnalogValueCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setIlluminanceCallbackPeriod
public void setIlluminanceCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletAmbientLight.IlluminanceListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletAmbientLight.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
-
setAnalogValueCallbackPeriod
public void setAnalogValueCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletAmbientLight.AnalogValueListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletAmbientLight.AnalogValueListener
listener is only triggered if the analog value has changed since the last triggering.- Throws:
TinkerforgeException
-
getAnalogValueCallbackPeriod
public long getAnalogValueCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetAnalogValueCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setIlluminanceCallbackThreshold
public void setIlluminanceCallbackThreshold(char option, int min, int max) throws TinkerforgeException
Sets the thresholds for theBrickletAmbientLight.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 BrickletAmbientLight.IlluminanceCallbackThreshold getIlluminanceCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetIlluminanceCallbackThreshold(char, int, int)
.- Throws:
TinkerforgeException
-
setAnalogValueCallbackThreshold
public void setAnalogValueCallbackThreshold(char option, int min, int max) throws TinkerforgeException
Sets the thresholds for theBrickletAmbientLight.AnalogValueReachedListener
listener. The following options are possible: \verbatim "Option", "Description" "'x'", "Listener is turned off" "'o'", "Listener is triggered when the analog value is *outside* the min and max values" "'i'", "Listener is triggered when the analog value is *inside* the min and max values" "'<'", "Listener is triggered when the analog value is smaller than the min value (max is ignored)" "'>'", "Listener is triggered when the analog value is greater than the min value (max is ignored)" \endverbatim- Throws:
TinkerforgeException
-
getAnalogValueCallbackThreshold
public BrickletAmbientLight.AnalogValueCallbackThreshold getAnalogValueCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetAnalogValueCallbackThreshold(char, int, int)
.- Throws:
TinkerforgeException
-
setDebouncePeriod
public void setDebouncePeriod(long debounce) throws TinkerforgeException
Sets the period with which the threshold listeners *BrickletAmbientLight.IlluminanceReachedListener
, *BrickletAmbientLight.AnalogValueReachedListener
are triggered, if the thresholds *setIlluminanceCallbackThreshold(char, int, int)
, *setAnalogValueCallbackThreshold(char, int, int)
keep being reached.- Throws:
TinkerforgeException
-
getDebouncePeriod
public long getDebouncePeriod() throws TinkerforgeException
Returns the debounce period as set bysetDebouncePeriod(long)
.- 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(BrickletAmbientLight.IlluminanceListener listener)
Adds a Illuminance listener.
-
removeIlluminanceListener
public void removeIlluminanceListener(BrickletAmbientLight.IlluminanceListener listener)
Removes a Illuminance listener.
-
addAnalogValueListener
public void addAnalogValueListener(BrickletAmbientLight.AnalogValueListener listener)
Adds a AnalogValue listener.
-
removeAnalogValueListener
public void removeAnalogValueListener(BrickletAmbientLight.AnalogValueListener listener)
Removes a AnalogValue listener.
-
addIlluminanceReachedListener
public void addIlluminanceReachedListener(BrickletAmbientLight.IlluminanceReachedListener listener)
Adds a IlluminanceReached listener.
-
removeIlluminanceReachedListener
public void removeIlluminanceReachedListener(BrickletAmbientLight.IlluminanceReachedListener listener)
Removes a IlluminanceReached listener.
-
addAnalogValueReachedListener
public void addAnalogValueReachedListener(BrickletAmbientLight.AnalogValueReachedListener listener)
Adds a AnalogValueReached listener.
-
removeAnalogValueReachedListener
public void removeAnalogValueReachedListener(BrickletAmbientLight.AnalogValueReachedListener listener)
Removes a AnalogValueReached listener.
-
-