38 lines
987 B
C
38 lines
987 B
C
// 文件编码: GB18030
|
||
/*
|
||
* button.h
|
||
*
|
||
* Created on: 2025年4月19日
|
||
* Author: LHYe200
|
||
*/
|
||
|
||
#ifndef CODE_BUTTON_H_
|
||
#define CODE_BUTTON_H_
|
||
|
||
#include "zf_common_headfile.h"
|
||
|
||
#define BUTTON_PIN_NUM 5 // 按键数量
|
||
#define BUTTON_PINS {P02_4, P02_5,P02_6,P02_7,P02_8}
|
||
|
||
#define BUTTON_SCAN_TIME 5 // 按键扫描时间,单位ms
|
||
#define BUTTON_SHORT_PRESS_TIME 30 // 按键短按时间,单位ms
|
||
#define BUTTON_LONG_PRESS_TIME 1000 // 按键长按时间,单位ms
|
||
|
||
#define BUTTON_SHORT_PRESS 1 // 短按
|
||
#define BUTTON_LONG_PRESS 2 // 长按
|
||
#define BUTTON_RELEASE 0 // 松开
|
||
#define BUTTON_LONG_PRESS_GOT 3
|
||
|
||
extern gpio_pin_enum BUTTON_PIN[BUTTON_PIN_NUM]; // 按键引脚
|
||
|
||
|
||
// extern uint8 button_state[BUTTON_PIN_NUM]; // 按键状态
|
||
// extern uint16 button_last_time[BUTTON_PIN_NUM]; // 持续按下时间
|
||
|
||
void Button_Init(void); // 按键初始化函数
|
||
void Button_Scan(void); // 按键扫描函数
|
||
uint8 Button_Get_State(uint8 button_num); // 获取按键状态函数
|
||
void Button_Reset(uint8 button_num);
|
||
|
||
#endif /* CODE_BUTTON_H_ */
|