输入按键服务
输入按键服务 (input key service) 将 GPIO 输入中断和 ADC 按键功能以事件的形式提供给用户。事件定义的音频产品常用按键功能参见 input_key_user_id_t
。
应用示例
以下示例展示了该 API 的实现方式。
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.
- 参数
input_key_config – Configuration of input key service
- 返回
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.
- 参数
input_handle – The handle of input key service
- 返回
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.
- 参数
input_key_handle – handle of service
input_key_info – input key’s information
add_key_num – number of keys
- 返回
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
-
esp_periph_id_t type
-
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
-
periph_service_config_t based_cfg
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
-
enumerator INPUT_KEY_SERVICE_ACTION_UNKNOWN
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
-
enumerator INPUT_KEY_USER_ID_UNKNOWN