#pragma once #include "esp_err.h" // 按键引脚定义 #define PIN_BTN_BOOT 9 // GPIO9 BOOT按键(低电平有效) #define PIN_BTN_KEY2 8 // GPIO8 KEY2按键(低电平有效) // 按键事件类型 typedef enum { BTN_EVT_CLICK, // 单击 BTN_EVT_DOUBLE_CLICK, // 双击 BTN_EVT_LONG_PRESS, // 长按(达到阈值时触发一次) } btn_event_type_t; // 按键事件回调函数类型 typedef void (*btn_event_cb_t)(int gpio_num, btn_event_type_t event, void *usr_data); // 初始化按键驱动(基于iot_button组件) esp_err_t button_init(void); // 注册BOOT按键事件回调(单击/双击/长按统一回调) void button_on_boot_event(btn_event_cb_t cb, void *usr_data); // 注册KEY2按键事件回调(单击/双击/长按统一回调) void button_on_key2_event(btn_event_cb_t cb, void *usr_data);