mirror of
https://gitee.com/moluo-tech/CodeBrick.git
synced 2025-01-30 04:42:53 +08:00
61 lines
1.9 KiB
C
61 lines
1.9 KiB
C
/******************************************************************************
|
||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*
|
||
* Copyright (c) 2017~2020, <morro_luo@163.com>
|
||
*
|
||
* SPDX-License-Identifier: Apache-2.0
|
||
*
|
||
* Change Logs:
|
||
* Date Author Notes
|
||
* 2017-08-10 Morro Initial version
|
||
* 2021-03-07 Morro <20><><EFBFBD><EFBFBD>æ<EFBFBD>жϽӿ<CFBD>
|
||
******************************************************************************/
|
||
|
||
#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));
|
||
|
||
bool key_busy(key_t *k); /*æ<>ж<EFBFBD>*/
|
||
|
||
void key_scan_process(void); /*<2A><><EFBFBD><EFBFBD>ɨ<EFBFBD>账<EFBFBD><E8B4A6>*/
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif
|