/** * @file KEY_ATY.h * * @param Project DEVICE_GENERAL_ATY_LIB * * @author ATY * * @copyright * - Copyright 2017 - 2025 MZ-ATY * - This code follows: * - MZ-ATY Various Contents Joint Statement - * * https://mengze.top/MZ-ATY_VCJS * - CC 4.0 BY-NC-SA - * * https://creativecommons.org/licenses/by-nc-sa/4.0/ * - Your use will be deemed to have accepted the terms of this statement. * * @brief functions of keys for all embedded device * * @version * - 1_01_230514 > ATY * -# Preliminary version, first Release ******************************************************************************** */ #ifndef __KEY_ATY_H #define __KEY_ATY_H #include "INCLUDE_ATY.h" #include "HW_GPIO_ATY.h" /******************************* For user *************************************/ // #define __DEBUG_KEY_ATY #define MAX_KEY_NUMBER 3 #define KEY_INDEX_PW 0 #define KEY_INDEX_UP 1 #define KEY_INDEX_DOWN 2 #define KEY_PORT P2 #define KEY_AD_Threshold 800 extern uint8_t KEY_PIN_GROUP[MAX_KEY_NUMBER]; extern uint8_t KEY_PIN_GROUP_AD[MAX_KEY_NUMBER]; /******************************************************************************/ #define KEY_TYPE_RELASE 0 #define KEY_TYPE_SINGLE 11 #define KEY_TYPE_LONG 21 #define KEY_TYPE_VLONG 22 #define KEY_TYPE_ACCESS_NEW 0xFF #define KEY_RELEASE_DEBOUNCE_TIME 20 #define KEY_PRESS_DEBOUNCE_TIME 100 #define KEY_TYPE_LONG_TIME 800 #define KEY_TYPE_VLONG_TIME (KEY_TYPE_LONG_TIME * 3) extern uint8_t lastKeyType[MAX_KEY_NUMBER]; extern uint8_t keyExportType[MAX_KEY_NUMBER]; extern uint16_t keyScanCount[MAX_KEY_NUMBER]; extern uint16_t keyReleaseCount[MAX_KEY_NUMBER]; #define KEY_ACCESS_NEW(index) \ do{ \ if(lastKeyType[index] != KEY_TYPE_RELASE) \ lastKeyType[index] = KEY_TYPE_ACCESS_NEW; \ } while(0) void KeyStateMachine(uint8_t keyIndex); float KeyStateMachine_AD(uint8_t keyIndex); #endif /* __KEY_ATY_H */ /******************************** End Of File *********************************/