Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_button

Driver for generic button. More...

Data Structures

struct  bc_button_driver_t
 Button driver interface. More...
 

Typedefs

typedef struct bc_button_t bc_button_t
 Button instance.
 

Enumerations

enum  bc_button_event_t {
  BC_BUTTON_EVENT_PRESS = 0,
  BC_BUTTON_EVENT_RELEASE = 1,
  BC_BUTTON_EVENT_CLICK = 2,
  BC_BUTTON_EVENT_HOLD = 3
}
 Callback events. More...
 

Functions

void bc_button_init (bc_button_t *self, bc_gpio_channel_t gpio_channel, bc_gpio_pull_t gpio_pull, int idle_state)
 Initialize button. More...
 
void bc_button_init_virtual (bc_button_t *self, int channel, const bc_button_driver_t *driver, int idle_state)
 Initialize virtual button. More...
 
void bc_button_set_event_handler (bc_button_t *self, void(*event_handler)(bc_button_t *, bc_button_event_t, void *), void *event_param)
 Set callback function. More...
 
void bc_button_set_scan_interval (bc_button_t *self, bc_tick_t scan_interval)
 Set scan interval (period of button input sampling) More...
 
void bc_button_set_debounce_time (bc_button_t *self, bc_tick_t debounce_time)
 Set debounce time (minimum sampling interval during which input cannot change to toggle its state) More...
 
void bc_button_set_click_timeout (bc_button_t *self, bc_tick_t click_timeout)
 Set click timeout (maximum interval within which button has to be released to recognize click event) More...
 
void bc_button_set_hold_time (bc_button_t *self, bc_tick_t hold_time)
 Set hold time (interval after which hold event is recognized when button is steadily pressed) More...
 

Detailed Description

Driver for generic button.

Enumeration Type Documentation

Callback events.

Enumerator
BC_BUTTON_EVENT_PRESS 

Event button pressed.

BC_BUTTON_EVENT_RELEASE 

Event button released.

BC_BUTTON_EVENT_CLICK 

Event button clicked (pressed and released within certain time)

BC_BUTTON_EVENT_HOLD 

Event button hold (pressed for longer time)

Definition at line 14 of file bc_button.h.

Function Documentation

void bc_button_init ( bc_button_t self,
bc_gpio_channel_t  gpio_channel,
bc_gpio_pull_t  gpio_pull,
int  idle_state 
)

Initialize button.

Parameters
[in]selfInstance
[in]gpio_channelGPIO channel button is connected to
[in]gpio_pullGPIO pull-up/pull-down setting
[in]idle_stateGPIO pin idle state (when button is not pressed)

Definition at line 20 of file bc_button.c.

Referenced by bc_module_encoder_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void bc_button_init_virtual ( bc_button_t self,
int  channel,
const bc_button_driver_t driver,
int  idle_state 
)

Initialize virtual button.

Parameters
[in]selfInstance
[in]channelVirtual channel button is connected to
[in]driverVirtual channel button driver
[in]idle_stateVirtual pin idle state (when button is not pressed)

Definition at line 43 of file bc_button.c.

Referenced by bc_module_lcd_set_event_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

void bc_button_set_click_timeout ( bc_button_t self,
bc_tick_t  click_timeout 
)

Set click timeout (maximum interval within which button has to be released to recognize click event)

Parameters
[in]selfInstance
[in]click_timeoutDesired click timeout in ticks

Definition at line 93 of file bc_button.c.

Referenced by bc_module_lcd_set_button_click_timeout().

Here is the caller graph for this function:

void bc_button_set_debounce_time ( bc_button_t self,
bc_tick_t  debounce_time 
)

Set debounce time (minimum sampling interval during which input cannot change to toggle its state)

Parameters
[in]selfInstance
[in]debounce_timeDesired debounce time in ticks

Definition at line 88 of file bc_button.c.

Referenced by bc_module_lcd_set_button_debounce_time().

Here is the caller graph for this function:

void bc_button_set_event_handler ( bc_button_t self,
void(*)(bc_button_t *, bc_button_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]selfInstance
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 66 of file bc_button.c.

Referenced by bc_module_encoder_init(), and bc_module_lcd_set_event_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

void bc_button_set_hold_time ( bc_button_t self,
bc_tick_t  hold_time 
)

Set hold time (interval after which hold event is recognized when button is steadily pressed)

Parameters
[in]selfInstance
[in]hold_timeDesired hold time in ticks

Definition at line 98 of file bc_button.c.

Referenced by bc_module_lcd_set_button_hold_time().

Here is the caller graph for this function:

void bc_button_set_scan_interval ( bc_button_t self,
bc_tick_t  scan_interval 
)

Set scan interval (period of button input sampling)

Parameters
[in]selfInstance
[in]scan_intervalDesired scan interval in ticks

Definition at line 83 of file bc_button.c.

Referenced by bc_module_lcd_set_button_scan_interval().

Here is the caller graph for this function: