Package com.tinkerforge
Class BrickletTilt
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletTilt
-
public class BrickletTilt extends Device
Detects inclination of Bricklet (tilt switch open/closed)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BrickletTilt.TiltStateListener
This listener provides the current tilt state.-
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_DISABLE_TILT_STATE_CALLBACK
static byte
FUNCTION_ENABLE_TILT_STATE_CALLBACK
static byte
FUNCTION_GET_IDENTITY
static byte
FUNCTION_GET_TILT_STATE
static byte
FUNCTION_IS_TILT_STATE_CALLBACK_ENABLED
static short
TILT_STATE_CLOSED
static short
TILT_STATE_CLOSED_VIBRATING
static short
TILT_STATE_OPEN
-
Constructor Summary
Constructors Constructor Description BrickletTilt(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
addTiltStateListener(BrickletTilt.TiltStateListener listener)
Adds a TiltState listener.void
disableTiltStateCallback()
Disables theBrickletTilt.TiltStateListener
listener.void
enableTiltStateCallback()
Enables theBrickletTilt.TiltStateListener
listener.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
getTiltState()
Returns the current tilt state.boolean
isTiltStateCallbackEnabled()
Returns *true* if theBrickletTilt.TiltStateListener
listener is enabled.void
removeTiltStateListener(BrickletTilt.TiltStateListener listener)
Removes a TiltState 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_TILT_STATE
public static final byte FUNCTION_GET_TILT_STATE
- See Also:
- Constant Field Values
-
FUNCTION_ENABLE_TILT_STATE_CALLBACK
public static final byte FUNCTION_ENABLE_TILT_STATE_CALLBACK
- See Also:
- Constant Field Values
-
FUNCTION_DISABLE_TILT_STATE_CALLBACK
public static final byte FUNCTION_DISABLE_TILT_STATE_CALLBACK
- See Also:
- Constant Field Values
-
FUNCTION_IS_TILT_STATE_CALLBACK_ENABLED
public static final byte FUNCTION_IS_TILT_STATE_CALLBACK_ENABLED
- See Also:
- Constant Field Values
-
FUNCTION_GET_IDENTITY
public static final byte FUNCTION_GET_IDENTITY
- See Also:
- Constant Field Values
-
TILT_STATE_CLOSED
public static final short TILT_STATE_CLOSED
- See Also:
- Constant Field Values
-
TILT_STATE_OPEN
public static final short TILT_STATE_OPEN
- See Also:
- Constant Field Values
-
TILT_STATE_CLOSED_VIBRATING
public static final short TILT_STATE_CLOSED_VIBRATING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletTilt
public BrickletTilt(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
-
getTiltState
public short getTiltState() throws TinkerforgeException
Returns the current tilt state. The state can either be * 0 = Closed: The ball in the tilt switch closes the circuit. * 1 = Open: The ball in the tilt switch does not close the circuit. * 2 = Closed Vibrating: The tilt switch is in motion (rapid change between open and close). .. image:: /Images/Bricklets/bricklet_tilt_mechanics.jpg :scale: 100 % :alt: Tilt states :align: center :target: ../../_images/Bricklets/bricklet_tilt_mechanics.jpg- Throws:
TinkerforgeException
-
enableTiltStateCallback
public void enableTiltStateCallback() throws TinkerforgeException
Enables theBrickletTilt.TiltStateListener
listener.- Throws:
TinkerforgeException
-
disableTiltStateCallback
public void disableTiltStateCallback() throws TinkerforgeException
Disables theBrickletTilt.TiltStateListener
listener.- Throws:
TinkerforgeException
-
isTiltStateCallbackEnabled
public boolean isTiltStateCallbackEnabled() throws TinkerforgeException
Returns *true* if theBrickletTilt.TiltStateListener
listener is enabled.- 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
-
addTiltStateListener
public void addTiltStateListener(BrickletTilt.TiltStateListener listener)
Adds a TiltState listener.
-
removeTiltStateListener
public void removeTiltStateListener(BrickletTilt.TiltStateListener listener)
Removes a TiltState listener.
-
-