Commit 5c96b146 authored by hu's avatar hu

优化按键操作逻辑

parent 87249c1a
......@@ -12,12 +12,12 @@
/*-----------------------------------------------------------------------------------------*/
typedef struct
{
uint16_t u16KeyShortPressTime; /*¶Ì°´¼ì²âʱ¼ä*/
uint16_t u16KeyLongPressTime; /*³¤°´¼ì²âʱ¼ä*/
uint16_t u16KeyShortPressTime; /*¶Ì°´¼ì²âʱ¼ä*/
uint16_t u16KeyLongPressTime; /*³¤°´¼ì²âʱ¼ä*/
uint16_t u16KeySuperLongPressTime; /*³¬³¤°´¼ì²âʱ¼ä*/
uint16_t u16KeyLoosenTime; /*ËÉ¿ª¼ì²âʱ¼ä*/
uint16_t u16KeyValidOFFTime; /*ÓÐЧOFF¼ì²âʱ¼ä*/
uint16_t u16KeyValidONTime; /*ÓÐЧON¼ì²âʱ¼ä*/
uint16_t u16KeyLoosenTime; /*ËÉ¿ª¼ì²âʱ¼ä*/
uint16_t u16KeyValidOFFTime; /*ÓÐЧOFF¼ì²âʱ¼ä*/
uint16_t u16KeyValidONTime; /*ÓÐЧON¼ì²âʱ¼ä*/
} Key_Parameter_st_t;
......@@ -40,10 +40,10 @@ static Key_Parameter_st_t stKeyParameter;
#pragma ghs section bss = default
static Key_Ctr_st_t stKeyCtrVariate[KEY_NUM_MAX];
//static Key_IGN_en_t enKeyIGNFirstStatus = KEY_IG_INVALID;
//static Key_IGN_en_t enKeyIGNStatusLast = KEY_IG_INVALID;
//static uint8_t u8KeyIGNChangeFlag = 0U;
//static uint16_t u16KeyIGNTimeCount;
// static Key_IGN_en_t enKeyIGNFirstStatus = KEY_IG_INVALID;
// static Key_IGN_en_t enKeyIGNStatusLast = KEY_IG_INVALID;
// static uint8_t u8KeyIGNChangeFlag = 0U;
// static uint16_t u16KeyIGNTimeCount;
/*-----------------------------------------------------------------------------------------*/
static void Key_Process(Key_Num_en_t enKeyIndex);
......@@ -76,7 +76,7 @@ static void Key_Process(Key_Num_en_t enKeyIndex)
if (stKeyAttribute[enKeyIndex].pfnKeyOperationCallBack != 0U)
{
if ((stKeyCtrVariate[enKeyIndex].enKeyTypeLast == KEY_CAN_NONE) &&
(enKeyRealType == KEY_CAN_SHORT_PRESS))
(enKeyRealType == KEY_CAN_SHORT_PRESS))
{
stKeyAttribute[enKeyIndex].pfnKeyOperationCallBack(KEY_EVENT_SHORT_PRESS);
}
......@@ -110,7 +110,7 @@ static void Key_Process(Key_Num_en_t enKeyIndex)
if (stKeyAttribute[enKeyIndex].pfnKeyOperationCallBack != 0U)
{
if ((stKeyCtrVariate[enKeyIndex].enKeyTypeLast == KEY_CAN_SHORT_PRESS) &&
(enKeyRealType == KEY_CAN_NONE))
(enKeyRealType == KEY_CAN_NONE))
{
stKeyAttribute[enKeyIndex].pfnKeyOperationCallBack(KEY_EVENT_SHORT_PRESS);
}
......@@ -157,8 +157,8 @@ static void Key_Process(Key_Num_en_t enKeyIndex)
stKeyCtrVariate[enKeyIndex].u16KeyIGNTimeCount = 0U;
}
if ((stKeyCtrVariate[enKeyIndex].u16KeyInvalidTimeCount >= stKeyParameter.u16KeyLoosenTime) &&
(stKeyCtrVariate[enKeyIndex].u16KeyValidTimeCount >= stKeyParameter.u16KeyShortPressTime) &&
(stKeyCtrVariate[enKeyIndex].u16KeyValidTimeCount < stKeyParameter.u16KeyLongPressTime))
(stKeyCtrVariate[enKeyIndex].u16KeyValidTimeCount >= stKeyParameter.u16KeyShortPressTime) &&
(stKeyCtrVariate[enKeyIndex].u16KeyValidTimeCount < stKeyParameter.u16KeyLongPressTime))
{
stKeyCtrVariate[enKeyIndex].u16KeyValidTimeCount = 0U;
/* call back */
......@@ -212,8 +212,10 @@ static void Key_Process(Key_Num_en_t enKeyIndex)
if (stKeyCtrVariate[enKeyIndex].u16KeyValidTimeCount >= stKeyParameter.u16KeyShortPressTime)
{
stKeyCtrVariate[enKeyIndex].u16KeyInvalidTimeCount = 0U;
// stKeyCtrVariate[enKeyIndex].u16KeyInvalidTimeCount = 0U;
}
stKeyCtrVariate[enKeyIndex].u16KeyInvalidTimeCount = 0U;
if (stKeyCtrVariate[enKeyIndex].u8KeyIGNChangeFlag == 0U)
{
if (stKeyCtrVariate[enKeyIndex].u16KeyValidTimeCount >= stKeyParameter.u16KeySuperLongPressTime)
......@@ -238,7 +240,7 @@ static void Key_Process(Key_Num_en_t enKeyIndex)
if (enKeyIGNRealStatus == KEY_IG_ON)
{
if ((stKeyCtrVariate[enKeyIndex].u16KeyFirstIGNTimeRecord >= stKeyParameter.u16KeyValidOFFTime) &&
(stKeyCtrVariate[enKeyIndex].u16KeyIGNTimeCount >= stKeyParameter.u16KeyValidONTime))
(stKeyCtrVariate[enKeyIndex].u16KeyIGNTimeCount >= stKeyParameter.u16KeyValidONTime))
{
if (stKeyAttribute[enKeyIndex].pfnKeyOperationCallBack != 0U)
{
......@@ -253,7 +255,7 @@ static void Key_Process(Key_Num_en_t enKeyIndex)
if (enKeyIGNRealStatus == KEY_IG_OFF)
{
if ((stKeyCtrVariate[enKeyIndex].u16KeyFirstIGNTimeRecord >= stKeyParameter.u16KeyValidONTime) &&
(stKeyCtrVariate[enKeyIndex].u16KeyIGNTimeCount >= stKeyParameter.u16KeyValidOFFTime))
(stKeyCtrVariate[enKeyIndex].u16KeyIGNTimeCount >= stKeyParameter.u16KeyValidOFFTime))
{
if (stKeyAttribute[enKeyIndex].pfnKeyOperationCallBack != 0U)
{
......@@ -304,11 +306,11 @@ void Key_Init(void)
stKeyCtrVariate[i].u16KeyIGNTimeCount = 0U;
}
/*按键动作时间*/
stKeyParameter.u16KeyLoosenTime = 200U;
stKeyParameter.u16KeyLoosenTime = 100U;
stKeyParameter.u16KeyShortPressTime = 40U;
stKeyParameter.u16KeyLongPressTime = 2000U;
stKeyParameter.u16KeySuperLongPressTime = 10000U;
stKeyParameter.u16KeyValidOFFTime = 200U;/*按键动作时间*/
stKeyParameter.u16KeyValidOFFTime = 200U; /*按键动作时间*/
stKeyParameter.u16KeyValidONTime = 1000U;
}
/*对于硬线按键而言,判断短按的时间参数*/
......
This diff is collapsed.
......@@ -6,59 +6,59 @@
#include "Key.h"
#include "CAN_Lib.h"
#include "GUI.h"
#include "Services_ODO_User.h" /*清空总计里程函数*/
#include "Services_ODO_User.h" /*清空总计里程函数*/
#include "Menu.h"
#include "jcua.h"
uint32_t EnterTimer [ 10 ];
uint8_t UE_EN [ Display_MAX ];
uint32_t EnterTimer[10];
uint8_t UE_EN[Display_MAX];
#pragma alignvar(8)
#pragma ghs section bss = default
uint8_t Mem [ 32 ];
uint8_t Mem[32];
#pragma ghs section bss = default
#pragma ghs section bss = ".myNonInitArea"
#pragma ghs section bss = ".myNonInitArea"
UE_CtrlInfo_Struct_t UE_CtrlInfo;
uint8_t BG_display_flag;
#pragma ghs section bss = default
#pragma ghs section bss = default
uint32_t HMI_StartAnimationFrameCnt;
uint32_t HMI_StartAnimationFrameCnt;
static void switch_branch(void);
uint8_t Get_Pwr(void)
{
return Common_Get_IG_Sts( );
return Common_Get_IG_Sts();
}
uint32_t Get_IG_ON(void)
{
return Common_GetIgnOnTime( );
return Common_GetIgnOnTime();
}
uint32_t Get_IG_Off(void)
{
return Common_GetIgnOffTime( );
return Common_GetIgnOffTime();
}
static const DispSch_Attr_st loc [] =
{
{&UE_EN [ Display_StartAnimation ], UE_IGN_ON, Display_StartAnimation, (( void * )0), Display_StartAnimationEnter, Display_StartAnimationService, Display_StartAnimationExit},
{&UE_EN [ Display_Menu ], UE_IGN_ON, Display_Menu, (( void * )0), (( void * )0), Display_MenuService, (( void * )0)},
{&UE_EN [ Display_Alarm ], UE_IGN_ON, Display_Alarm, (( void * )0), (( void * )0), Display_AlarmService, (( void * )0)},
static const DispSch_Attr_st loc[] =
{
{&UE_EN[Display_StartAnimation], UE_IGN_ON, Display_StartAnimation, ((void *)0), Display_StartAnimationEnter, Display_StartAnimationService, Display_StartAnimationExit},
{&UE_EN[Display_Menu], UE_IGN_ON, Display_Menu, ((void *)0), ((void *)0), Display_MenuService, ((void *)0)},
{&UE_EN[Display_Alarm], UE_IGN_ON, Display_Alarm, ((void *)0), ((void *)0), Display_AlarmService, ((void *)0)},
};
void DispSch_TotalInit(void)
{
uint8_t i;
uint8_t i;
DispSch_Ext_st m_st;
m_st.Get_Power = Get_Pwr;
m_st.Get_IG_ON_Timer = Get_IG_ON;
m_st.Get_Power = Get_Pwr;
m_st.Get_IG_ON_Timer = Get_IG_ON;
m_st.Get_IG_OFF_Timer = Get_IG_Off;
m_st.Get_IG_OFF_Timer = Get_IG_Off;
m_st.TotalSize = Display_MAX;
m_st.TotalSize = Display_MAX;
DispSch_Init(Mem, loc, &m_st, 0u);
for ( i = 0u; i < Display_MAX; i++ )
for (i = 0u; i < Display_MAX; i++)
{
UE_EN [ i ] = UE_Disable;
UE_EN[i] = UE_Disable;
}
}
......@@ -66,85 +66,99 @@ void DisplayServices(void)
{
uint32_t PowerOnTimer;
uint32_t PowerOFFTimer;
uint8_t PowerStatus;
uint8_t PowerStatus;
uint16_t popupID = 0xFFFFu;
uint16_t DispVSpeed = 0u;
PowerStatus = Common_Get_IG_Sts( );
PowerOnTimer = Common_GetIgnOnTime( );
PowerOFFTimer = Common_GetIgnOffTime( );
PowerStatus = Common_Get_IG_Sts();
PowerOnTimer = Common_GetIgnOnTime();
PowerOFFTimer = Common_GetIgnOffTime();
DispVSpeed = Common_Get_Disp_V_Speed();
if ( (PowerOnTimer <= StartAnimationEnd) && (PowerOnTimer >= StartAnimationStart) )
if ((PowerOnTimer <= StartAnimationEnd) && (PowerOnTimer >= StartAnimationStart))
{
UE_EN [ Display_StartAnimation ] = UE_Enable;
UE_EN [ Display_Menu ] = UE_Disable;
UE_EN [ Display_Alarm ] = UE_Disable;
UE_EN[Display_StartAnimation] = UE_Enable;
UE_EN[Display_Menu] = UE_Disable;
UE_EN[Display_Alarm] = UE_Disable;
}
else
{
popupID = Popup_Get_Current_Message( );
popupID = Popup_Get_Current_Message();
if ((popupID != 0xffffu ) && (MenuFlag.Key_Menu_Popup_time == 0x00u))
if ((popupID != 0xffffu) && (MenuFlag.Key_Menu_Popup_time == 0x00u))
{
UE_EN [ Display_Alarm ] = UE_Enable;
UE_EN[Display_Alarm] = UE_Enable;
}
else
{
if (MenuFlag.Key_Menu_Popup_time != 0x00u)
{
MenuFlag.Key_Menu_Popup_time --;
MenuFlag.Key_Menu_Popup_time--;
}
else
{
;/*Do Nothing!*/
; /*Do Nothing!*/
}
UE_EN [ Display_Alarm ] = UE_Disable;
UE_EN[Display_Alarm] = UE_Disable;
if ( PowerStatus == COMMON_POWER_ON )
if (PowerStatus == COMMON_POWER_ON)
{
UE_EN [ Display_Menu ] = UE_Enable;
UE_EN[Display_Menu] = UE_Enable;
}
else
{
UE_EN [ Display_Menu ] = UE_Disable;
UE_EN[Display_Menu] = UE_Disable;
}
}
if (DispVSpeed > 66u)
{
if ((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_5_MENU_4))
{
NextMenu(MenuFlag.Menu_Flag);
}
}
else
{
; /*Do Nothing!*/
}
}
DispSch_xxxMs_Logic(10u);
/*上短*/
if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_UP == KEY_EVENT_SHORT_PRESS )
if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_UP == KEY_EVENT_SHORT_PRESS)
{
HMI_Clear_KEY_UP();
}
/*上长*/
else if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_UP == KEY_EVENT_LONG_PRESS )
else if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_UP == KEY_EVENT_LONG_PRESS)
{
HMI_Clear_KEY_UP();
}
/*下短*/
else if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_DOWN == KEY_EVENT_SHORT_PRESS )
else if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_DOWN == KEY_EVENT_SHORT_PRESS)
{
HMI_Clear_KEY_DOWN();
}
/*下长*/
else if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_DOWN == KEY_EVENT_LONG_PRESS )
else if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_DOWN == KEY_EVENT_LONG_PRESS)
{
HMI_Clear_KEY_DOWN();
}
/*确认短*/
else if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_CONFIRM == KEY_EVENT_SHORT_PRESS )
else if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_CONFIRM == KEY_EVENT_SHORT_PRESS)
{
HMI_Clear_KEY_CONFIRM();
}
/*确认长*/
else if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_CONFIRM == KEY_EVENT_LONG_PRESS )
else if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_CONFIRM == KEY_EVENT_LONG_PRESS)
{
HMI_Clear_KEY_CONFIRM();
}
/*确认超长 30 S*/
else if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_CONFIRM == KEY_EVENT_SUPER_LONG_PRESS )
else if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_CONFIRM == KEY_EVENT_SUPER_LONG_PRESS)
{
HMI_Clear_KEY_CONFIRM();
......@@ -152,28 +166,28 @@ void DisplayServices(void)
TYW_Data_ODO_Clear();
}
/*返回短*/
else if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_CANCEL == KEY_EVENT_SHORT_PRESS )
else if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_CANCEL == KEY_EVENT_SHORT_PRESS)
{
HMI_Clear_KEY_CANCEL();
}
/*返回长*/
else if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_CANCEL == KEY_EVENT_LONG_PRESS )
else if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_CANCEL == KEY_EVENT_LONG_PRESS)
{
HMI_Clear_KEY_CANCEL();
}
/*MENU短*/
else if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_MENU == KEY_EVENT_SHORT_PRESS )
else if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_MENU == KEY_EVENT_SHORT_PRESS)
{
HMI_Clear_KEY_MENU();
}
/*MENU长*/
else if ( UE_CtrlInfo.HMI_KEYInfo.u8KEY_MENU == KEY_EVENT_LONG_PRESS )
else if (UE_CtrlInfo.HMI_KEYInfo.u8KEY_MENU == KEY_EVENT_LONG_PRESS)
{
HMI_Clear_KEY_MENU();
}
else
{
;/*do nothing*/
; /*do nothing*/
}
}
......@@ -188,31 +202,29 @@ void Display_StartAnimationService(void)
HMI_StartAnimationFrameCnt++;
m16_FrameCnt = HMI_StartAnimationFrameCnt;
if ( (m16_FrameCnt % 3) == 0 )
if ((m16_FrameCnt % 3) == 0)
{
loc_Disable_Window_App( );
//GUI_Display_Animation_Frame(m16_FrameCnt / 3u);
loc_Disable_Window_App();
// GUI_Display_Animation_Frame(m16_FrameCnt / 3u);
GUI_Display_background();
}
}
void Display_StartAnimationExit(void)
{
loc_Enable_Window_App( );
loc_Enable_Window_App();
}
void Display_MenuService(void)
{
}
void Display_AlarmService(void)
{
}
void GUI_DisplayServices(void)
{
UElib_uint16_t HMI_MENU_Sta = 0u;
UElib_uint16_t HMI_MENU_Sta = 0u;
HMI_MENU_Sta = Get_Cur_HMI();
......@@ -255,7 +267,7 @@ void GUI_DisplayServices(void)
}
MenuManage();
//BG_display_flag = 0;
// BG_display_flag = 0;
}
}
}
......@@ -281,7 +293,6 @@ void HMI_Set_KEY_MENU(uint8_t u8KeyVal)
UE_CtrlInfo.HMI_KEYInfo.u8KEY_MENU = u8KeyVal;
}
void HMI_Clear_KEY_UP(void)
{
UE_CtrlInfo.HMI_KEYInfo.u8KEY_UP = 0u;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment