57 lines
1.8 KiB
C
Raw Normal View History

2020-07-11 10:18:03 +08:00
/******************************************************************************
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
2020-12-04 20:53:54 +08:00
* Copyright (c) 2017~2020, <morro_luo@163.com>
2020-07-11 10:18:03 +08:00
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017-08-10 Morro Initial version
******************************************************************************/
#ifndef _KEY_H_
#define _KEY_H_
#include "module.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LONG_PRESS_TIME 1500 /*<2A><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>ʱ<EFBFBD><CAB1> ------------*/
#define KEY_DEBOUNCE_TIME 20 /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> ------------*/
#define KEY_PRESS 0 /*<2A>̰<EFBFBD> --------------------*/
#define KEY_LONG_DOWN 1 /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ----------------*/
#define KEY_LONG_UP 2 /*<2A><><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD> ----------------*/
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -----------------------------------------------------------------*/
typedef struct key_t {
/*
*@brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ӿ<EFBFBD>
*@param[in] none
*@return 0 - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>0 - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
int (*readkey)(void);
/*
*@brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*@param[in] type - <EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(KEY_SHORT_PRESS - <EFBFBD>̰<EFBFBD>, KEY_LONG_PRESS - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
*@param[in] duration <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
*@return none
*/
void (*event)(int type, unsigned int duration);/*<2A><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD> ------------*/
unsigned int tick; /*<2A>δ<EFBFBD><CEB4><EFBFBD>ʱ<EFBFBD><CAB1> --------------*/
struct key_t *next; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
}key_t;
bool key_create(key_t *key, int (*readkey)(void), /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
void (*event)(int type, unsigned int duration));
void key_scan_process(void); /*<2A><><EFBFBD><EFBFBD>ɨ<EFBFBD><EFBFBD><E8B4A6>*/
#ifdef __cplusplus
}
#endif
#endif