Input Key Service

[中文]

The input key service provides GPIO input interrupts and ADC key functions in the form of events. For what common key functions are defined by the events for audio products, see input_key_user_id_t.

Application Example

Implementation of this API is demonstrated in the following example:

Header File

Functions

periph_service_handle_t input_key_service_create(input_key_service_cfg_t *input_key_config)

Initialize and start the input key service.

Return

NULL failed others input key service handle

Parameters
  • input_key_config: Configuration of input key service

periph_service_state_t get_input_key_service_state(periph_service_handle_t input_handle)

Get the state of input key service.

Return

state of input key service

Parameters
  • input_handle: The handle of input key service

esp_err_t input_key_service_add_key(periph_service_handle_t input_key_handle, input_key_service_info_t *input_key_info, int add_key_num)

Add input key’s information to service list.

Return

ESP_OK success ESP_FAIL failed

Parameters
  • input_key_handle: handle of service

  • input_key_info: input key’s information

  • add_key_num: number of keys

Structures

struct input_key_service_info_t

input key’s infomation

Public Members

esp_periph_id_t type

ID of peripherals

int user_id

The key’s user id

int act_id

The key’s action id

struct input_key_service_cfg_t

input key’s configuration

Public Members

periph_service_config_t based_cfg

Peripheral service configuration

esp_periph_set_handle_t handle

Peripheral set handle

Macros

INPUT_KEY_SERVICE_TASK_STACK_SIZE
INPUT_KEY_SERVICE_TASK_PRIORITY
INPUT_KEY_SERVICE_TASK_ON_CORE
INPUT_KEY_SERVICE_DEFAULT_CONFIG()

Enumerations

enum input_key_service_action_id_t

input key action id

Values:

INPUT_KEY_SERVICE_ACTION_UNKNOWN = 0

unknown action id

INPUT_KEY_SERVICE_ACTION_CLICK

click action id

INPUT_KEY_SERVICE_ACTION_CLICK_RELEASE

click release action id

INPUT_KEY_SERVICE_ACTION_PRESS

long press action id

INPUT_KEY_SERVICE_ACTION_PRESS_RELEASE

long press release id

Header File

Enumerations

enum input_key_user_id_t

input key user user-defined id

Values:

INPUT_KEY_USER_ID_UNKNOWN = -1

unknown user id

INPUT_KEY_USER_ID_REC = 0x01

user id for recording

INPUT_KEY_USER_ID_SET = 0x02

user id for settings

INPUT_KEY_USER_ID_PLAY = 0x03

user id for playing

INPUT_KEY_USER_ID_MODE = 0x04

user id for mode

INPUT_KEY_USER_ID_VOLDOWN = 0x05

user id for volume down

INPUT_KEY_USER_ID_VOLUP = 0x06

user id for volume up

INPUT_KEY_USER_ID_MUTE = 0x07

user id for mute

INPUT_KEY_USER_ID_CAPTURE = 0x08

user id for capture photo

INPUT_KEY_USER_ID_MSG = 0x09

user id for message

INPUT_KEY_USER_ID_BATTERY_CHARGING = 0x0A

user id for battery charging

INPUT_KEY_USER_ID_WAKEUP = 0x0B

user id for GPIO wakeup

INPUT_KEY_USER_ID_COLOR = 0x0C

user id for color

INPUT_KEY_USER_ID_MAX = 0x101