#ifndef __STM32_LED_H
#define __STM32_LED_H

#include "main.h"

//
/*
短按: 1次,80ms~280ms(down)

长按: 1200ms~>>(down)

双击: 2次,80ms~280ms(down) -> 0ms~280ms(up) -> 80ms~280ms(down)
*/
#define SCAN_TIME 		(10)				//10ms任务,扫描一次
#define CANCEL_KEY_DOWN (80/SCAN_TIME)		//按下<80ms，取消
#define SHORT_KEY_DOWN 	(280/SCAN_TIME)		//短按80ms-280ms
#define LONG_KEY_DOWN 	(1200/SCAN_TIME)	//长按1.2s
#define CANCEL_KEY_UP 	(280/SCAN_TIME)		//松开超过280ms，取消

#define HANDLE_KEY_TIME (240/SCAN_TIME)		//按键处理时间

enum KeyState
{
    KEY_UP_FLAG,
    KEY_DOWN_FLAG
};

enum KeyRes
{
    NO_KEY_FLAG,
    ONE_HITS_KEY_FLAG,
    TWO_HITS_KEY_FLAG,
    THREE_HITS_KEY_FLAG,
    LONG_KEY_FLAG,
    MAX_KEY_FLAG
};

typedef struct
{
    unsigned char ID;			//按键号
    unsigned char State;		//状态
    unsigned short DnTime;		//down计时
    unsigned short UpTime;		//up计时
    unsigned char HitNum;		//单击计次
    unsigned char Res;			//最后结果
} pKey;

/*tea5767
	K11: up+
	K12: down-
*/


/*ds1302
	K13: 开机时间复位
	K14: 菜单
	K15: up+
	K16: down-
*/

extern pKey Keys[16];

extern void GPIO_ConfigurationKey ( void );
extern unsigned short ScanKey ( void );
extern void KeyHander ( void );



#endif


