Package com.tinkerforge
Class BrickletAnalogIn
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletAnalogIn
-
public class BrickletAnalogIn extends Device
Measures DC voltage between 0V and 45V
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletAnalogIn.AnalogValueCallbackThreshold
static interface
BrickletAnalogIn.AnalogValueListener
This listener is triggered periodically with the period that is set bysetAnalogValueCallbackPeriod(long)
.static interface
BrickletAnalogIn.AnalogValueReachedListener
This listener is triggered when the threshold as set bysetAnalogValueCallbackThreshold(char, int, int)
is reached.class
BrickletAnalogIn.VoltageCallbackThreshold
static interface
BrickletAnalogIn.VoltageListener
This listener is triggered periodically with the period that is set bysetVoltageCallbackPeriod(long)
.static interface
BrickletAnalogIn.VoltageReachedListener
This listener is triggered when the threshold as set bysetVoltageCallbackThreshold(char, int, int)
is reached.-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BrickletAnalogIn(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
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 bysetAnalogValueCallbackPeriod(long)
.BrickletAnalogIn.AnalogValueCallbackThreshold
getAnalogValueCallbackThreshold()
Returns the threshold as set bysetAnalogValueCallbackThreshold(char, int, int)
.short
getAveraging()
Returns the averaging configuration as set bysetAveraging(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.short
getRange()
Returns the measurement range as set bysetRange(short)
.int
getVoltage()
Returns the voltage of the sensor.long
getVoltageCallbackPeriod()
Returns the period as set bysetVoltageCallbackPeriod(long)
.BrickletAnalogIn.VoltageCallbackThreshold
getVoltageCallbackThreshold()
Returns the threshold as set bysetVoltageCallbackThreshold(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 theBrickletAnalogIn.AnalogValueListener
listener is triggered periodically.void
setAnalogValueCallbackThreshold(char option, int min, int max)
Sets the thresholds for theBrickletAnalogIn.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 theBrickletAnalogIn.VoltageListener
listener is triggered periodically.void
setVoltageCallbackThreshold(char option, int min, int max)
Sets the thresholds for theBrickletAnalogIn.VoltageReachedListener
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_VOLTAGE
public static final byte FUNCTION_GET_VOLTAGE
- See Also:
- Constant Field Values
-
FUNCTION_GET_ANALOG_VALUE
public static final byte FUNCTION_GET_ANALOG_VALUE
- See Also:
- Constant Field Values
-
FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_VOLTAGE_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_VOLTAGE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_VOLTAGE_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_SET_RANGE
public static final byte FUNCTION_SET_RANGE
- See Also:
- Constant Field Values
-
FUNCTION_GET_RANGE
public static final byte FUNCTION_GET_RANGE
- See Also:
- Constant Field Values
-
FUNCTION_SET_AVERAGING
public static final byte FUNCTION_SET_AVERAGING
- See Also:
- Constant Field Values
-
FUNCTION_GET_AVERAGING
public static final byte FUNCTION_GET_AVERAGING
- 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
-
RANGE_AUTOMATIC
public static final short RANGE_AUTOMATIC
- See Also:
- Constant Field Values
-
RANGE_UP_TO_6V
public static final short RANGE_UP_TO_6V
- See Also:
- Constant Field Values
-
RANGE_UP_TO_10V
public static final short RANGE_UP_TO_10V
- See Also:
- Constant Field Values
-
RANGE_UP_TO_36V
public static final short RANGE_UP_TO_36V
- See Also:
- Constant Field Values
-
RANGE_UP_TO_45V
public static final short RANGE_UP_TO_45V
- See Also:
- Constant Field Values
-
RANGE_UP_TO_3V
public static final short RANGE_UP_TO_3V
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletAnalogIn
public BrickletAnalogIn(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
-
getVoltage
public int getVoltage() throws TinkerforgeException
Returns the voltage of the sensor. The resolution between 0 and 6V is about 2mV. Between 6 and 45V the resolution is about 10mV. If you want to get the voltage periodically, it is recommended to use theBrickletAnalogIn.VoltageListener
listener and set the period withsetVoltageCallbackPeriod(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 bygetVoltage()
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. If you want the analog value periodically, it is recommended to use theBrickletAnalogIn.AnalogValueListener
listener and set the period withsetAnalogValueCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setVoltageCallbackPeriod
public void setVoltageCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletAnalogIn.VoltageListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletAnalogIn.VoltageListener
listener is only triggered if the voltage has changed since the last triggering.- Throws:
TinkerforgeException
-
getVoltageCallbackPeriod
public long getVoltageCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetVoltageCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setAnalogValueCallbackPeriod
public void setAnalogValueCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletAnalogIn.AnalogValueListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletAnalogIn.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
-
setVoltageCallbackThreshold
public void setVoltageCallbackThreshold(char option, int min, int max) throws TinkerforgeException
Sets the thresholds for theBrickletAnalogIn.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)" \endverbatim- Throws:
TinkerforgeException
-
getVoltageCallbackThreshold
public BrickletAnalogIn.VoltageCallbackThreshold getVoltageCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetVoltageCallbackThreshold(char, int, int)
.- Throws:
TinkerforgeException
-
setAnalogValueCallbackThreshold
public void setAnalogValueCallbackThreshold(char option, int min, int max) throws TinkerforgeException
Sets the thresholds for theBrickletAnalogIn.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 BrickletAnalogIn.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 *BrickletAnalogIn.VoltageReachedListener
, *BrickletAnalogIn.AnalogValueReachedListener
are triggered, if the thresholds *setVoltageCallbackThreshold(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
-
setRange
public void setRange(short range) throws TinkerforgeException
Sets the measurement range. Possible ranges: * 0: Automatically switched * 1: 0V - 6.05V, ~1.48mV resolution * 2: 0V - 10.32V, ~2.52mV resolution * 3: 0V - 36.30V, ~8.86mV resolution * 4: 0V - 45.00V, ~11.25mV resolution * 5: 0V - 3.3V, ~0.81mV resolution, new in version 2.0.3$nbsp;(Plugin) .. versionadded:: 2.0.1$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getRange
public short getRange() throws TinkerforgeException
Returns the measurement range as set bysetRange(short)
. .. versionadded:: 2.0.1$nbsp;(Plugin)- Throws:
TinkerforgeException
-
setAveraging
public void setAveraging(short average) throws TinkerforgeException
Set the length of a averaging for the voltage value. Setting the length to 0 will turn the averaging completely off. If the averaging is off, there is more noise on the data, but the data is without delay. .. versionadded:: 2.0.3$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getAveraging
public short getAveraging() throws TinkerforgeException
Returns the averaging configuration as set bysetAveraging(short)
. .. versionadded:: 2.0.3$nbsp;(Plugin)- 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
-
addVoltageListener
public void addVoltageListener(BrickletAnalogIn.VoltageListener listener)
Adds a Voltage listener.
-
removeVoltageListener
public void removeVoltageListener(BrickletAnalogIn.VoltageListener listener)
Removes a Voltage listener.
-
addAnalogValueListener
public void addAnalogValueListener(BrickletAnalogIn.AnalogValueListener listener)
Adds a AnalogValue listener.
-
removeAnalogValueListener
public void removeAnalogValueListener(BrickletAnalogIn.AnalogValueListener listener)
Removes a AnalogValue listener.
-
addVoltageReachedListener
public void addVoltageReachedListener(BrickletAnalogIn.VoltageReachedListener listener)
Adds a VoltageReached listener.
-
removeVoltageReachedListener
public void removeVoltageReachedListener(BrickletAnalogIn.VoltageReachedListener listener)
Removes a VoltageReached listener.
-
addAnalogValueReachedListener
public void addAnalogValueReachedListener(BrickletAnalogIn.AnalogValueReachedListener listener)
Adds a AnalogValueReached listener.
-
removeAnalogValueReachedListener
public void removeAnalogValueReachedListener(BrickletAnalogIn.AnalogValueReachedListener listener)
Removes a AnalogValueReached listener.
-
-