/** * @file key.h * @brief 单 GPIO 按键控制 (低电平有效, 软件消抖) */ #ifndef KEY_H #define KEY_H #include #include "driver/gpio.h" #ifdef __cplusplus extern "C" { #endif /** * @brief 初始化按键 (内部上拉, 低电平有效) * @param gpio GPIO 引脚号, 如 GPIO_NUM_8 */ void key_init(int gpio); /** * @brief 读取按键状态 (已消抖) * @return true=按下, false=释放 */ bool key_is_pressed(void); #ifdef __cplusplus } #endif #endif /* KEY_H */