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.

Parameters

input_key_config – Configuration of input key service

Returns

NULL failed others input key service handle

periph_service_state_t get_input_key_service_state(periph_service_handle_t input_handle)

Get the state of input key service.

Parameters

input_handle – The handle of input key service

Returns

state 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.

Parameters
  • input_key_handle – handle of service

  • input_key_info – input key’s information

  • add_key_num – number of keys

Returns

ESP_OK success ESP_FAIL failed

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:

enumerator INPUT_KEY_SERVICE_ACTION_UNKNOWN

unknown action id

enumerator INPUT_KEY_SERVICE_ACTION_CLICK

click action id

enumerator INPUT_KEY_SERVICE_ACTION_CLICK_RELEASE

click release action id

enumerator INPUT_KEY_SERVICE_ACTION_PRESS

long press action id

enumerator 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:

enumerator INPUT_KEY_USER_ID_UNKNOWN

unknown user id

enumerator INPUT_KEY_USER_ID_REC

user id for recording

enumerator INPUT_KEY_USER_ID_SET

user id for settings

enumerator INPUT_KEY_USER_ID_PLAY

user id for playing

enumerator INPUT_KEY_USER_ID_MODE

user id for mode

enumerator INPUT_KEY_USER_ID_VOLDOWN

user id for volume down

enumerator INPUT_KEY_USER_ID_VOLUP

user id for volume up

enumerator INPUT_KEY_USER_ID_MUTE

user id for mute

enumerator INPUT_KEY_USER_ID_CAPTURE

user id for capture photo

enumerator INPUT_KEY_USER_ID_MSG

user id for message

enumerator INPUT_KEY_USER_ID_BATTERY_CHARGING

user id for battery charging

enumerator INPUT_KEY_USER_ID_WAKEUP

user id for GPIO wakeup

enumerator INPUT_KEY_USER_ID_COLOR

user id for color

enumerator INPUT_KEY_USER_ID_MAX