Package com.tinkerforge
Class BrickletHallEffect
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletHallEffect
-
public class BrickletHallEffect extends Device
Detects presence of magnetic field
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletHallEffect.EdgeCountConfig
static interface
BrickletHallEffect.EdgeCountListener
This listener is triggered periodically with the period that is set bysetEdgeCountCallbackPeriod(long)
.class
BrickletHallEffect.EdgeInterrupt
-
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 short
EDGE_TYPE_BOTH
static short
EDGE_TYPE_FALLING
static short
EDGE_TYPE_RISING
static byte
FUNCTION_EDGE_INTERRUPT
static byte
FUNCTION_GET_EDGE_COUNT
static byte
FUNCTION_GET_EDGE_COUNT_CALLBACK_PERIOD
static byte
FUNCTION_GET_EDGE_COUNT_CONFIG
static byte
FUNCTION_GET_EDGE_INTERRUPT
static byte
FUNCTION_GET_IDENTITY
static byte
FUNCTION_GET_VALUE
static byte
FUNCTION_SET_EDGE_COUNT_CALLBACK_PERIOD
static byte
FUNCTION_SET_EDGE_COUNT_CONFIG
static byte
FUNCTION_SET_EDGE_INTERRUPT
-
Constructor Summary
Constructors Constructor Description BrickletHallEffect(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
addEdgeCountListener(BrickletHallEffect.EdgeCountListener listener)
Adds a EdgeCount listener.BrickletHallEffect.EdgeInterrupt
edgeInterrupt()
This listener is triggered every n-th count, as configured withsetEdgeInterrupt(long)
.long
getEdgeCount(boolean resetCounter)
Returns the current value of the edge counter.long
getEdgeCountCallbackPeriod()
Returns the period as set bysetEdgeCountCallbackPeriod(long)
.BrickletHallEffect.EdgeCountConfig
getEdgeCountConfig()
Returns the edge type and debounce time as set bysetEdgeCountConfig(short, short)
.long
getEdgeInterrupt()
Returns the edges as set bysetEdgeInterrupt(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.boolean
getValue()
Returns *true* if a magnetic field of 3.5 millitesla or greater is detected.void
removeEdgeCountListener(BrickletHallEffect.EdgeCountListener listener)
Removes a EdgeCount listener.void
setEdgeCountCallbackPeriod(long period)
Sets the period with which theBrickletHallEffect.EdgeCountListener
listener is triggered periodically.void
setEdgeCountConfig(short edgeType, short debounce)
The edge type parameter configures if rising edges, falling edges or both are counted.void
setEdgeInterrupt(long edges)
Sets the number of edges until an interrupt is invoked.-
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_VALUE
public static final byte FUNCTION_GET_VALUE
- See Also:
- Constant Field Values
-
FUNCTION_GET_EDGE_COUNT
public static final byte FUNCTION_GET_EDGE_COUNT
- See Also:
- Constant Field Values
-
FUNCTION_SET_EDGE_COUNT_CONFIG
public static final byte FUNCTION_SET_EDGE_COUNT_CONFIG
- See Also:
- Constant Field Values
-
FUNCTION_GET_EDGE_COUNT_CONFIG
public static final byte FUNCTION_GET_EDGE_COUNT_CONFIG
- See Also:
- Constant Field Values
-
FUNCTION_SET_EDGE_INTERRUPT
public static final byte FUNCTION_SET_EDGE_INTERRUPT
- See Also:
- Constant Field Values
-
FUNCTION_GET_EDGE_INTERRUPT
public static final byte FUNCTION_GET_EDGE_INTERRUPT
- See Also:
- Constant Field Values
-
FUNCTION_SET_EDGE_COUNT_CALLBACK_PERIOD
public static final byte FUNCTION_SET_EDGE_COUNT_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_EDGE_COUNT_CALLBACK_PERIOD
public static final byte FUNCTION_GET_EDGE_COUNT_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_EDGE_INTERRUPT
public static final byte FUNCTION_EDGE_INTERRUPT
- See Also:
- Constant Field Values
-
FUNCTION_GET_IDENTITY
public static final byte FUNCTION_GET_IDENTITY
- See Also:
- Constant Field Values
-
EDGE_TYPE_RISING
public static final short EDGE_TYPE_RISING
- See Also:
- Constant Field Values
-
EDGE_TYPE_FALLING
public static final short EDGE_TYPE_FALLING
- See Also:
- Constant Field Values
-
EDGE_TYPE_BOTH
public static final short EDGE_TYPE_BOTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletHallEffect
public BrickletHallEffect(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
-
getValue
public boolean getValue() throws TinkerforgeException
Returns *true* if a magnetic field of 3.5 millitesla or greater is detected.- Throws:
TinkerforgeException
-
getEdgeCount
public long getEdgeCount(boolean resetCounter) throws TinkerforgeException
Returns the current value of the edge counter. You can configure edge type (rising, falling, both) that is counted withsetEdgeCountConfig(short, short)
. If you set the reset counter to *true*, the count is set back to 0 directly after it is read.- Throws:
TinkerforgeException
-
setEdgeCountConfig
public void setEdgeCountConfig(short edgeType, short debounce) throws TinkerforgeException
The edge type parameter configures if rising edges, falling edges or both are counted. Possible edge types are: * 0 = rising * 1 = falling * 2 = both A magnetic field of 3.5 millitesla or greater causes a falling edge and a magnetic field of 2.5 millitesla or smaller causes a rising edge. If a magnet comes near the Bricklet the signal goes low (falling edge), if a magnet is removed from the vicinity the signal goes high (rising edge). Configuring an edge counter resets its value to 0. If you don't know what any of this means, just leave it at default. The default configuration is very likely OK for you.- Throws:
TinkerforgeException
-
getEdgeCountConfig
public BrickletHallEffect.EdgeCountConfig getEdgeCountConfig() throws TinkerforgeException
Returns the edge type and debounce time as set bysetEdgeCountConfig(short, short)
.- Throws:
TinkerforgeException
-
setEdgeInterrupt
public void setEdgeInterrupt(long edges) throws TinkerforgeException
Sets the number of edges until an interrupt is invoked. If *edges* is set to n, an interrupt is invoked for every n-th detected edge. If *edges* is set to 0, the interrupt is disabled.- Throws:
TinkerforgeException
-
getEdgeInterrupt
public long getEdgeInterrupt() throws TinkerforgeException
Returns the edges as set bysetEdgeInterrupt(long)
.- Throws:
TinkerforgeException
-
setEdgeCountCallbackPeriod
public void setEdgeCountCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletHallEffect.EdgeCountListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletHallEffect.EdgeCountListener
listener is only triggered if the edge count has changed since the last triggering.- Throws:
TinkerforgeException
-
getEdgeCountCallbackPeriod
public long getEdgeCountCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetEdgeCountCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
edgeInterrupt
public BrickletHallEffect.EdgeInterrupt edgeInterrupt() throws TinkerforgeException
This listener is triggered every n-th count, as configured withsetEdgeInterrupt(long)
. The parameters are the current count and the current value (seegetValue()
andgetEdgeCount(boolean)
).- 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
-
addEdgeCountListener
public void addEdgeCountListener(BrickletHallEffect.EdgeCountListener listener)
Adds a EdgeCount listener.
-
removeEdgeCountListener
public void removeEdgeCountListener(BrickletHallEffect.EdgeCountListener listener)
Removes a EdgeCount listener.
-
-