2020-07-11 10:18:03 +08:00

57 lines
1.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************************************
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* Copyright (c) 2017~2020, <master_roger@sina.com>
*
* 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 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ӿ<EFBFBD>
*@param[in] none
*@return 0 - <20><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>, <20><>0 - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
int (*readkey)(void);
/*
*@brief <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*@param[in] type - <20>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>(KEY_SHORT_PRESS - <20>̰<EFBFBD>, KEY_LONG_PRESS - <20><><EFBFBD><EFBFBD>)
*@param[in] duration <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>,<2C><><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