public class BrickletMoisture extends Device
Modifier and Type | Class and Description |
---|---|
class |
BrickletMoisture.MoistureCallbackThreshold |
static interface |
BrickletMoisture.MoistureListener
This listener is triggered periodically with the period that is set by
setMoistureCallbackPeriod(long) . |
static interface |
BrickletMoisture.MoistureReachedListener
This listener is triggered when the threshold as set by
setMoistureCallbackThreshold(char, int, int) is reached. |
Device.Identity
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEVICE_DISPLAY_NAME |
static int |
DEVICE_IDENTIFIER |
static byte |
FUNCTION_GET_DEBOUNCE_PERIOD |
static byte |
FUNCTION_GET_IDENTITY |
static byte |
FUNCTION_GET_MOISTURE_CALLBACK_PERIOD |
static byte |
FUNCTION_GET_MOISTURE_CALLBACK_THRESHOLD |
static byte |
FUNCTION_GET_MOISTURE_VALUE |
static byte |
FUNCTION_GET_MOVING_AVERAGE |
static byte |
FUNCTION_SET_DEBOUNCE_PERIOD |
static byte |
FUNCTION_SET_MOISTURE_CALLBACK_PERIOD |
static byte |
FUNCTION_SET_MOISTURE_CALLBACK_THRESHOLD |
static byte |
FUNCTION_SET_MOVING_AVERAGE |
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 |
---|
BrickletMoisture(java.lang.String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addMoistureListener(BrickletMoisture.MoistureListener listener)
Adds a Moisture listener.
|
void |
addMoistureReachedListener(BrickletMoisture.MoistureReachedListener listener)
Adds a MoistureReached listener.
|
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 |
getMoistureCallbackPeriod()
Returns the period as set by
setMoistureCallbackPeriod(long) . |
BrickletMoisture.MoistureCallbackThreshold |
getMoistureCallbackThreshold()
Returns the threshold as set by
setMoistureCallbackThreshold(char, int, int) . |
int |
getMoistureValue()
Returns the current moisture value.
|
short |
getMovingAverage()
Returns the length moving average as set by
setMovingAverage(short) . |
void |
removeMoistureListener(BrickletMoisture.MoistureListener listener)
Removes a Moisture listener.
|
void |
removeMoistureReachedListener(BrickletMoisture.MoistureReachedListener listener)
Removes a MoistureReached listener.
|
void |
setDebouncePeriod(long debounce)
Sets the period with which the threshold listener
*
BrickletMoisture.MoistureReachedListener
is triggered, if the threshold
* setMoistureCallbackThreshold(char, int, int)
keeps being reached. |
void |
setMoistureCallbackPeriod(long period)
Sets the period with which the
BrickletMoisture.MoistureListener listener is triggered
periodically. |
void |
setMoistureCallbackThreshold(char option,
int min,
int max)
Sets the thresholds for the
BrickletMoisture.MoistureReachedListener listener. |
void |
setMovingAverage(short average)
Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
for the moisture value.
|
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_MOISTURE_VALUE
public static final byte FUNCTION_SET_MOISTURE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_MOISTURE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_MOISTURE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_MOISTURE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_DEBOUNCE_PERIOD
public static final byte FUNCTION_GET_DEBOUNCE_PERIOD
public static final byte FUNCTION_SET_MOVING_AVERAGE
public static final byte FUNCTION_GET_MOVING_AVERAGE
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 BrickletMoisture(java.lang.String uid, IPConnection ipcon)
public int getMoistureValue() throws TinkerforgeException
BrickletMoisture.MoistureListener
listener and set the period with
setMoistureCallbackPeriod(long)
.TinkerforgeException
public void setMoistureCallbackPeriod(long period) throws TinkerforgeException
BrickletMoisture.MoistureListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletMoisture.MoistureListener
listener is only triggered if the moisture value has changed
since the last triggering.TinkerforgeException
public long getMoistureCallbackPeriod() throws TinkerforgeException
setMoistureCallbackPeriod(long)
.TinkerforgeException
public void setMoistureCallbackThreshold(char option, int min, int max) throws TinkerforgeException
BrickletMoisture.MoistureReachedListener
listener.
The following options are possible:
\verbatim
"Option", "Description"
"'x'", "Listener is turned off"
"'o'", "Listener is triggered when the moisture value is *outside* the min and max values"
"'i'", "Listener is triggered when the moisture value is *inside* the min and max values"
"'<'", "Listener is triggered when the moisture value is smaller than the min value (max is ignored)"
"'>'", "Listener is triggered when the moisture value is greater than the min value (max is ignored)"
\endverbatimTinkerforgeException
public BrickletMoisture.MoistureCallbackThreshold getMoistureCallbackThreshold() throws TinkerforgeException
setMoistureCallbackThreshold(char, int, int)
.TinkerforgeException
public void setDebouncePeriod(long debounce) throws TinkerforgeException
BrickletMoisture.MoistureReachedListener
is triggered, if the threshold
* setMoistureCallbackThreshold(char, int, int)
keeps being reached.TinkerforgeException
public long getDebouncePeriod() throws TinkerforgeException
setDebouncePeriod(long)
.TinkerforgeException
public void setMovingAverage(short average) throws TinkerforgeException
TinkerforgeException
public short getMovingAverage() throws TinkerforgeException
setMovingAverage(short)
.TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addMoistureListener(BrickletMoisture.MoistureListener listener)
public void removeMoistureListener(BrickletMoisture.MoistureListener listener)
public void addMoistureReachedListener(BrickletMoisture.MoistureReachedListener listener)
public void removeMoistureReachedListener(BrickletMoisture.MoistureReachedListener listener)
Copyright © 2020 Tinkerforge GmbH. All rights reserved.