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, BUTTON_RES_INVALID_PARAM = 2, BUTTON_RES_UNINITIALIZED = 3 }
 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 48 of file button.h.

Function Documentation

◆ Button_get_number()

uint8_t Button_get_number ( void  )

Get number of buttons.

◆ 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  )

Initialize Button module.

◆ 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
scheduler/app.c.

Enumeration Type Documentation

◆ button_event_e

Different events for a button.

Enumerator
BUTTON_PRESSED 
BUTTON_RELEASED 

Definition at line 21 of file button.h.

21  {

◆ button_res_e

List of return code.

Enumerator
BUTTON_RES_OK 

Operation is successful

BUTTON_RES_INVALID_ID 

Button id is invalid

BUTTON_RES_INVALID_PARAM 

Function parameter is invalid

BUTTON_RES_UNINITIALIZED 

Button initialization has not been performed

Definition at line 29 of file button.h.

BUTTON_RES_INVALID_ID
@ BUTTON_RES_INVALID_ID
Definition: button.h:34
BUTTON_RES_OK
@ BUTTON_RES_OK
Definition: button.h:32
BUTTON_RES_INVALID_PARAM
@ BUTTON_RES_INVALID_PARAM
Definition: button.h:36
button_res_e
button_res_e
List of return code.
Definition: button.h:29
BUTTON_RELEASED
@ BUTTON_RELEASED
Definition: button.h:23
BUTTON_PRESSED
@ BUTTON_PRESSED
Definition: button.h:22
BUTTON_RES_UNINITIALIZED
@ BUTTON_RES_UNINITIALIZED
Definition: button.h:38
button_event_e
button_event_e
Different events for a button.
Definition: button.h:21