2024-01-23 20:05:30 +08:00
|
|
|
#ifndef __KEY_FSM_H_
|
|
|
|
#define __KEY_FSM_H_
|
|
|
|
|
2024-01-23 22:45:29 +08:00
|
|
|
|
2024-01-30 23:00:38 +08:00
|
|
|
#define KeyFSM_Input(pFSM) (KeyIn *)_preloadIn((FSM *)pFSM)
|
2024-01-29 14:04:24 +08:00
|
|
|
|
2024-01-23 22:45:29 +08:00
|
|
|
typedef enum _keyIn{
|
|
|
|
Up,
|
|
|
|
pDown,
|
|
|
|
}KeyIn;
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum _keyOutSignal{
|
|
|
|
Idle,
|
|
|
|
Down,
|
|
|
|
Hold,
|
|
|
|
Down_2times,
|
|
|
|
Down_3times,
|
|
|
|
}KeyOutSignal;
|
|
|
|
|
2024-01-29 14:04:24 +08:00
|
|
|
const static char *keyStr[] =
|
|
|
|
{
|
|
|
|
"Idle",
|
|
|
|
"Down",
|
|
|
|
"Hold",
|
|
|
|
"Down_2times",
|
|
|
|
"Down_3times",
|
|
|
|
};
|
|
|
|
|
2024-01-23 20:05:30 +08:00
|
|
|
typedef struct _keyFSMData
|
|
|
|
{
|
2024-04-19 13:07:09 +08:00
|
|
|
/* ----------------------------------- 输入 ----------------------------------- */
|
2024-01-23 22:45:29 +08:00
|
|
|
KeyIn in;
|
2024-04-19 13:07:09 +08:00
|
|
|
|
|
|
|
/* ----------------------------------- 输出 ----------------------------------- */
|
2024-01-23 22:45:29 +08:00
|
|
|
KeyOutSignal out;
|
2024-04-19 13:07:09 +08:00
|
|
|
|
|
|
|
/* ---------------------------------- 内部变量 ---------------------------------- */
|
2024-01-30 15:11:15 +08:00
|
|
|
int countDelay;
|
|
|
|
int countMultiDown;
|
2024-01-23 20:05:30 +08:00
|
|
|
}KeyFSMData;
|
|
|
|
|
|
|
|
typedef struct _KeyFSM KeyFSM;
|
|
|
|
|
|
|
|
KeyFSM *createKeyFSM();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|