Package com.tinkerforge
Class BrickletLine
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletLine
-
public class BrickletLine extends Device
Measures reflectivity of a surface
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletLine.ReflectivityCallbackThreshold
static interface
BrickletLine.ReflectivityListener
This listener is triggered periodically with the period that is set bysetReflectivityCallbackPeriod(long)
.static interface
BrickletLine.ReflectivityReachedListener
This listener is triggered when the threshold as set bysetReflectivityCallbackThreshold(char, int, int)
is reached.-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
Fields Modifier and Type Field 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_REFLECTIVITY
static byte
FUNCTION_GET_REFLECTIVITY_CALLBACK_PERIOD
static byte
FUNCTION_GET_REFLECTIVITY_CALLBACK_THRESHOLD
static byte
FUNCTION_SET_DEBOUNCE_PERIOD
static byte
FUNCTION_SET_REFLECTIVITY_CALLBACK_PERIOD
static byte
FUNCTION_SET_REFLECTIVITY_CALLBACK_THRESHOLD
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 Summary
Constructors Constructor Description BrickletLine(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
addReflectivityListener(BrickletLine.ReflectivityListener listener)
Adds a Reflectivity listener.void
addReflectivityReachedListener(BrickletLine.ReflectivityReachedListener listener)
Adds a ReflectivityReached listener.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.int
getReflectivity()
Returns the currently measured reflectivity.long
getReflectivityCallbackPeriod()
Returns the period as set bysetReflectivityCallbackPeriod(long)
.BrickletLine.ReflectivityCallbackThreshold
getReflectivityCallbackThreshold()
Returns the threshold as set bysetReflectivityCallbackThreshold(char, int, int)
.void
removeReflectivityListener(BrickletLine.ReflectivityListener listener)
Removes a Reflectivity listener.void
removeReflectivityReachedListener(BrickletLine.ReflectivityReachedListener listener)
Removes a ReflectivityReached listener.void
setDebouncePeriod(long debounce)
Sets the period with which the threshold listener *BrickletLine.ReflectivityReachedListener
is triggered, if the threshold *setReflectivityCallbackThreshold(char, int, int)
keeps being reached.void
setReflectivityCallbackPeriod(long period)
Sets the period with which theBrickletLine.ReflectivityListener
listener is triggered periodically.void
setReflectivityCallbackThreshold(char option, int min, int max)
Sets the thresholds for theBrickletLine.ReflectivityReachedListener
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_REFLECTIVITY
public static final byte FUNCTION_GET_REFLECTIVITY
- See Also:
- Constant Field Values
-
FUNCTION_SET_REFLECTIVITY_CALLBACK_PERIOD
public static final byte FUNCTION_SET_REFLECTIVITY_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_REFLECTIVITY_CALLBACK_PERIOD
public static final byte FUNCTION_GET_REFLECTIVITY_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_REFLECTIVITY_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_REFLECTIVITY_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_REFLECTIVITY_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_REFLECTIVITY_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_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
-
-
Constructor Detail
-
BrickletLine
public BrickletLine(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
-
getReflectivity
public int getReflectivity() throws TinkerforgeException
Returns the currently measured reflectivity. The reflectivity is a value between 0 (not reflective) and 4095 (very reflective). Usually black has a low reflectivity while white has a high reflectivity. If you want to get the reflectivity periodically, it is recommended to use theBrickletLine.ReflectivityListener
listener and set the period withsetReflectivityCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setReflectivityCallbackPeriod
public void setReflectivityCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletLine.ReflectivityListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletLine.ReflectivityListener
listener is only triggered if the reflectivity has changed since the last triggering.- Throws:
TinkerforgeException
-
getReflectivityCallbackPeriod
public long getReflectivityCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetReflectivityCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setReflectivityCallbackThreshold
public void setReflectivityCallbackThreshold(char option, int min, int max) throws TinkerforgeException
Sets the thresholds for theBrickletLine.ReflectivityReachedListener
listener. The following options are possible: \verbatim "Option", "Description" "'x'", "Listener is turned off" "'o'", "Listener is triggered when the reflectivity is *outside* the min and max values" "'i'", "Listener is triggered when the reflectivity is *inside* the min and max values" "'<'", "Listener is triggered when the reflectivity is smaller than the min value (max is ignored)" "'>'", "Listener is triggered when the reflectivity is greater than the min value (max is ignored)" \endverbatim- Throws:
TinkerforgeException
-
getReflectivityCallbackThreshold
public BrickletLine.ReflectivityCallbackThreshold getReflectivityCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetReflectivityCallbackThreshold(char, int, int)
.- Throws:
TinkerforgeException
-
setDebouncePeriod
public void setDebouncePeriod(long debounce) throws TinkerforgeException
Sets the period with which the threshold listener *BrickletLine.ReflectivityReachedListener
is triggered, if the threshold *setReflectivityCallbackThreshold(char, int, int)
keeps being reached.- Throws:
TinkerforgeException
-
getDebouncePeriod
public long getDebouncePeriod() throws TinkerforgeException
Returns the debounce period as set bysetDebouncePeriod(long)
.- 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
-
addReflectivityListener
public void addReflectivityListener(BrickletLine.ReflectivityListener listener)
Adds a Reflectivity listener.
-
removeReflectivityListener
public void removeReflectivityListener(BrickletLine.ReflectivityListener listener)
Removes a Reflectivity listener.
-
addReflectivityReachedListener
public void addReflectivityReachedListener(BrickletLine.ReflectivityReachedListener listener)
Adds a ReflectivityReached listener.
-
removeReflectivityReachedListener
public void removeReflectivityReachedListener(BrickletLine.ReflectivityReachedListener listener)
Removes a ReflectivityReached listener.
-
-