mbed HRM11017を使ってkonashi.jsでナイトライダー

Dependencies:   BLE_API_Native_IRC mbed

Fork of BLE_RCBController by Junichi Katsu

Embed: (wiki syntax)

« Back to documentation index

Button Handler

Button Handler

Buttons handling module. More...

Data Structures

struct  app_button_cfg_t
 Button configuration structure. More...

Typedefs

typedef void(* app_button_handler_t )(uint8_t pin_no)
 Button event handler type.
typedef uint32_t(* app_button_evt_schedule_func_t )(app_button_handler_t button_handler, uint8_t pin_no)
 Type of function for passing events from the Button Handler module to the scheduler.

Functions

uint32_t app_button_init (app_button_cfg_t *p_buttons, uint8_t button_count, uint32_t detection_delay, app_button_evt_schedule_func_t evt_schedule_func)
 Function for initializing the Buttons.
uint32_t app_button_enable (void)
 Function for enabling button detection.
uint32_t app_button_disable (void)
 Function for disabling button detection.
uint32_t app_button_is_pushed (uint8_t pin_no, bool *p_is_pushed)
 Function for checking if a button is currently being pushed.

Detailed Description

Buttons handling module.

The button handler uses the GPIOTE Handler to detect that a button has been pushed. To handle debouncing, it will start a timer in the GPIOTE event handler. The button will only be reported as pushed if the corresponding pin is still active when the timer expires. If there is a new GPIOTE event while the timer is running, the timer is restarted. Use the USE_SCHEDULER parameter of the APP_BUTTON_INIT() macro to select if the Scheduler is to be used or not.

Note:
The app_button module uses the app_timer module. The user must ensure that the queue in app_timer is large enough to hold the app_timer_stop() / app_timer_start() operations which will be executed on each event from GPIOTE module (2 operations), as well as other app_timer operations queued simultaneously in the application.
Even if the scheduler is not used, app_button.h will include app_scheduler.h, so when compiling, app_scheduler.h must be available in one of the compiler include paths.

Typedef Documentation

typedef uint32_t(* app_button_evt_schedule_func_t)(app_button_handler_t button_handler, uint8_t pin_no)

Type of function for passing events from the Button Handler module to the scheduler.

Definition at line 55 of file app_button.h.

typedef void(* app_button_handler_t)(uint8_t pin_no)

Button event handler type.

Definition at line 52 of file app_button.h.


Function Documentation

uint32_t app_button_disable ( void   )

Function for disabling button detection.

Return values:
NRF_ERROR_INVALID_PARAMGPIOTE has to many users.
NRF_ERROR_INVALID_STATEButton or GPIOTE not initialized.
NRF_SUCCESSButton detection successfully enabled.
uint32_t app_button_enable ( void   )

Function for enabling button detection.

Return values:
NRF_ERROR_INVALID_PARAMGPIOTE has to many users.
NRF_ERROR_INVALID_STATEButton or GPIOTE not initialized.
NRF_SUCCESSButton detection successfully enabled.
uint32_t app_button_init ( app_button_cfg_t p_buttons,
uint8_t  button_count,
uint32_t  detection_delay,
app_button_evt_schedule_func_t  evt_schedule_func 
)

Function for initializing the Buttons.

This function will initialize the specified pins as buttons, and configure the Button Handler module as a GPIOTE user (but it will not enable button detection).

Note:
Normally initialization should be done using the APP_BUTTON_INIT() macro, as that will take care of connecting the Buttons module to the scheduler (if specified).
app_button_enable() function must be called in order to enable the button detection.
Parameters:
[in]p_buttonsArray of buttons to be used (NOTE: Must be static!).
[in]button_countNumber of buttons.
[in]detection_delayDelay from a GPIOTE event until a button is reported as pushed.
[in]evt_schedule_funcFunction for passing button events to the scheduler. Point to app_button_evt_schedule() to connect to the scheduler. Set to NULL to make the Buttons module call the event handler directly from the delayed button push detection timeout handler.
Returns:
NRF_SUCCESS on success, otherwise an error code.
uint32_t app_button_is_pushed ( uint8_t  pin_no,
bool *  p_is_pushed 
)

Function for checking if a button is currently being pushed.

Parameters:
[in]pin_noButton pin to be checked.
[out]p_is_pushedButton state.
Return values:
NRF_SUCCESSState successfully read.
NRF_ERROR_INVALID_PARAMInvalid pin_no.