Button

Button Utility. More...

Modules

Types
Button data types.
 

Functions

zos_result_t button_init (zos_gpio_t gpio, const button_config_t *config, void *arg)
 Initialize GPIO as a button. More...
 
void button_deinit (zos_gpio_t gpio)
 De-initialize button feature for given GPIO. More...
 
zos_bool_t button_is_active (zos_gpio_t gpio)
 Returns if a button is considered active passed on its configuration. More...
 
zos_result_t button_update_config (zos_gpio_t gpio, const button_config_t *config)
 Update a button's configuration. More...
 

Detailed Description

Button Utility.

Function Documentation

void button_deinit ( zos_gpio_t  gpio)

De-initialize button feature for given GPIO.

Parameters
gpioGPIO to deinitialized as button
Examples:
basic/button/button.c, cloud/s2cbasic/platform_streams.c, cloud/s2cdemo/zentri_platform_streams.c, cloud/simplemq/main.c, and demo/pong/main.c.
zos_result_t button_init ( zos_gpio_t  gpio,
const button_config_t config,
void *  arg 
)

Initialize GPIO as a button.

This configures a GPIO as button. This includes the necessary functionality to debounce the button and execute handlers based on the specified configuration.

Parameters
gpioGPIO to configure as a button
configButton configuration
argOptional argument to pass to event handlers
Returns
zos_result_t result of api call
Examples:
basic/button/button.c, cloud/s2cbasic/platform_streams.c, cloud/s2cdemo/zentri_platform_streams.c, cloud/simplemq/main.c, and demo/pong/main.c.
zos_bool_t button_is_active ( zos_gpio_t  gpio)

Returns if a button is considered active passed on its configuration.

Parameters
gpioGPIO to test
Returns
ZOS_TRUE if button is active, FALSE else
Examples:
cloud/s2cbasic/platform_streams.c, cloud/s2cdemo/zentri_platform_streams.c, and demo/pong/game.c.
zos_result_t button_update_config ( zos_gpio_t  gpio,
const button_config_t config 
)

Update a button's configuration.

This updates a button configuration including the:

  • debounce time
  • click_time
  • press_time

All other settings are ignored.

Parameters
gpioGPIO of corresponding button
configUpdated configuration
Returns
zos_result_t result of api call
Examples:
demo/pong/game.c.