Defines | |
#define | DUAL_BUTTON_BUTTON_STATE_PRESSED 0 |
#define | DUAL_BUTTON_BUTTON_STATE_RELEASED 1 |
#define | DUAL_BUTTON_CALLBACK_STATE_CHANGED 4 |
#define | DUAL_BUTTON_DEVICE_IDENTIFIER 230 |
#define | DUAL_BUTTON_FUNCTION_GET_BUTTON_STATE 3 |
#define | DUAL_BUTTON_FUNCTION_GET_IDENTITY 255 |
#define | DUAL_BUTTON_FUNCTION_GET_LED_STATE 2 |
#define | DUAL_BUTTON_FUNCTION_SET_LED_STATE 1 |
#define | DUAL_BUTTON_FUNCTION_SET_SELECTED_LED_STATE 5 |
#define | DUAL_BUTTON_LED_LEFT 0 |
#define | DUAL_BUTTON_LED_RIGHT 1 |
#define | DUAL_BUTTON_LED_STATE_AUTO_TOGGLE_OFF 1 |
#define | DUAL_BUTTON_LED_STATE_AUTO_TOGGLE_ON 0 |
#define | DUAL_BUTTON_LED_STATE_OFF 3 |
#define | DUAL_BUTTON_LED_STATE_ON 2 |
Typedefs | |
typedef Device | DualButton |
Functions | |
void | dual_button_create (DualButton *dual_button, const char *uid, IPConnection *ipcon) |
void | dual_button_destroy (DualButton *dual_button) |
int | dual_button_get_api_version (DualButton *dual_button, uint8_t ret_api_version[3]) |
int | dual_button_get_button_state (DualButton *dual_button, uint8_t *ret_button_l, uint8_t *ret_button_r) |
int | dual_button_get_identity (DualButton *dual_button, char ret_uid[8], char ret_connected_uid[8], char *ret_position, uint8_t ret_hardware_version[3], uint8_t ret_firmware_version[3], uint16_t *ret_device_identifier) |
int | dual_button_get_led_state (DualButton *dual_button, uint8_t *ret_led_l, uint8_t *ret_led_r) |
int | dual_button_get_response_expected (DualButton *dual_button, uint8_t function_id, bool *ret_response_expected) |
void | dual_button_register_callback (DualButton *dual_button, uint8_t id, void *callback, void *user_data) |
int | dual_button_set_led_state (DualButton *dual_button, uint8_t led_l, uint8_t led_r) |
int | dual_button_set_response_expected (DualButton *dual_button, uint8_t function_id, bool response_expected) |
int | dual_button_set_response_expected_all (DualButton *dual_button, bool response_expected) |
int | dual_button_set_selected_led_state (DualButton *dual_button, uint8_t led, uint8_t state) |
#define DUAL_BUTTON_BUTTON_STATE_PRESSED 0 |
Definition at line 101 of file bricklet_dual_button.h.
#define DUAL_BUTTON_BUTTON_STATE_RELEASED 1 |
Definition at line 106 of file bricklet_dual_button.h.
#define DUAL_BUTTON_CALLBACK_STATE_CHANGED 4 |
Signature:
void callback(uint8_t button_l, uint8_t button_r, uint8_t led_l, uint8_t led_r, void *user_data)
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).
Definition at line 75 of file bricklet_dual_button.h.
#define DUAL_BUTTON_DEVICE_IDENTIFIER 230 |
This constant is used to identify a DualButton Bricklet.
The dual_button_get_identity function and the IPCON_CALLBACK_ENUMERATE callback of the IP Connection have a device_identifier
parameter to specify the Brick's or Bricklet's type.
Definition at line 127 of file bricklet_dual_button.h.
#define DUAL_BUTTON_FUNCTION_GET_BUTTON_STATE 3 |
Definition at line 44 of file bricklet_dual_button.h.
#define DUAL_BUTTON_FUNCTION_GET_IDENTITY 255 |
Definition at line 54 of file bricklet_dual_button.h.
#define DUAL_BUTTON_FUNCTION_GET_LED_STATE 2 |
Definition at line 39 of file bricklet_dual_button.h.
#define DUAL_BUTTON_FUNCTION_SET_LED_STATE 1 |
Definition at line 34 of file bricklet_dual_button.h.
Definition at line 49 of file bricklet_dual_button.h.
#define DUAL_BUTTON_LED_LEFT 0 |
Definition at line 111 of file bricklet_dual_button.h.
#define DUAL_BUTTON_LED_RIGHT 1 |
Definition at line 116 of file bricklet_dual_button.h.
#define DUAL_BUTTON_LED_STATE_AUTO_TOGGLE_OFF 1 |
Definition at line 86 of file bricklet_dual_button.h.
#define DUAL_BUTTON_LED_STATE_AUTO_TOGGLE_ON 0 |
Definition at line 81 of file bricklet_dual_button.h.
#define DUAL_BUTTON_LED_STATE_OFF 3 |
Definition at line 96 of file bricklet_dual_button.h.
#define DUAL_BUTTON_LED_STATE_ON 2 |
Definition at line 91 of file bricklet_dual_button.h.
typedef Device DualButton |
Device with two buttons and two LEDs
Definition at line 29 of file bricklet_dual_button.h.
void dual_button_create | ( | DualButton * | dual_button, |
const char * | uid, | ||
IPConnection * | ipcon | ||
) |
Creates the device object dual_button
with the unique device ID uid
and adds it to the IPConnection ipcon
.
Definition at line 114 of file bricklet_dual_button.c.
void dual_button_destroy | ( | DualButton * | dual_button | ) |
Removes the device object dual_button
from its IPConnection and destroys it. The device object cannot be used anymore afterwards.
Definition at line 131 of file bricklet_dual_button.c.
int dual_button_get_api_version | ( | DualButton * | dual_button, |
uint8_t | ret_api_version[3] | ||
) |
Returns the API version (major, minor, release) of the bindings for this device.
Definition at line 151 of file bricklet_dual_button.c.
int dual_button_get_button_state | ( | DualButton * | dual_button, |
uint8_t * | ret_button_l, | ||
uint8_t * | ret_button_r | ||
) |
Returns the current state for both buttons. Possible states are:
* 0 = pressed * 1 = released
Definition at line 201 of file bricklet_dual_button.c.
int dual_button_get_identity | ( | DualButton * | dual_button, |
char | ret_uid[8], | ||
char | ret_connected_uid[8], | ||
char * | ret_position, | ||
uint8_t | ret_hardware_version[3], | ||
uint8_t | ret_firmware_version[3], | ||
uint16_t * | ret_device_identifier | ||
) |
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' or 'd'.
The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|
Definition at line 247 of file bricklet_dual_button.c.
int dual_button_get_led_state | ( | DualButton * | dual_button, |
uint8_t * | ret_led_l, | ||
uint8_t * | ret_led_r | ||
) |
Returns the current state of the LEDs, as set by dual_button_set_led_state.
Definition at line 175 of file bricklet_dual_button.c.
int dual_button_get_response_expected | ( | DualButton * | dual_button, |
uint8_t | function_id, | ||
bool * | ret_response_expected | ||
) |
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 via the dual_button_set_response_expected function. 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 send and errors are silently ignored, because they cannot be detected.
Definition at line 135 of file bricklet_dual_button.c.
void dual_button_register_callback | ( | DualButton * | dual_button, |
uint8_t | id, | ||
void * | callback, | ||
void * | user_data | ||
) |
Registers a callback with ID id
to the function callback
. The user_data
will be given as a parameter of the callback.
Definition at line 147 of file bricklet_dual_button.c.
int dual_button_set_led_state | ( | DualButton * | dual_button, |
uint8_t | led_l, | ||
uint8_t | led_r | ||
) |
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 dual_button_get_led_state or you can use dual_button_set_selected_led_state.
The default value is (1, 1).
Definition at line 155 of file bricklet_dual_button.c.
int dual_button_set_response_expected | ( | DualButton * | dual_button, |
uint8_t | function_id, | ||
bool | response_expected | ||
) |
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 and callbacks it is always disabled.
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 send and errors are silently ignored, because they cannot be detected.
Definition at line 139 of file bricklet_dual_button.c.
int dual_button_set_response_expected_all | ( | DualButton * | dual_button, |
bool | response_expected | ||
) |
Changes the response expected flag for all setter and callback configuration functions of this device at once.
Definition at line 143 of file bricklet_dual_button.c.
int dual_button_set_selected_led_state | ( | DualButton * | dual_button, |
uint8_t | led, | ||
uint8_t | state | ||
) |
Sets the state of the selected LED (0 or 1).
The other LED remains untouched.
Definition at line 227 of file bricklet_dual_button.c.