Package com.tinkerforge
Class BrickletDualButton
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletDualButton
-
public class BrickletDualButton extends Device
Two tactile buttons with built-in blue LEDs
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletDualButton.ButtonState
class
BrickletDualButton.LEDState
static interface
BrickletDualButton.StateChangedListener
This listener is called whenever a button is pressed.-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
Fields Modifier and Type Field Description static short
BUTTON_STATE_PRESSED
static short
BUTTON_STATE_RELEASED
static java.lang.String
DEVICE_DISPLAY_NAME
static int
DEVICE_IDENTIFIER
static byte
FUNCTION_GET_BUTTON_STATE
static byte
FUNCTION_GET_IDENTITY
static byte
FUNCTION_GET_LED_STATE
static byte
FUNCTION_SET_LED_STATE
static byte
FUNCTION_SET_SELECTED_LED_STATE
static short
LED_LEFT
static short
LED_RIGHT
static short
LED_STATE_AUTO_TOGGLE_OFF
static short
LED_STATE_AUTO_TOGGLE_ON
static short
LED_STATE_OFF
static short
LED_STATE_ON
-
Constructor Summary
Constructors Constructor Description BrickletDualButton(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
addStateChangedListener(BrickletDualButton.StateChangedListener listener)
Adds a StateChanged listener.BrickletDualButton.ButtonState
getButtonState()
Returns the current state for both buttons.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.BrickletDualButton.LEDState
getLEDState()
Returns the current state of the LEDs, as set bysetLEDState(short, short)
.void
removeStateChangedListener(BrickletDualButton.StateChangedListener listener)
Removes a StateChanged listener.void
setLEDState(short ledL, short ledR)
Sets the state of the LEDs.void
setSelectedLEDState(short led, short state)
Sets the state of the selected LED (0 or 1).-
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_SET_LED_STATE
public static final byte FUNCTION_SET_LED_STATE
- See Also:
- Constant Field Values
-
FUNCTION_GET_LED_STATE
public static final byte FUNCTION_GET_LED_STATE
- See Also:
- Constant Field Values
-
FUNCTION_GET_BUTTON_STATE
public static final byte FUNCTION_GET_BUTTON_STATE
- See Also:
- Constant Field Values
-
FUNCTION_SET_SELECTED_LED_STATE
public static final byte FUNCTION_SET_SELECTED_LED_STATE
- See Also:
- Constant Field Values
-
FUNCTION_GET_IDENTITY
public static final byte FUNCTION_GET_IDENTITY
- See Also:
- Constant Field Values
-
LED_STATE_AUTO_TOGGLE_ON
public static final short LED_STATE_AUTO_TOGGLE_ON
- See Also:
- Constant Field Values
-
LED_STATE_AUTO_TOGGLE_OFF
public static final short LED_STATE_AUTO_TOGGLE_OFF
- See Also:
- Constant Field Values
-
LED_STATE_ON
public static final short LED_STATE_ON
- See Also:
- Constant Field Values
-
LED_STATE_OFF
public static final short LED_STATE_OFF
- See Also:
- Constant Field Values
-
BUTTON_STATE_PRESSED
public static final short BUTTON_STATE_PRESSED
- See Also:
- Constant Field Values
-
BUTTON_STATE_RELEASED
public static final short BUTTON_STATE_RELEASED
- See Also:
- Constant Field Values
-
LED_LEFT
public static final short LED_LEFT
- See Also:
- Constant Field Values
-
LED_RIGHT
public static final short LED_RIGHT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletDualButton
public BrickletDualButton(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
-
setLEDState
public void setLEDState(short ledL, short ledR) throws TinkerforgeException
Sets the state of the LEDs. Possible states are: * 0 = AutoToggleOn: Enables auto toggle with initially enabled LED. * 1 = AutoToggleOff: Activates auto toggle with initially disabled LED. * 2 = On: Enables LED (auto toggle is disabled). * 3 = Off: Disables LED (auto toggle is disabled). In auto toggle mode the LED is toggled automatically at each press of a button. If you just want to set one of the LEDs and don't know the current state of the other LED, you can get the state withgetLEDState()
or you can usesetSelectedLEDState(short, short)
.- Throws:
TinkerforgeException
-
getLEDState
public BrickletDualButton.LEDState getLEDState() throws TinkerforgeException
Returns the current state of the LEDs, as set bysetLEDState(short, short)
.- Throws:
TinkerforgeException
-
getButtonState
public BrickletDualButton.ButtonState getButtonState() throws TinkerforgeException
Returns the current state for both buttons. Possible states are: * 0 = pressed * 1 = released- Throws:
TinkerforgeException
-
setSelectedLEDState
public void setSelectedLEDState(short led, short state) throws TinkerforgeException
Sets the state of the selected LED (0 or 1). The other LED remains untouched.- 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
-
addStateChangedListener
public void addStateChangedListener(BrickletDualButton.StateChangedListener listener)
Adds a StateChanged listener.
-
removeStateChangedListener
public void removeStateChangedListener(BrickletDualButton.StateChangedListener listener)
Removes a StateChanged listener.
-
-