esp32s2_bare_board/main/components/key_scan/key_scan.h
2025-04-14 17:33:55 +08:00

71 lines
2.1 KiB
C

/**
* @file key_scan.h
* @author Alvin Young (impressionyang@outlook.com)
* @brief
* @version 0.1
* @date 2025-03-23
*
* _ _
* (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _
* / / ' \/ _ \/ __/ -_|_-<(_-</ / _ \/ _ \/ // / _ `/ _ \/ _ `/
* /_/_/_/_/ .__/_/ \__/___/___/_/\___/_//_/\_, /\_,_/_//_/\_, /
* /_/ /___/ /___/
* @copyright Copyright (c) 2025 impressionyang
*
* @par 修改日志:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2025-03-23 <td>v1.0 <td>Alvin Young <td>首次创建
* </table>
*
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __KEY_SCAN_H__
#define __KEY_SCAN_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/* define --------------------------------------------------------------------*/
/* typedef -------------------------------------------------------------------*/
typedef enum __key_scan_key_result_e__
{
EM_KEY_SCAN_RESULT_IDLE = 0x00,
EM_KEY_SCAN_RESULT_ONSHOT,
EM_KEY_SCAN_RESULT_DOUBLE,
EM_KEY_SCAN_RESULT_LONG,
} key_scan_key_result_e;
typedef enum __key_scan_key_stm_e__
{
EM_KEY_SCAN_KEY_STM_IDLE = 0x00,
EM_KEY_SCAN_KEY_STM_DEBOUNCE,
EM_KEY_SCAN_KEY_STM_PRESS,
EM_KEY_SCAN_KEY_STM_RELEASE,
EM_KEY_SCAN_KEY_STM_SEND_KEY,
} key_scan_key_stm_e;
typedef struct __key_scan_key_state_t__
{
key_scan_key_stm_e state;
key_scan_key_stm_e last_state;
uint16_t press_cnt;
uint16_t release_cnt;
uint8_t debounce_ret;
} key_scan_key_state_t;
/* variables -----------------------------------------------------------------*/
/* Private function(only *.c) -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
uint8_t key_scan_init();
#ifdef __cplusplus
}
#endif
#endif //__KEY_SCAN_H__
/*
* EOF
*/