Wirepas SDK
button.h File Reference

Board-independent button functions. More...

Detailed Description

Board-independent button functions.

Definition in file button.h.

Go to the source code of this file.

Typedefs

typedef void(* on_button_event_cb) (uint8_t button_id, button_event_e event)
 Callback structure for a button event. More...
 

Functions

void Button_init (void)
 Initialize Button module. More...
 
button_res_e Button_register_for_event (uint8_t button_id, button_event_e event, on_button_event_cb cb)
 Register for a button event. More...
 
button_res_e Button_getState (uint8_t button_id, bool *state_p)
 Get State of a given button. More...
 
uint8_t Button_get_number (void)
 Get number of buttons. More...
 

Enumerations

enum  button_event_e { BUTTON_PRESSED, BUTTON_RELEASED }
 Different events for a button. More...
 
enum  button_res_e { BUTTON_RES_OK = 0, BUTTON_RES_INVALID_ID = 1 }
 List of return code. More...
 

Typedef Documentation

◆ on_button_event_cb

typedef void(* on_button_event_cb) (uint8_t button_id, button_event_e event)

Callback structure for a button event.

Parameters
button_idId of the button that is pressed
eventEvent that generated this callback

Definition at line 40 of file button.h.

Function Documentation

◆ Button_get_number()

uint8_t Button_get_number ( void  )

Get number of buttons.

Examples
blink/app.c.

◆ Button_getState()

button_res_e Button_getState ( uint8_t  button_id,
bool *  state_p 
)

Get State of a given button.

Parameters
button_idId of the button
state_pstate of the button, true for pressed Valid only if return code is BUTTON_RES_OK
Returns
Return code of operation

◆ Button_init()

void Button_init ( void  )

◆ Button_register_for_event()

button_res_e Button_register_for_event ( uint8_t  button_id,
button_event_e  event,
on_button_event_cb  cb 
)

Register for a button event.

Parameters
button_idId of the button
eventEvent to monitor
cbCallback to call when event happen
Returns
Return code of operation
Examples
blink/app.c, provisioning_joining_node/app.c, provisioning_proxy/app.c, and scheduler/app.c.

Enumeration Type Documentation

◆ button_event_e

Different events for a button.

Enumerator
BUTTON_PRESSED 
BUTTON_RELEASED 

Definition at line 17 of file button.h.

17  {

◆ button_res_e

List of return code.

Enumerator
BUTTON_RES_OK 

Operation is successful

BUTTON_RES_INVALID_ID 

Button id is invalid

Definition at line 25 of file button.h.

26 {
28  BUTTON_RES_OK = 0,
31 } button_res_e;
BUTTON_RES_INVALID_ID
@ BUTTON_RES_INVALID_ID
Definition: button.h:30
BUTTON_RES_OK
@ BUTTON_RES_OK
Definition: button.h:28
button_res_e
button_res_e
List of return code.
Definition: button.h:25
BUTTON_RELEASED
@ BUTTON_RELEASED
Definition: button.h:19
BUTTON_PRESSED
@ BUTTON_PRESSED
Definition: button.h:18
button_event_e
button_event_e
Different events for a button.
Definition: button.h:17