public class BrickletAnalogIn extends Device
Modifier and Type | Class and Description |
---|---|
class |
BrickletAnalogIn.AnalogValueCallbackThreshold |
static interface |
BrickletAnalogIn.AnalogValueListener
This listener is triggered periodically with the period that is set by
setAnalogValueCallbackPeriod(long) . |
static interface |
BrickletAnalogIn.AnalogValueReachedListener
This listener is triggered when the threshold as set by
setAnalogValueCallbackThreshold(char, int, int) is reached. |
class |
BrickletAnalogIn.VoltageCallbackThreshold |
static interface |
BrickletAnalogIn.VoltageListener
This listener is triggered periodically with the period that is set by
setVoltageCallbackPeriod(long) . |
static interface |
BrickletAnalogIn.VoltageReachedListener
This listener is triggered when the threshold as set by
setVoltageCallbackThreshold(char, int, int) is reached. |
Device.Identity
Constructor and Description |
---|
BrickletAnalogIn(String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addAnalogValueListener(BrickletAnalogIn.AnalogValueListener listener)
Adds a AnalogValue listener.
|
void |
addAnalogValueReachedListener(BrickletAnalogIn.AnalogValueReachedListener listener)
Adds a AnalogValueReached listener.
|
void |
addVoltageListener(BrickletAnalogIn.VoltageListener listener)
Adds a Voltage listener.
|
void |
addVoltageReachedListener(BrickletAnalogIn.VoltageReachedListener listener)
Adds a VoltageReached 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) . |
BrickletAnalogIn.AnalogValueCallbackThreshold |
getAnalogValueCallbackThreshold()
Returns the threshold as set by
setAnalogValueCallbackThreshold(char, int, int) . |
short |
getAveraging()
Returns the averaging configuration as set by
setAveraging(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.
|
short |
getRange()
Returns the measurement range as set by
setRange(short) . |
int |
getVoltage()
Returns the voltage of the sensor.
|
long |
getVoltageCallbackPeriod()
Returns the period as set by
setVoltageCallbackPeriod(long) . |
BrickletAnalogIn.VoltageCallbackThreshold |
getVoltageCallbackThreshold()
Returns the threshold as set by
setVoltageCallbackThreshold(char, int, int) . |
void |
removeAnalogValueListener(BrickletAnalogIn.AnalogValueListener listener)
Removes a AnalogValue listener.
|
void |
removeAnalogValueReachedListener(BrickletAnalogIn.AnalogValueReachedListener listener)
Removes a AnalogValueReached listener.
|
void |
removeVoltageListener(BrickletAnalogIn.VoltageListener listener)
Removes a Voltage listener.
|
void |
removeVoltageReachedListener(BrickletAnalogIn.VoltageReachedListener listener)
Removes a VoltageReached listener.
|
void |
setAnalogValueCallbackPeriod(long period)
Sets the period with which the
BrickletAnalogIn.AnalogValueListener listener is triggered
periodically. |
void |
setAnalogValueCallbackThreshold(char option,
int min,
int max)
Sets the thresholds for the
BrickletAnalogIn.AnalogValueReachedListener listener. |
void |
setAveraging(short average)
Set the length of a averaging for the voltage value.
|
void |
setDebouncePeriod(long debounce)
Sets the period with which the threshold listeners
*
BrickletAnalogIn.VoltageReachedListener ,
* BrickletAnalogIn.AnalogValueReachedListener
are triggered, if the thresholds
* setVoltageCallbackThreshold(char, int, int) ,
* setAnalogValueCallbackThreshold(char, int, int)
keep being reached. |
void |
setRange(short range)
Sets the measurement range.
|
void |
setVoltageCallbackPeriod(long period)
Sets the period with which the
BrickletAnalogIn.VoltageListener listener is triggered
periodically. |
void |
setVoltageCallbackThreshold(char option,
int min,
int max)
Sets the thresholds for the
BrickletAnalogIn.VoltageReachedListener listener. |
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
public static final int DEVICE_IDENTIFIER
public static final String DEVICE_DISPLAY_NAME
public static final byte FUNCTION_GET_VOLTAGE
public static final byte FUNCTION_GET_ANALOG_VALUE
public static final byte FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_VOLTAGE_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_VOLTAGE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_VOLTAGE_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_SET_RANGE
public static final byte FUNCTION_GET_RANGE
public static final byte FUNCTION_SET_AVERAGING
public static final byte FUNCTION_GET_AVERAGING
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 RANGE_AUTOMATIC
public static final short RANGE_UP_TO_6V
public static final short RANGE_UP_TO_10V
public static final short RANGE_UP_TO_36V
public static final short RANGE_UP_TO_45V
public static final short RANGE_UP_TO_3V
public BrickletAnalogIn(String uid, IPConnection ipcon)
public int getVoltage() throws TinkerforgeException
BrickletAnalogIn.VoltageListener
listener and set the period with
setVoltageCallbackPeriod(long)
.TinkerforgeException
public int getAnalogValue() throws TinkerforgeException
getVoltage()
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
BrickletAnalogIn.AnalogValueListener
listener and set the period with
setAnalogValueCallbackPeriod(long)
.TinkerforgeException
public void setVoltageCallbackPeriod(long period) throws TinkerforgeException
BrickletAnalogIn.VoltageListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletAnalogIn.VoltageListener
listener is only triggered if the voltage has changed since
the last triggering.TinkerforgeException
public long getVoltageCallbackPeriod() throws TinkerforgeException
setVoltageCallbackPeriod(long)
.TinkerforgeException
public void setAnalogValueCallbackPeriod(long period) throws TinkerforgeException
BrickletAnalogIn.AnalogValueListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletAnalogIn.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 setVoltageCallbackThreshold(char option, int min, int max) throws TinkerforgeException
BrickletAnalogIn.VoltageReachedListener
listener.
The following options are possible:
\verbatim
"Option", "Description"
"'x'", "Listener is turned off"
"'o'", "Listener is triggered when the voltage is *outside* the min and max values"
"'i'", "Listener is triggered when the voltage is *inside* the min and max values"
"'<'", "Listener is triggered when the voltage is smaller than the min value (max is ignored)"
"'>'", "Listener is triggered when the voltage is greater than the min value (max is ignored)"
\endverbatimTinkerforgeException
public BrickletAnalogIn.VoltageCallbackThreshold getVoltageCallbackThreshold() throws TinkerforgeException
setVoltageCallbackThreshold(char, int, int)
.TinkerforgeException
public void setAnalogValueCallbackThreshold(char option, int min, int max) throws TinkerforgeException
BrickletAnalogIn.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 BrickletAnalogIn.AnalogValueCallbackThreshold getAnalogValueCallbackThreshold() throws TinkerforgeException
setAnalogValueCallbackThreshold(char, int, int)
.TinkerforgeException
public void setDebouncePeriod(long debounce) throws TinkerforgeException
BrickletAnalogIn.VoltageReachedListener
,
* BrickletAnalogIn.AnalogValueReachedListener
are triggered, if the thresholds
* setVoltageCallbackThreshold(char, int, int)
,
* setAnalogValueCallbackThreshold(char, int, int)
keep being reached.TinkerforgeException
public long getDebouncePeriod() throws TinkerforgeException
setDebouncePeriod(long)
.TinkerforgeException
public void setRange(short range) throws TinkerforgeException
TinkerforgeException
public short getRange() throws TinkerforgeException
setRange(short)
.
.. versionadded:: 2.0.1$nbsp;(Plugin)TinkerforgeException
public void setAveraging(short average) throws TinkerforgeException
TinkerforgeException
public short getAveraging() throws TinkerforgeException
setAveraging(short)
.
.. versionadded:: 2.0.3$nbsp;(Plugin)TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addVoltageListener(BrickletAnalogIn.VoltageListener listener)
public void removeVoltageListener(BrickletAnalogIn.VoltageListener listener)
public void addAnalogValueListener(BrickletAnalogIn.AnalogValueListener listener)
public void removeAnalogValueListener(BrickletAnalogIn.AnalogValueListener listener)
public void addVoltageReachedListener(BrickletAnalogIn.VoltageReachedListener listener)
public void removeVoltageReachedListener(BrickletAnalogIn.VoltageReachedListener listener)
public void addAnalogValueReachedListener(BrickletAnalogIn.AnalogValueReachedListener listener)
public void removeAnalogValueReachedListener(BrickletAnalogIn.AnalogValueReachedListener listener)
Copyright © 2021 Tinkerforge GmbH. All rights reserved.