/* ------------------------------------------------------------------------------------------------
* @fn KeyCoolPressTimeHandle
*
* @brief 按键的检测
*
* @param none
*
* @return none
**************************************************************************************************
*/
uint8_t KeyCoolPressTimeHandle(void)
{
static uint32_t KEY_Cool_PressTime = 0;
uint8_t KeyState = KEY_PRESS_NULL;
if(KEY_Cool == (uint8_t)Bit_RESET)
{
if(KEY_Cool_PressTime == 0)
{
KEY_Cool_PressTime = TcomGetTimerCount();
}
if(TcomGetTimerCount() - KEY_Cool_PressTime > LONG_PRESS_TIME)
{
KeyState = KEY_PRESS_LONG;
//KEY_Cool_PressTime = 0;
}
}
else
{
if(KEY_Cool_PressTime != 0 && TcomGetTimerCount() - KEY_Cool_PressTime > SHORT_PRESS_TIME)
{
KeyState = KEY_PRESS_SHORT;
}
KEY_Cool_PressTime = 0;
}
return KeyState;
}
void KeyCoolHandle(void)
{
uint8_t KeyState = KeyCoolPressTimeHandle();
if(KeyStateStruct.Cool == KEY_PRESS_NULL && KeyState != KEY_PRESS_NULL)
{
if(KeyState == KEY_PRESS_SHORT)
{
//执行操作
// ToggleKeyCoolState();
// KeyStateSend(ADDR_COOL);
}
else if(KeyState == KEY_PRESS_LONG)
{
// KEY_LOG("Key Cool Long Press\n");
}
}
KeyStateStruct.Cool = KeyState;
}