Documentation ¶
Overview ¶
Two tactile buttons with built-in blue LEDs.
See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricklets/DualButton_Bricklet_Go.html.
Index ¶
- Constants
- type ButtonState
- type DualButtonBricklet
- func (device *DualButtonBricklet) DeregisterStateChangedCallback(registrationId uint64)
- func (device *DualButtonBricklet) GetAPIVersion() [3]uint8
- func (device *DualButtonBricklet) GetButtonState() (buttonL ButtonState, buttonR ButtonState, err error)
- func (device *DualButtonBricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, ...)
- func (device *DualButtonBricklet) GetLEDState() (ledL LEDState, ledR LEDState, err error)
- func (device *DualButtonBricklet) GetResponseExpected(functionID Function) (bool, error)
- func (device *DualButtonBricklet) RegisterStateChangedCallback(fn func(ButtonState, ButtonState, LEDState, LEDState)) uint64
- func (device *DualButtonBricklet) SetLEDState(ledL LEDState, ledR LEDState) (err error)
- func (device *DualButtonBricklet) SetResponseExpected(functionID Function, responseExpected bool) error
- func (device *DualButtonBricklet) SetResponseExpectedAll(responseExpected bool)
- func (device *DualButtonBricklet) SetSelectedLEDState(led LED, state LEDState) (err error)
- type Function
- type LED
- type LEDState
Constants ¶
const DeviceDisplayName = "Dual Button Bricklet"
const DeviceIdentifier = 230
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ButtonState ¶
type ButtonState = uint8
const ( ButtonStatePressed ButtonState = 0 ButtonStateReleased ButtonState = 1 )
type DualButtonBricklet ¶
type DualButtonBricklet struct {
// contains filtered or unexported fields
}
func New ¶
func New(uid string, ipcon *ipconnection.IPConnection) (DualButtonBricklet, error)
Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ipcon` is connected.
func (*DualButtonBricklet) DeregisterStateChangedCallback ¶
func (device *DualButtonBricklet) DeregisterStateChangedCallback(registrationId uint64)
Remove a registered State Changed callback.
func (*DualButtonBricklet) GetAPIVersion ¶
func (device *DualButtonBricklet) GetAPIVersion() [3]uint8
Returns the version of the API definition (major, minor, revision) implemented by this API bindings. This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
func (*DualButtonBricklet) GetButtonState ¶
func (device *DualButtonBricklet) GetButtonState() (buttonL ButtonState, buttonR ButtonState, err error)
Returns the current state for both buttons. Possible states are:
* 0 = pressed * 1 = released
Associated constants:
- ButtonStatePressed
- ButtonStateReleased
func (*DualButtonBricklet) GetIdentity ¶
func (device *DualButtonBricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, firmwareVersion [3]uint8, deviceIdentifier uint16, err error)
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 `Isolator Bricklet <isolator_bricklet>` is always at position 'z'.
The device identifier numbers can be found `here <device_identifier>`. |device_identifier_constant|
func (*DualButtonBricklet) GetLEDState ¶
func (device *DualButtonBricklet) GetLEDState() (ledL LEDState, ledR LEDState, err error)
Returns the current state of the LEDs, as set by SetLEDState.
Associated constants:
- LEDStateAutoToggleOn
- LEDStateAutoToggleOff
- LEDStateOn
- LEDStateOff
func (*DualButtonBricklet) GetResponseExpected ¶
func (device *DualButtonBricklet) GetResponseExpected(functionID Function) (bool, error)
Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.
For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by SetResponseExpected. For setter functions it is disabled by default and can be enabled.
Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.
See SetResponseExpected for the list of function ID constants available for this function.
func (*DualButtonBricklet) RegisterStateChangedCallback ¶
func (device *DualButtonBricklet) RegisterStateChangedCallback(fn func(ButtonState, ButtonState, LEDState, LEDState)) uint64
This callback is called whenever a button is pressed.
Possible states for buttons are:
* 0 = pressed * 1 = released
Possible states for LEDs are:
* 0 = AutoToggleOn: Auto toggle enabled and LED on. * 1 = AutoToggleOff: Auto toggle enabled and LED off. * 2 = On: LED on (auto toggle is disabled). * 3 = Off: LED off (auto toggle is disabled).
func (*DualButtonBricklet) SetLEDState ¶
func (device *DualButtonBricklet) SetLEDState(ledL LEDState, ledR LEDState) (err error)
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 with GetLEDState or you can use SetSelectedLEDState.
Associated constants:
- LEDStateAutoToggleOn
- LEDStateAutoToggleOff
- LEDStateOn
- LEDStateOff
func (*DualButtonBricklet) SetResponseExpected ¶
func (device *DualButtonBricklet) SetResponseExpected(functionID Function, responseExpected bool) error
Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.
Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.
func (*DualButtonBricklet) SetResponseExpectedAll ¶
func (device *DualButtonBricklet) SetResponseExpectedAll(responseExpected bool)
Changes the response expected flag for all setter and callback configuration functions of this device at once.
func (*DualButtonBricklet) SetSelectedLEDState ¶
func (device *DualButtonBricklet) SetSelectedLEDState(led LED, state LEDState) (err error)
Sets the state of the selected LED (0 or 1).
The other LED remains untouched.
Associated constants:
- LEDLeft
- LEDRight
- LEDStateAutoToggleOn
- LEDStateAutoToggleOff
- LEDStateOn
- LEDStateOff