Commit bd899f06 authored by 时昊's avatar 时昊

feat:增加按键超时功能

parent 224d593b
...@@ -6,56 +6,21 @@ ...@@ -6,56 +6,21 @@
__align(4) __align(4)
#define BACK_MENU_TIME 1000 #define BACK_MENU_TIME 1000
// #define MENU_GRADE g_u8Menu_Grade
#define CURSOR_POSITION g_u8Cursor_Posittion
_Menu_Data MenuData; _Menu_Data MenuData;
uint8_t PageType; //设置时间参数(设置小时或者分钟)
uint8_t Key_Right_Long_Press_Flag;
uint8_t Key_Left_Long_Press_Flag;
RTC_TimeTypeDef RTC_TimeStruct; RTC_TimeTypeDef RTC_TimeStruct;
RTC_DateTypeDef RTC_DateStruct; RTC_DateTypeDef RTC_DateStruct;
RTC_CounterTypeDef counter_val; RTC_CounterTypeDef counter_val;
void Key_Operation_Left(Key_Event_en_t enKeyEvent)//Mode void Key_Operation_Left(Key_Event_en_t enKeyEvent)//选择
{ {
switch (enKeyEvent) switch (enKeyEvent)
{ {
case KEY_EVENT_SHORT_PRESS_1: case KEY_EVENT_SHORT_PRESS_1:
// if(MENU_GRADE == 0x00) Key_Event_Short_Press_Left();
// {
// Menu_Service(MENU_KEY_LEFT_SHORT);
// }
// else
// {
// Menu_Service(MENU_KEY_DOWN_SHORT);
// }
break; break;
case KEY_EVENT_SHORT_PRESS_2: case KEY_EVENT_SHORT_PRESS_2:
// if(MENU_GRADE == 0x00)
// {
// Menu_Service(MENU_KEY_LEFT_LONG);
// }
// else
// {
// Menu_Change_Branch_To_Item(0, MENU_ITEM_DriveInfo);
// Menu_Service(MENU_KEY_DOWN_LONG);
// }
break; break;
case KEY_EVENT_LONG_PRESS_1: //2 case KEY_EVENT_LONG_PRESS_1: //2
// if(MENU_GRADE == 0x00)
// {
// Menu_Service(MENU_KEY_LEFT_SUPER_LONG);
// }
// else
// {
// Menu_Service(MENU_KEY_DOWN_SUPER_LONG);
// }
Key_Left_Long_Press_Flag = 1;
break; break;
case KEY_EVENT_LONG_PRESS_2: //3 case KEY_EVENT_LONG_PRESS_2: //3
break; break;
...@@ -68,25 +33,22 @@ void Key_Operation_Left(Key_Event_en_t enKeyEvent)//Mode ...@@ -68,25 +33,22 @@ void Key_Operation_Left(Key_Event_en_t enKeyEvent)//Mode
case KEY_EVENT_ON_TO_OFF: case KEY_EVENT_ON_TO_OFF:
break; break;
case KEY_EVENT_NONE: case KEY_EVENT_NONE:
Key_Left_Long_Press_Flag = 0; KEY_LEFT_EVENT_NONE_Service();
break; break;
default: default:
break; break;
} }
} }
void Key_Operation_Right(Key_Event_en_t enKeyEvent)//Set void Key_Operation_Right(Key_Event_en_t enKeyEvent)//确认
{ {
switch (enKeyEvent) switch (enKeyEvent)
{ {
case KEY_EVENT_SHORT_PRESS_1: case KEY_EVENT_SHORT_PRESS_1:
// Menu_Service(MENU_KEY_CONFIRM_SHORT); Key_Event_Short_Press_Right();
break; break;
case KEY_EVENT_SHORT_PRESS_2: case KEY_EVENT_SHORT_PRESS_2:
// Menu_Service(MENU_KEY_CONFIRM_LONG);
break; break;
case KEY_EVENT_LONG_PRESS_1: //2s case KEY_EVENT_LONG_PRESS_1: //2s
// Menu_Service(MENU_KEY_CONFIRM_SUPER_LONG);
Key_Right_Long_Press_Flag = 1;
break; break;
case KEY_EVENT_LONG_PRESS_2: //3s case KEY_EVENT_LONG_PRESS_2: //3s
break; break;
...@@ -99,7 +61,7 @@ void Key_Operation_Right(Key_Event_en_t enKeyEvent)//Set ...@@ -99,7 +61,7 @@ void Key_Operation_Right(Key_Event_en_t enKeyEvent)//Set
case KEY_EVENT_ON_TO_OFF: case KEY_EVENT_ON_TO_OFF:
break; break;
case KEY_EVENT_NONE: case KEY_EVENT_NONE:
Key_Right_Long_Press_Flag = 0; KEY_RIGHT_EVENT_NONE_Service();
break; break;
default: default:
break; break;
...@@ -111,33 +73,30 @@ void Key_Operation_Right(Key_Event_en_t enKeyEvent)//Set ...@@ -111,33 +73,30 @@ void Key_Operation_Right(Key_Event_en_t enKeyEvent)//Set
Key_Status_en_t Key_Status_Read_Left(void) Key_Status_en_t Key_Status_Read_Left(void)
{ {
Key_Status_en_t enKeyReal = KEY_REALTIME_LOOSEN; Key_Status_en_t enKeyReal = KEY_REALTIME_LOOSEN;
if (SYS_OPR_STAT_IGN_ON) if (RTE_GPIO_Get_Level(KEY_SELECT_MCU))//选择
{
enKeyReal = KEY_REALTIME_PRESS;
}
else
{ {
// if (RTE_GPIO_Get_Level(MODE_P_IN)) enKeyReal = KEY_REALTIME_LOOSEN;
// {
// enKeyReal = KEY_REALTIME_LOOSEN;
// }
// else
// {
// enKeyReal = KEY_REALTIME_PRESS;
// }
} }
return enKeyReal; return enKeyReal;
} }
Key_Status_en_t Key_Status_Read_Right(void) Key_Status_en_t Key_Status_Read_Right(void)
{ {
Key_Status_en_t enKeyReal = KEY_REALTIME_LOOSEN; Key_Status_en_t enKeyReal = KEY_REALTIME_LOOSEN;
if (SYS_OPR_STAT_IGN_ON)
if (RTE_GPIO_Get_Level(KEY_OK_MCU))//确认
{ {
// if (RTE_GPIO_Get_Level(SET_P_IN)) enKeyReal = KEY_REALTIME_PRESS;
// {
// enKeyReal = KEY_REALTIME_LOOSEN;
// }
// else
// {
// enKeyReal = KEY_REALTIME_PRESS;
// }
} }
else
{
enKeyReal = KEY_REALTIME_LOOSEN;
}
return enKeyReal; return enKeyReal;
} }
...@@ -147,8 +106,6 @@ const Key_Attribute_st_t stKeyAttribute[KEY_NUM_MAX] = ...@@ -147,8 +106,6 @@ const Key_Attribute_st_t stKeyAttribute[KEY_NUM_MAX] =
{ {
{KEY_NEED_DEBOUNCE_NORMAL, Key_Status_Read_Left, Key_Operation_Left}, {KEY_NEED_DEBOUNCE_NORMAL, Key_Status_Read_Left, Key_Operation_Left},
{KEY_NEED_DEBOUNCE_NORMAL, Key_Status_Read_Right, Key_Operation_Right}, {KEY_NEED_DEBOUNCE_NORMAL, Key_Status_Read_Right, Key_Operation_Right},
//{KEY_NEED_DEBOUNCE_NORMAL, Key_Status_Read_FLIP, Key_Operation_FLIP},
//{KEY_NEED_DEBOUNCE_NORMAL, Key_Status_Read_ADJUST, Key_Operation_ADJUST},
}; };
/*---------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------*/
...@@ -167,11 +124,13 @@ void Key_KL30_Init_EXample(void) ...@@ -167,11 +124,13 @@ void Key_KL30_Init_EXample(void)
stKeyInitTem.enKeyIGNRealStatus = KEY_IG_OFF; stKeyInitTem.enKeyIGNRealStatus = KEY_IG_OFF;
Key_KL30_Init(&u8KeyRamData[0], stKeyAttribute, &stKeyInitTem); Key_KL30_Init(&u8KeyRamData[0], stKeyAttribute, &stKeyInitTem);
Key_Parameter_Set_Short_Press_1_Time(50U,1000U); Key_Parameter_Set_Short_Press_1_Time(50U,2000U);
Key_Parameter_Set_Short_Press_2_Time(3000U,10000U); Key_Parameter_Set_Short_Press_2_Time(3000U,6000U);
Key_Parameter_Set_Long_Press_1_Time(10000U); Key_Parameter_Set_Long_Press_1_Time(7000U);
Key_Parameter_Set_Long_Press_2_Time(60000U); Key_Parameter_Set_Long_Press_2_Time(8000U);
Key_Parameter_Set_Long_Press_3_Time(9000U);
Key_Parameter_Set_Long_Press_4_Time(10000U);
} }
void Key_Wakeup_Init_EXample(void) void Key_Wakeup_Init_EXample(void)
{ {
...@@ -181,33 +140,163 @@ void Key_Wakeup_Init_EXample(void) ...@@ -181,33 +140,163 @@ void Key_Wakeup_Init_EXample(void)
stKeyInitTem.enKeyIGNRealStatus = KEY_IG_OFF; stKeyInitTem.enKeyIGNRealStatus = KEY_IG_OFF;
Key_Wakeup_Init(&u8KeyRamData[0], stKeyAttribute, &stKeyInitTem); Key_Wakeup_Init(&u8KeyRamData[0], stKeyAttribute, &stKeyInitTem);
Key_Parameter_Set_Short_Press_1_Time(50U,1000U); Key_Parameter_Set_Short_Press_1_Time(50U,2000U);
Key_Parameter_Set_Short_Press_2_Time(3000U,10000U); Key_Parameter_Set_Short_Press_2_Time(3000U,6000U);
Key_Parameter_Set_Long_Press_1_Time(10000U); Key_Parameter_Set_Long_Press_1_Time(7000U);
Key_Parameter_Set_Long_Press_2_Time(60000U); Key_Parameter_Set_Long_Press_2_Time(8000U);
Key_Parameter_Set_Long_Press_3_Time(9000U);
Key_Parameter_Set_Long_Press_4_Time(10000U);
} }
void Key_Check_Service(void) void Key_TimeOut_Service(void)
{ {
PageType = Page_Time_Set_Hour; if((MenuData.Back_Time_Left_Flag == 1)&&(MenuData.Back_Time_Right_Flag == 1))
{
Menu_Service(MENU_KEY_TIMEOUT);
}
} }
void Key_Auto_Save(void) void Key_Auto_Save(void)
{ {
if(PageType == Page_Time_Set_Hour)
{
//RTC_SetTime(&counter_val.time);
}
{
//RTC_SetTime(&counter_val.time);
}
}
void Key_Event_Short_Press_Left(void)//选择
{
if((Menu_Get_Current_Cursor_Information() == MENU_ITEM_DISPLAY_MODE)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_SETTING)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BLUETOOTH_CONNECT)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_SETTING)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_UNIT_SETTING)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_LANGUAGE_SETTING)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_FAULT_INFORMATION)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_PHONE_CONNECT)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_QUIT))
{
Menu_Service(MENU_KEY_RIGHT_SHORT);
}
else
{
if((Menu_Get_Current_Cursor_Information() == MENU_ITEM_SELECT_DAYTIME)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_SELECT_NIGHTTIME)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_SELECT_AUTO)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_5)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_4)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_3)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_2)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_1)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_AUTO)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BLUETOOTH_OPEN)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BLUETOOTH_CLOSE)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BLUETOOTH_SYNC)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BLUETOOTH_BACK)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_HOUR_TENB)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_HOUR_BIT)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_MIN_TENB)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_MIN_BIT)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_BACK)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_UNIT_KM)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_UNIT_MILE)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_LANGUAGE_CHINESE)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_LANGUAGE_ENGLISH))
{
Menu_Service(MENU_KEY_DOWN_SHORT);
}
else
{
if(Menu_Get_Current_Cursor_Information() == MENU_ITEM_MAIN_ITEM)//切换大小计
{
Menu_Service(MENU_KEY_FUNCTION_1_SHORT);
}
}
}
}
void Key_Event_Short_Press_Right(void)//确认
{
if((Menu_Get_Current_Cursor_Information() == MENU_ITEM_MAIN_ITEM)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_DISPLAY_MODE)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_SETTING)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BLUETOOTH_CONNECT)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_SETTING)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_UNIT_SETTING)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_LANGUAGE_SETTING)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_FAULT_INFORMATION)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_PHONE_CONNECT)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_QUIT)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_SELECT_DAYTIME)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_SELECT_NIGHTTIME)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_SELECT_AUTO)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_5)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_4)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_3)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_2)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_1)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_AUTO)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BLUETOOTH_OPEN)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BLUETOOTH_CLOSE)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BLUETOOTH_SYNC)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BLUETOOTH_BACK)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_HOUR_TENB)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_HOUR_BIT)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_MIN_TENB)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_MIN_BIT)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_CLOCK_BACK)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_UNIT_KM)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_UNIT_MILE)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_LANGUAGE_CHINESE)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_LANGUAGE_ENGLISH)||
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_PHONE_CONNECT_WIN))
{ {
RTC_SetTime(&counter_val.time); Menu_Service(MENU_KEY_CONFIRM_SHORT);
} }
}
if(PageType == Page_Time_Set_Minute) void KEY_LEFT_EVENT_NONE_Service(void)
{
MenuData.Back_Time_Left++;
if(MenuData.Back_Time_Left > BACK_MENU_TIME)
{ {
RTC_SetTime(&counter_val.time); MenuData.Back_Time_Left = BACK_MENU_TIME;
MenuData.Back_Time_Left_Flag = 1;
} }
PageType = Page_Time;
} }
void KEY_RIGHT_EVENT_NONE_Service(void)
{
MenuData.Back_Time_Right++;
if(MenuData.Back_Time_Right > BACK_MENU_TIME)
{
MenuData.Back_Time_Right = BACK_MENU_TIME;
MenuData.Back_Time_Right_Flag = 1;
}
}
void Key_Clear_Time(void)
{
if(Key_Status_Read_Left() == KEY_REALTIME_PRESS)
{
MenuData.Back_Time_Left = 0;
MenuData.Back_Time_Left_Flag = 0;
MenuData.Back_Time_Right_Flag = 0;
}
if(Key_Status_Read_Right() == KEY_REALTIME_PRESS)
{
MenuData.Back_Time_Right = 0;
MenuData.Back_Time_Left_Flag = 0;
MenuData.Back_Time_Right_Flag = 0;
}
}
uint8_t ClearODO_Flag = 0; uint8_t ClearODO_Flag = 0;
void TYW_RESET_ODO(void) void TYW_RESET_ODO(void)
...@@ -229,6 +318,8 @@ void TYW_RESET_ODO(void) ...@@ -229,6 +318,8 @@ void TYW_RESET_ODO(void)
} }
} }
uint8_t Get_Dis_Hour_Time(void) uint8_t Get_Dis_Hour_Time(void)
{ {
return counter_val.time.RTC_Hours; return counter_val.time.RTC_Hours;
...@@ -239,11 +330,6 @@ uint8_t Get_Dis_Minute_Time(void) ...@@ -239,11 +330,6 @@ uint8_t Get_Dis_Minute_Time(void)
return counter_val.time.RTC_Minutes; return counter_val.time.RTC_Minutes;
} }
uint8_t Get_Current_PageType(void)
{
return PageType;
}
uint8_t Get_Dis_Unit(void) uint8_t Get_Dis_Unit(void)
{ {
return MenuData.Unit; //0km,1mile return MenuData.Unit; //0km,1mile
......
...@@ -32,36 +32,20 @@ typedef enum ...@@ -32,36 +32,20 @@ typedef enum
typedef struct typedef struct
{ {
uint16_t Back_Time_Left;
uint16_t Back_Time_Right;
uint8_t Back_Time_Right_Flag;
uint8_t Back_Time_Left_Flag;
uint8_t Set_Hour; uint8_t Set_Hour;
uint8_t Set_Minute; uint8_t Set_Minute;
uint8_t Dis_Hour; uint8_t Dis_Hour;
uint8_t Dis_Minute; uint8_t Dis_Minute;
uint8_t Unit; uint8_t Unit;
uint8_t Language;
}_Menu_Data; }_Menu_Data;
typedef enum
{
Page_Time = 0,
Page_Time_Set_Hour,
Page_Time_Set_Minute,
Page_Max,
}_Page_Type;
extern uint8_t PageType;
extern uint8_t Key_Right_Long_Press_Flag;
extern uint8_t Key_Left_Long_Press_Flag;
extern uint8_t ClearODO_Flag; extern uint8_t ClearODO_Flag;
// extern uint8_t g_u8Menu_Grade;
extern uint8_t g_u8Cursor_Posittion; extern uint8_t g_u8Cursor_Posittion;
extern uint8_t g_u8Language;
extern uint8_t g_u8Theme;
extern uint8_t g_u8Blue;
extern uint8_t g_u8DVR_Set;
extern uint8_t g_u8Formatting;
extern uint8_t g_u8Factory;
extern _Menu_Infor MenuInfor;
extern RTC_CounterTypeDef counter_val; extern RTC_CounterTypeDef counter_val;
extern void Key_KL30_Init_EXample(void); extern void Key_KL30_Init_EXample(void);
extern void Key_Wakeup_Init_EXample(void); extern void Key_Wakeup_Init_EXample(void);
...@@ -70,13 +54,15 @@ void Key_Operation_Right(Key_Event_en_t enKeyEvent); ...@@ -70,13 +54,15 @@ void Key_Operation_Right(Key_Event_en_t enKeyEvent);
void Key_Operation_Left(Key_Event_en_t enKeyEvent); void Key_Operation_Left(Key_Event_en_t enKeyEvent);
Key_Status_en_t Key_Status_Read_Left(void); Key_Status_en_t Key_Status_Read_Left(void);
Key_Status_en_t Key_Status_Read_Right(void); Key_Status_en_t Key_Status_Read_Right(void);
void Key_Event_Short_Press_Left(void);
void Key_Event_Short_Press_Right(void);
void KEY_RIGHT_EVENT_NONE_Service(void);
void KEY_LEFT_EVENT_NONE_Service(void);
void Key_Auto_Save(void); void Key_Auto_Save(void);
uint8_t Get_Dis_Hour_Time(void); uint8_t Get_Dis_Hour_Time(void);
uint8_t Get_Dis_Minute_Time(void); uint8_t Get_Dis_Minute_Time(void);
uint8_t Get_Current_PageType(void);
void TYW_RESET_ODO(void); void TYW_RESET_ODO(void);
uint8_t Get_Dis_Unit(void); uint8_t Get_Dis_Unit(void);
void Key_Check_Service(void); void Key_TimeOut_Service(void);
void Key_Clear_Time(void);
#endif #endif
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