PebbleOS v4.43.0-118-gb6c5f89a9
Loading...
Searching...
No Matches
GPIO keys

Keys on GPIOs, reported as Input key events. More...

Data Structures

struct  pbl_gpio_keys_key
 A key. More...
 
struct  pbl_gpio_keys
 Keys on GPIOs. More...
 

Macros

#define PBL_GPIO_KEYS_KEY(_label, _gpio, _code, _debounce_interval_ms)
 Initializer for a key.
 
#define PBL_GPIO_KEYS_DEFINE(sym, _name, ...)
 Define and register a set of keys.
 

Detailed Description

Keys on GPIOs, reported as Input key events.

Each edge of a key restarts its debounce timer; when the timer expires the key is read and, if it changed, reported. A key must therefore be stable for its debounce interval to be reported. Keys held at initialization are reported once their debounce interval has elapsed.

The configuration follows the devicetree gpio-keys binding, one key per child node:

PBL_GPIO_KEYS_DEFINE(BUTTONS, "buttons",
...);
#define NRF5_GPIO_P0
Port P0.
Definition nrf5.h:40
#define PBL_GPIO_ACTIVE_LOW
The pin is active when low.
Definition gpio.h:50
#define PBL_GPIO(_port, _pin, _flags)
Initializer for a struct pbl_gpio.
Definition gpio.h:148
#define PBL_GPIO_PULL_UP
Enable the pull-up.
Definition gpio.h:52
#define PBL_GPIO_KEYS_DEFINE(sym, _name,...)
Define and register a set of keys.
Definition gpio_keys.h:92
#define PBL_GPIO_KEYS_KEY(_label, _gpio, _code, _debounce_interval_ms)
Initializer for a key.
Definition gpio_keys.h:77
@ PBL_INPUT_KEY_BACK
Definition input.h:56

Data Structure Documentation

◆ pbl_gpio_keys_key

struct pbl_gpio_keys_key

A key.

Data Fields
uint16_t code PBL_INPUT_EV_KEY code, linux,code.
uint16_t debounce_interval_ms Time the key must be stable to be reported, in ms, debounce-interval.
struct pbl_gpio gpio GPIO, gpios; reads active while pressed.
const char * label Name, label.

◆ pbl_gpio_keys

struct pbl_gpio_keys

Keys on GPIOs.

Data Fields
struct pbl_device dev Device.
const struct pbl_gpio_keys_key * keys Keys.
uint8_t num_keys Number of keys.
struct pbl_gpio_keys_key_state * state Runtime state of each key.

Macro Definition Documentation

◆ PBL_GPIO_KEYS_DEFINE

#define PBL_GPIO_KEYS_DEFINE (   sym,
  _name,
  ... 
)
Value:
static const struct pbl_gpio_keys_key sym##_keys[] = {__VA_ARGS__}; \
static struct pbl_gpio_keys_key_state sym##_key_state[ARRAY_LENGTH(sym##_keys)]; \
PBL_DEVICE_STATE_DEFINE(sym); \
const struct pbl_gpio_keys sym = { \
.dev = PBL_DEVICE_INIT(sym, _name, pbl_gpio_keys_init, nullptr, nullptr), \
.keys = sym##_keys, \
.state = sym##_key_state, \
.num_keys = ARRAY_LENGTH(sym##_keys), \
}; \
PBL_DEVICE_REGISTER(sym, &sym.dev)
#define PBL_DEVICE_INIT(sym, _name, _init, _parent, _deps)
Initializer for the struct pbl_device of device instance sym.
Definition device.h:142
struct pbl_device dev
Device.
Definition gpio_keys.h:56
uint8_t num_keys
Number of keys.
Definition gpio_keys.h:62
A key.
Definition gpio_keys.h:34
Keys on GPIOs.
Definition gpio_keys.h:54
#define ARRAY_LENGTH(array)
Calculate the length of an array, based on the size of the element type.
Definition size.h:18

Define and register a set of keys.

Parameters
symSymbol of the struct pbl_gpio_keys.
_nameDevice name.
...Keys, each a PBL_GPIO_KEYS_KEY.

◆ PBL_GPIO_KEYS_KEY

#define PBL_GPIO_KEYS_KEY (   _label,
  _gpio,
  _code,
  _debounce_interval_ms 
)
Value:
{ \
.label = (_label), \
.gpio = _gpio, \
.code = (_code), \
.debounce_interval_ms = (_debounce_interval_ms), \
}

Initializer for a key.

Parameters
_labelName.
_gpioGPIO, a PBL_GPIO.
_codePBL_INPUT_EV_KEY code.
_debounce_interval_msDebounce interval in ms.