| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /**
- ******************************************************************************
- * @file input_scan.h
- * @brief 编码器/按键扫描模块公共接口
- *
- * 负责:
- * - 3个按键的消抖检测 (SW_KEY / SW1_KEY / SW2_KEY)
- * - 2个旋转编码器的正交解码 (SW1 / SW2)
- * - 编码器变速调节逻辑
- *
- * 事件标志由本模块定义, main.c 通过 extern 读取后处理.
- ******************************************************************************
- */
- #ifndef __INPUT_SCAN_H
- #define __INPUT_SCAN_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdint.h>
- /* ========== 按键事件标志 (在 ScanButtons 中置位, 主循环中清除) ========== */
- extern volatile uint8_t g_swKeyEdge; /* SW_KEY 短按释放标志 */
- extern volatile uint8_t g_sw1KeyEdge; /* SW1_KEY 短按释放标志 */
- extern volatile uint8_t g_sw2KeyEdge; /* SW2_KEY 短按释放标志 */
- extern volatile uint8_t g_swKeyLongPress; /* SW_KEY 长按5s标志 (1=触发, 2=已处理) */
- /* ========== 双键同按状态 (在 ScanButtons 中维护) ========== */
- extern volatile uint8_t g_bothPressFlag; /* 两编码器键同按标志 */
- extern volatile uint16_t g_bothPressMs; /* 同按持续时间 (ms) */
- /* ========== 函数接口 ========== */
- /**
- * @brief 初始化输入扫描模块
- * 读取编码器和按键的初始状态, 防止上电后产生误触发.
- * 须在 GPIO 初始化之后、TIM3 启动之前调用.
- */
- void InputScan_Init(void);
- /**
- * @brief 扫描所有按键 (在 TIM3 中断中每 1ms 调用)
- * 外部上拉, 低电平有效, 包含边沿检测.
- */
- void ScanButtons(void);
- /**
- * @brief 扫描所有编码器 (在 TIM3 中断中每 1ms 调用)
- * SW1: 低音音量; SW2: 主音量 LR
- */
- void ScanEncoders(void);
- #ifdef __cplusplus
- }
- #endif
- #endif /* __INPUT_SCAN_H */
|