public class BrickletDistanceIR extends Device
Modifier and Type | Class and Description |
---|---|
class |
BrickletDistanceIR.AnalogValueCallbackThreshold |
static interface |
BrickletDistanceIR.AnalogValueListener
This listener is triggered periodically with the period that is set by
setAnalogValueCallbackPeriod(long) . |
static interface |
BrickletDistanceIR.AnalogValueReachedListener
This listener is triggered when the threshold as set by
setAnalogValueCallbackThreshold(char, int, int) is reached. |
class |
BrickletDistanceIR.DistanceCallbackThreshold |
static interface |
BrickletDistanceIR.DistanceListener
This listener is triggered periodically with the period that is set by
setDistanceCallbackPeriod(long) . |
static interface |
BrickletDistanceIR.DistanceReachedListener
This listener is triggered when the threshold as set by
setDistanceCallbackThreshold(char, int, int) is reached. |
Device.Identity
Modifier and Type | Field and Description |
---|---|
static 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_DISTANCE |
static byte |
FUNCTION_GET_DISTANCE_CALLBACK_PERIOD |
static byte |
FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD |
static byte |
FUNCTION_GET_IDENTITY |
static byte |
FUNCTION_GET_SAMPLING_POINT |
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_DISTANCE_CALLBACK_PERIOD |
static byte |
FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD |
static byte |
FUNCTION_SET_SAMPLING_POINT |
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 and Description |
---|
BrickletDistanceIR(String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addAnalogValueListener(BrickletDistanceIR.AnalogValueListener listener)
Adds a AnalogValue listener.
|
void |
addAnalogValueReachedListener(BrickletDistanceIR.AnalogValueReachedListener listener)
Adds a AnalogValueReached listener.
|
void |
addDistanceListener(BrickletDistanceIR.DistanceListener listener)
Adds a Distance listener.
|
void |
addDistanceReachedListener(BrickletDistanceIR.DistanceReachedListener listener)
Adds a DistanceReached listener.
|
int |
getAnalogValue()
Returns the value as read by a 12-bit analog-to-digital converter.
|
long |
getAnalogValueCallbackPeriod()
Returns the period as set by
setAnalogValueCallbackPeriod(long) . |
BrickletDistanceIR.AnalogValueCallbackThreshold |
getAnalogValueCallbackThreshold()
Returns the threshold as set by
setAnalogValueCallbackThreshold(char, int, int) . |
long |
getDebouncePeriod()
Returns the debounce period as set by
setDebouncePeriod(long) . |
int |
getDistance()
Returns the distance measured by the sensor.
|
long |
getDistanceCallbackPeriod()
Returns the period as set by
setDistanceCallbackPeriod(long) . |
BrickletDistanceIR.DistanceCallbackThreshold |
getDistanceCallbackThreshold()
Returns the threshold as set by
setDistanceCallbackThreshold(char, int, int) . |
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.
|
int |
getSamplingPoint(short position)
Returns the distance to a sampling point position as set by
setSamplingPoint(short, int) . |
void |
removeAnalogValueListener(BrickletDistanceIR.AnalogValueListener listener)
Removes a AnalogValue listener.
|
void |
removeAnalogValueReachedListener(BrickletDistanceIR.AnalogValueReachedListener listener)
Removes a AnalogValueReached listener.
|
void |
removeDistanceListener(BrickletDistanceIR.DistanceListener listener)
Removes a Distance listener.
|
void |
removeDistanceReachedListener(BrickletDistanceIR.DistanceReachedListener listener)
Removes a DistanceReached listener.
|
void |
setAnalogValueCallbackPeriod(long period)
Sets the period with which the
BrickletDistanceIR.AnalogValueListener listener is triggered
periodically. |
void |
setAnalogValueCallbackThreshold(char option,
int min,
int max)
Sets the thresholds for the
BrickletDistanceIR.AnalogValueReachedListener listener. |
void |
setDebouncePeriod(long debounce)
Sets the period with which the threshold listeners
*
BrickletDistanceIR.DistanceReachedListener ,
* BrickletDistanceIR.AnalogValueReachedListener
are triggered, if the thresholds
* setDistanceCallbackThreshold(char, int, int) ,
* setAnalogValueCallbackThreshold(char, int, int)
keep being reached. |
void |
setDistanceCallbackPeriod(long period)
Sets the period with which the
BrickletDistanceIR.DistanceListener listener is triggered
periodically. |
void |
setDistanceCallbackThreshold(char option,
int min,
int max)
Sets the thresholds for the
BrickletDistanceIR.DistanceReachedListener listener. |
void |
setSamplingPoint(short position,
int distance)
Sets a sampling point value to a specific position of the lookup table.
|
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
public static final int DEVICE_IDENTIFIER
public static final String DEVICE_DISPLAY_NAME
public static final byte FUNCTION_GET_DISTANCE
public static final byte FUNCTION_GET_ANALOG_VALUE
public static final byte FUNCTION_SET_SAMPLING_POINT
public static final byte FUNCTION_GET_SAMPLING_POINT
public static final byte FUNCTION_SET_DISTANCE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_DISTANCE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_DEBOUNCE_PERIOD
public static final byte FUNCTION_GET_DEBOUNCE_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 BrickletDistanceIR(String uid, IPConnection ipcon)
public int getDistance() throws TinkerforgeException
BrickletDistanceIR.DistanceListener
listener and set the period with
setDistanceCallbackPeriod(long)
.TinkerforgeException
public int getAnalogValue() throws TinkerforgeException
getDistance()
is averaged over several samples
to yield less noise, while getAnalogValue()
gives back raw
unfiltered analog values. The only reason to use getAnalogValue()
is,
if you need the full resolution of the analog-to-digital converter.
If you want the analog value periodically, it is recommended to use the
BrickletDistanceIR.AnalogValueListener
listener and set the period with
setAnalogValueCallbackPeriod(long)
.TinkerforgeException
public void setSamplingPoint(short position, int distance) throws TinkerforgeException
TinkerforgeException
public int getSamplingPoint(short position) throws TinkerforgeException
setSamplingPoint(short, int)
.TinkerforgeException
public void setDistanceCallbackPeriod(long period) throws TinkerforgeException
BrickletDistanceIR.DistanceListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletDistanceIR.DistanceListener
listener is only triggered if the distance has changed since the
last triggering.TinkerforgeException
public long getDistanceCallbackPeriod() throws TinkerforgeException
setDistanceCallbackPeriod(long)
.TinkerforgeException
public void setAnalogValueCallbackPeriod(long period) throws TinkerforgeException
BrickletDistanceIR.AnalogValueListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletDistanceIR.AnalogValueListener
listener is only triggered if the analog value has
changed since the last triggering.TinkerforgeException
public long getAnalogValueCallbackPeriod() throws TinkerforgeException
setAnalogValueCallbackPeriod(long)
.TinkerforgeException
public void setDistanceCallbackThreshold(char option, int min, int max) throws TinkerforgeException
BrickletDistanceIR.DistanceReachedListener
listener.
The following options are possible:
\verbatim
"Option", "Description"
"'x'", "Listener is turned off"
"'o'", "Listener is triggered when the distance is *outside* the min and max values"
"'i'", "Listener is triggered when the distance is *inside* the min and max values"
"'<'", "Listener is triggered when the distance is smaller than the min value (max is ignored)"
"'>'", "Listener is triggered when the distance is greater than the min value (max is ignored)"
\endverbatimTinkerforgeException
public BrickletDistanceIR.DistanceCallbackThreshold getDistanceCallbackThreshold() throws TinkerforgeException
setDistanceCallbackThreshold(char, int, int)
.TinkerforgeException
public void setAnalogValueCallbackThreshold(char option, int min, int max) throws TinkerforgeException
BrickletDistanceIR.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)"
\endverbatimTinkerforgeException
public BrickletDistanceIR.AnalogValueCallbackThreshold getAnalogValueCallbackThreshold() throws TinkerforgeException
setAnalogValueCallbackThreshold(char, int, int)
.TinkerforgeException
public void setDebouncePeriod(long debounce) throws TinkerforgeException
BrickletDistanceIR.DistanceReachedListener
,
* BrickletDistanceIR.AnalogValueReachedListener
are triggered, if the thresholds
* setDistanceCallbackThreshold(char, int, int)
,
* setAnalogValueCallbackThreshold(char, int, int)
keep being reached.TinkerforgeException
public long getDebouncePeriod() throws TinkerforgeException
setDebouncePeriod(long)
.TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addDistanceListener(BrickletDistanceIR.DistanceListener listener)
public void removeDistanceListener(BrickletDistanceIR.DistanceListener listener)
public void addAnalogValueListener(BrickletDistanceIR.AnalogValueListener listener)
public void removeAnalogValueListener(BrickletDistanceIR.AnalogValueListener listener)
public void addDistanceReachedListener(BrickletDistanceIR.DistanceReachedListener listener)
public void removeDistanceReachedListener(BrickletDistanceIR.DistanceReachedListener listener)
public void addAnalogValueReachedListener(BrickletDistanceIR.AnalogValueReachedListener listener)
public void removeAnalogValueReachedListener(BrickletDistanceIR.AnalogValueReachedListener listener)
Copyright © 2022 Tinkerforge GmbH. All rights reserved.