按键系统待测

This commit is contained in:
CSBOOK\44744
2026-06-25 01:20:23 +08:00
parent 3cce1be162
commit 84ecf892b5
11 changed files with 1187 additions and 61 deletions
@@ -0,0 +1,57 @@
/*
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "driver/gpio.h"
typedef enum {
CONTROL_PLANE_EVENT_FAMILY_KEY = 0,
CONTROL_PLANE_EVENT_FAMILY_WIFI,
CONTROL_PLANE_EVENT_FAMILY_MULTIMODAL,
CONTROL_PLANE_EVENT_FAMILY_LCD,
CONTROL_PLANE_EVENT_FAMILY_DIRECTION,
CONTROL_PLANE_EVENT_FAMILY_CALIBRATION,
CONTROL_PLANE_EVENT_FAMILY_RUNTIME,
} control_plane_event_family_t;
typedef enum {
CONTROL_PLANE_KEY_ID_PTT = 0,
CONTROL_PLANE_KEY_ID_SW1,
CONTROL_PLANE_KEY_ID_SW2,
} control_plane_key_id_t;
typedef enum {
CONTROL_PLANE_KEY_EVENT_PRESSED = 0,
CONTROL_PLANE_KEY_EVENT_RELEASED,
CONTROL_PLANE_KEY_EVENT_SHORT_PRESS,
CONTROL_PLANE_KEY_EVENT_LONG_PRESS_START,
CONTROL_PLANE_KEY_EVENT_LONG_PRESS_RELEASE,
CONTROL_PLANE_KEY_EVENT_DOUBLE_CLICK,
CONTROL_PLANE_KEY_EVENT_REPEAT,
CONTROL_PLANE_KEY_EVENT_CANCELLED,
} control_plane_key_event_type_t;
typedef struct {
control_plane_key_id_t key_id;
control_plane_key_event_type_t type;
gpio_num_t gpio_num;
int level;
int64_t timestamp_ms;
uint32_t press_duration_ms;
uint32_t click_count;
} control_plane_key_event_t;
typedef struct {
control_plane_event_family_t family;
int64_t timestamp_ms;
union {
control_plane_key_event_t key;
} data;
} control_plane_system_event_t;
@@ -12,6 +12,7 @@
#include "control_plane.h"
#include "domain.h"
#include "esp_err.h"
#include "control_plane_events.h"
control_plane_direction_command_t control_plane_direction_parse_command_internal(
const char *input,
@@ -112,3 +113,13 @@ bool control_plane_multimodal_is_uplink_running(void);
esp_err_t control_plane_multimodal_play_downstream_audio(const uint8_t *data, size_t len);
esp_err_t control_plane_multimodal_handle_ptt_press_step(void);
esp_err_t control_plane_multimodal_handle_ptt_release(void);
esp_err_t control_plane_start_system_event_task(void);
void control_plane_stop_system_event_task(void);
esp_err_t control_plane_post_system_event(const control_plane_system_event_t *event, uint32_t timeout_ms);
int64_t control_plane_event_timestamp_ms(void);
const char *control_plane_key_id_name(control_plane_key_id_t key_id);
const char *control_plane_key_event_type_name(control_plane_key_event_type_t type);
esp_err_t control_plane_start_key_input_task(void);
void control_plane_stop_key_input_task(void);