public class BrickletAmbientLightV2 extends Device
Modifier and Type | Class and Description |
---|---|
class |
BrickletAmbientLightV2.Configuration |
class |
BrickletAmbientLightV2.IlluminanceCallbackThreshold |
static interface |
BrickletAmbientLightV2.IlluminanceListener
This listener is triggered periodically with the period that is set by
setIlluminanceCallbackPeriod(long) . |
static interface |
BrickletAmbientLightV2.IlluminanceReachedListener
This listener is triggered when the threshold as set by
setIlluminanceCallbackThreshold(char, long, long) is reached. |
Device.Identity
Constructor and Description |
---|
BrickletAmbientLightV2(java.lang.String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and 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 by
setConfiguration(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 of the ambient light sensor.
|
long |
getIlluminanceCallbackPeriod()
Returns the period as set by
setIlluminanceCallbackPeriod(long) . |
BrickletAmbientLightV2.IlluminanceCallbackThreshold |
getIlluminanceCallbackThreshold()
Returns the threshold as set by
setIlluminanceCallbackThreshold(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 the
BrickletAmbientLightV2.IlluminanceListener listener is triggered
periodically. |
void |
setIlluminanceCallbackThreshold(char option,
long min,
long max)
Sets the thresholds for the
BrickletAmbientLightV2.IlluminanceReachedListener listener. |
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
public static final int DEVICE_IDENTIFIER
public static final java.lang.String DEVICE_DISPLAY_NAME
public static final byte FUNCTION_GET_ILLUMINANCE
public static final byte FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_DEBOUNCE_PERIOD
public static final byte FUNCTION_GET_DEBOUNCE_PERIOD
public static final byte FUNCTION_SET_CONFIGURATION
public static final byte FUNCTION_GET_CONFIGURATION
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 ILLUMINANCE_RANGE_UNLIMITED
public static final short ILLUMINANCE_RANGE_64000LUX
public static final short ILLUMINANCE_RANGE_32000LUX
public static final short ILLUMINANCE_RANGE_16000LUX
public static final short ILLUMINANCE_RANGE_8000LUX
public static final short ILLUMINANCE_RANGE_1300LUX
public static final short ILLUMINANCE_RANGE_600LUX
public static final short INTEGRATION_TIME_50MS
public static final short INTEGRATION_TIME_100MS
public static final short INTEGRATION_TIME_150MS
public static final short INTEGRATION_TIME_200MS
public static final short INTEGRATION_TIME_250MS
public static final short INTEGRATION_TIME_300MS
public static final short INTEGRATION_TIME_350MS
public static final short INTEGRATION_TIME_400MS
public BrickletAmbientLightV2(java.lang.String uid, IPConnection ipcon)
public long getIlluminance() throws TinkerforgeException
setConfiguration(short, short)
.
If you want to get the illuminance periodically, it is recommended to use the
BrickletAmbientLightV2.IlluminanceListener
listener and set the period with
setIlluminanceCallbackPeriod(long)
.TinkerforgeException
public void setIlluminanceCallbackPeriod(long period) throws TinkerforgeException
BrickletAmbientLightV2.IlluminanceListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletAmbientLightV2.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 setIlluminanceCallbackThreshold(char option, long min, long max) throws TinkerforgeException
BrickletAmbientLightV2.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)"
\endverbatimTinkerforgeException
public BrickletAmbientLightV2.IlluminanceCallbackThreshold getIlluminanceCallbackThreshold() throws TinkerforgeException
setIlluminanceCallbackThreshold(char, long, long)
.TinkerforgeException
public void setDebouncePeriod(long debounce) throws TinkerforgeException
BrickletAmbientLightV2.IlluminanceReachedListener
,
are triggered, if the thresholds
* setIlluminanceCallbackThreshold(char, long, long)
,
keep being reached.TinkerforgeException
public long getDebouncePeriod() throws TinkerforgeException
setDebouncePeriod(long)
.TinkerforgeException
public void setConfiguration(short illuminanceRange, short integrationTime) throws TinkerforgeException
getIlluminance()
and the
BrickletAmbientLightV2.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 by getIlluminance()
and the BrickletAmbientLightV2.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.TinkerforgeException
public BrickletAmbientLightV2.Configuration getConfiguration() throws TinkerforgeException
setConfiguration(short, short)
.TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addIlluminanceListener(BrickletAmbientLightV2.IlluminanceListener listener)
public void removeIlluminanceListener(BrickletAmbientLightV2.IlluminanceListener listener)
public void addIlluminanceReachedListener(BrickletAmbientLightV2.IlluminanceReachedListener listener)
public void removeIlluminanceReachedListener(BrickletAmbientLightV2.IlluminanceReachedListener listener)
Copyright © 2020 Tinkerforge GmbH. All rights reserved.