Commit b0b15f8a authored by 何锐's avatar 何锐

feat:完成菜单控制

parent 2a845a0a
......@@ -57,6 +57,7 @@
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false,
"files.associations": {
"string.h": "c"
"string.h": "c",
"can_communication_matrix.h": "c"
}
}
\ No newline at end of file
......@@ -68,6 +68,63 @@ uint8_t recvflag111 = 0;
uint8_t xierucishu = 0;
uint8_t waittimer;
uint8_t saomafinish;
uint8_t Autoheadlightstatustime;
uint8_t Autoheadlightstatuslast;
uint8_t RampStopSettime;
uint8_t RampStopSetlast;
uint8_t TCSSettime;
uint8_t TCSSetlast;
uint8_t Sendcontinuouslytime;
uint8_t Sendcontinuouslylast;
uint8_t steepslopetime;
uint8_t steepslopelast;
void ProcessVehicleStatus(void)
{
typedef struct {
uint8_t currentValue;
uint8_t* lastValue;
uint8_t* counter;
uint8_t* flag;
} StatusCheck_t;
StatusCheck_t statusChecks[] = {
{R485_IDD4h.Sig.SideStaySenseSetInstructTX, &Sendcontinuouslylast, &Sendcontinuouslytime, &SideStayflag},
{R485_IDD4h.Sig.SlopeDropSetInstructTX, &steepslopelast, &steepslopetime, &SlopeDescentflag},
{R485_IDD4h.Sig.RampStopSetInstructTX, &RampStopSetlast, &RampStopSettime, &RampParkflag},
{R485_IDD4h.Sig.TCSSetInstructTX, &TCSSetlast, &TCSSettime, &TCSflag},
{R485_IDD4h.Sig.Autoheadlightstatus, &Autoheadlightstatuslast, &Autoheadlightstatustime, &Autoheadlightflag}
};
for (int i = 0; i < sizeof(statusChecks)/sizeof(statusChecks[0]); i++)
{
StatusCheck_t check = statusChecks[i];
if (check.currentValue == 1 || check.currentValue == 0)
{
if(*check.lastValue == check.currentValue)
{
(*check.counter)++;
}
else
{
if(*check.counter == 1)
{
*check.counter = 1;
}
*check.counter = 1;
*check.lastValue = check.currentValue;
}
}
if (*check.counter >= 3)
{
*check.counter = 0;
*check.flag = (*check.lastValue == 1) ? 1 : 0;
}
}
}
void datacheck(void)
{
uint16_t checksum = 0;
......@@ -91,6 +148,11 @@ void datacheck(void)
}
switch (BarCode[2]) //ID
{
case 0xD4:
memcpy(R485_IDD4h.Msg,RS485_data,RS485_RX_ID0XD4_DATA_LEN);
ProcessVehicleStatus();
break;
case 0xB4:
memcpy(R485_IDB4h.Msg,RS485_data,RS485_RX_ID0XB4_DATA_LEN);
checksum = Yadi_CAL_Data_Sum(&BarCode[2], 64 + 2);
......@@ -98,6 +160,8 @@ void datacheck(void)
{
;
}
break;
case 0x81: //81接收mac地址
{
if((BarCode[72] == 0x4A) && (BarCode[71] == 0x4B))
......
......@@ -398,7 +398,7 @@ uint8_t yibiaoshuju[34];
// // Function_Check_Ctrl(1); //Excel表格发报文。硬线信号
// //FUEL_UDS__Display(3);
// Buzzer_Warning();
// break;
break;
// case 4:
......
......@@ -94,6 +94,7 @@ extern const uint8_t *Num_30[];
extern const uint8_t * Letter_Num_11[];
extern uint32_t loc_Current_0;
extern uint8_t menumondel;
extern void Get_static_Current(void);
extern uint32_t Get_Display_Type(void);
extern uint8_t guangganflag;
......
......@@ -210,7 +210,15 @@ void Key_Operation_SW6(Key_Event_en_t enKeyEvent)
}
else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
{
if(menumondel == 0)
{
menumondel = 1;
Display_TFT_Clear();
}
else
{
menumondel = 0;
}
}
else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
{
......
......@@ -2,6 +2,7 @@
#include "Barcode_Scanner.h"
#include "string.h"
#include "Key.h"
#include "Display_Info.h"
uint8_t barcode_Msg[64];
uint8_t barcode_Msg1[64];
uint8_t name1 = 0;
......@@ -182,6 +183,19 @@ uint32_t R485_Send_0xD1(void)
uint8_t RampParkedStatecounter = 0; //红色闪烁两次
uint8_t SideStayflag;
uint8_t TCSflag;
uint8_t SlopeDescentflag;
uint8_t RampParkflag;
uint8_t Autoheadlightflag;
void menuFeedbackinit(void)
{
SideStayflag = 0;
TCSflag = 0;
SlopeDescentflag = 0;
RampParkflag = 0;
Autoheadlightflag = 0;
}
uint32_t R485_Send_0xD2(void)
{
memset(R485_IDD2h.Msg, 0xFF, 36);
......@@ -191,6 +205,42 @@ uint32_t R485_Send_0xD2(void)
R485_IDD2h.Sig.BrakeSwitchFeedback = 0x00; //ready灯熄灭
if(SideStayflag == 0)
{
R485_IDD2h.Sig.SideStaySenseSetFeedback = 0x00; //菜单边撑感应功能设置反馈功能
}
else if(SideStayflag == 1)
{
R485_IDD2h.Sig.SideStaySenseSetFeedback = 0x01; //菜单边撑感应功能设置反馈功能
}
if(TCSflag == 0)
{
R485_IDD2h.Sig.TCSDefined = 0x00; //菜单TCS功能设置反馈功能
}
else if(TCSflag == 1)
{
R485_IDD2h.Sig.TCSDefined = 0x01; //菜单TCS功能设置反馈功能
}
if(SlopeDescentflag == 0)
{
R485_IDD2h.Sig.SlopeDescentFunctionStatus = 0x00; //菜单陡坡缓降功能设置反馈功能
}
else if(SlopeDescentflag == 1)
{
R485_IDD2h.Sig.SlopeDescentFunctionStatus = 0x01; //菜单陡坡缓降功能设置反馈功能
}
if(RampParkflag == 0)
{
R485_IDD2h.Sig.RampParkedSetFeedback = 0x00; //菜单边撑感应功能设置反馈功能
}
else if(RampParkflag == 1)
{
R485_IDD2h.Sig.RampParkedSetFeedback = 0x01; //菜单边撑感应功能设置反馈功能
}
if(clearOdoFlag == 0)
{
switch (MENU_CHECK_STEP)
......@@ -447,7 +497,7 @@ uint32_t R485_Send_0xD3(void)
memset(R485_IDD3h.Msg, 0xFF, 26);
uint32_t u32sendendflag = 0;
R485_IDD3h.Sig.AutoheadLightSetting = 0x00; //自动大灯
// R485_IDD3h.Sig.AutoheadLightSetting = 0x00; //自动大灯
R485_IDD3h.Sig.BlueToothPair = 0x00; //经典蓝牙配对指令
......@@ -475,12 +525,12 @@ uint32_t R485_Send_0xD3(void)
switch (MENU_CHECK_STEP)
{
case 2:
R485_IDD3h.Sig.AutoheadLightSetting = 0x00; //自动大灯
// R485_IDD3h.Sig.AutoheadLightSetting = 0x00; //自动大灯
R485_IDD3h.Sig.ElectronicCushionStatus = 0x01; //座桶开启灯
break;
case 3:
R485_IDD3h.Sig.AutoheadLightSetting = 0x00; //自动大灯
// R485_IDD3h.Sig.AutoheadLightSetting = 0x00; //自动大灯
R485_IDD3h.Sig.RemainingMileageDisSetting = 0; //续航里程
R485_IDD3h.Sig.SupportSwitchState = 0x01; //边撑状态
......@@ -488,7 +538,7 @@ uint32_t R485_Send_0xD3(void)
break;
case 4:
R485_IDD3h.Sig.AutoheadLightSetting = 0x00; //自动大灯
// R485_IDD3h.Sig.AutoheadLightSetting = 0x00; //自动大灯
R485_IDD3h.Sig.RemainingMileageDisSetting = 1; //续航里程
......@@ -502,7 +552,7 @@ uint32_t R485_Send_0xD3(void)
break;
case 6:
R485_IDD3h.Sig.AutoheadLightSetting = 0x01; //自动大灯
// R485_IDD3h.Sig.AutoheadLightSetting = 0x01; //自动大灯
if(KeyStep == 3)
{
......@@ -523,7 +573,7 @@ uint32_t R485_Send_0xD3(void)
case 9:
R485_IDD3h.Sig.SupportSwitchState = 0x01; //边撑状态
R485_IDD3h.Sig.AutoheadLightSetting = 0x01; //自动大灯
// R485_IDD3h.Sig.AutoheadLightSetting = 0x01; //自动大灯
R485_IDD3h.Sig.ElectronicCushionStatus = 0x01; //座桶开启灯
break;
......@@ -534,7 +584,7 @@ uint32_t R485_Send_0xD3(void)
R485_IDD3h.Sig.SupportSwitchState = 0x00; //边撑状态
R485_IDD3h.Sig.ElectronicCushionStatus = 0x00; //座桶开启灯
R485_IDD3h.Sig.AutoheadLightSetting = 0x00; //自动大灯
// R485_IDD3h.Sig.AutoheadLightSetting = 0x00; //自动大灯
break;
}
}
......@@ -640,10 +690,29 @@ uint32_t R485_Send_0xA4(void)
R485_IDA4h.Sig.Invalid_characters = 0x01;
uint32_t u32sendendflag = 0;
if(menumondel == 0)
{
u32sendendflag = R485_Send(0xA4, R485_IDA4h.Msg, sizeof(R485_IDA4h.Msg));
}
else if(menumondel == 1)
{
u32sendendflag = R485_Send(0xC4, R485_IDA4h.Msg, sizeof(R485_IDA4h.Msg));
}
return u32sendendflag;
}
uint32_t R485_Send_0xC4(void) //菜单设置收发
{
memset(R485_IDC4h.Msg, 0xFF, 1);
R485_IDC4h.Sig.Invalid_characterssecond = 0x01;
uint32_t u32sendendflag = 0;
u32sendendflag = R485_Send(0xC4, R485_IDC4h.Msg, sizeof(R485_IDC4h.Msg));
return u32sendendflag;
}
uint32_t R485_Send_0x41(void)
{
/**************0.437*********** */
......
......@@ -16,10 +16,10 @@
#define RS485_RX_ID0XB6_DATA_LEN 86
#define RS485_RX_ID0XD6_DATA_LEN 111
#define RS485_RX_ID0XA4_DATA_LEN 1
#define RS485_RX_ID0XC4_DATA_LEN 4
#define RS485_RX_ID0XC4_DATA_LEN 1
#define RS485_RX_ID0XB4_DATA_LEN 75
#define RS485_RX_ID0XD4_DATA_LEN 14
#define RS485_RX_ID0XD4_DATA_LEN 17
typedef union
{
uint8_t Msg[64];
......@@ -1244,8 +1244,19 @@ typedef union __attribute__((packed))
uint8_t ABSOLStatus : 1; // ABS在线状态
uint8_t : 5;
uint8_t UserPasswordL : 8; // 用户输入密码值_L
uint8_t UserPasswordH : 8; // 用户输入密码值_H
uint16_t UserPassword :16; // 用户输入密码值
/*--byte14--*/
uint8_t : 8;
uint8_t SideStaySenseSetInstructTX :2; /*边撑感应功能设置指令*/
uint8_t SlopeDropSetInstructTX :2; /*陡坡缓降功能设置指令*/
uint8_t RampStopSetInstructTX :2; /*坡道驻停功能设置指令*/
uint8_t TCSSetInstructTX :2; /*TCS功能设置指令*/
uint8_t CushionSenseSetInstructTX :2; /*座垫感应功能设置指令*/
uint8_t :6;
}Sig;
} _ID0XD4h_Data;
......@@ -1263,6 +1274,15 @@ typedef union __attribute__((packed))
}Sig;
} _ID0XA4h_Data;
typedef union __attribute__((packed))
{
uint8_t Msg[RS485_RX_ID0XC4_DATA_LEN];
struct
{
uint8_t Invalid_characterssecond : 8;
}Sig;
} _ID0XC4h_Data;
typedef union __attribute__((packed))
{
uint8_t Msg[RS485_RX_ID0XD0_DATA_LEN];
......@@ -1917,6 +1937,7 @@ extern _ID0XD6h_Data R485_IDD6h;
extern _ID0XB4h_Data R485_IDB4h;
extern _ID0XD4h_Data R485_IDD4h;
extern _ID0XA4h_Data R485_IDA4h;
extern _ID0XC4h_Data R485_IDC4h;
extern uint8_t zhenduansendStep;
extern uint32_t R485_Send_0x40(void);
......@@ -1943,13 +1964,22 @@ extern uint32_t R485_Send_0xD1(void);
extern uint32_t R485_Send_0xD2(void);
extern uint32_t R485_Send_0xD3(void);
extern uint32_t R485_Send_0xA4(void);
extern uint32_t R485_Send_0xC4(void);
// extern uint32_t R485_Send_0x80(void);
extern uint32_t R485_Send_0x04(void);
extern void menuFeedbackinit(void);
extern uint8_t barcode_Msg[64];
extern uint8_t barcode_Msg1[64];
extern uint8_t name1;
extern uint8_t name2;
extern uint8_t R485_0x80_msg[64];
extern uint8_t SideStayflag;
extern uint8_t TCSflag;
extern uint8_t SlopeDescentflag;
extern uint8_t RampParkflag;
extern uint8_t Autoheadlightflag;
extern uint8_t mimayanzhengjieguo;
#endif
......@@ -56,6 +56,7 @@ LineSta LineGetSta;
_ID0XB4h_Data R485_IDB4h;
_ID0XD4h_Data R485_IDD4h;
_ID0XA4h_Data R485_IDA4h;
_ID0XC4h_Data R485_IDC4h;
void R485_TX_Init(void)
{
......@@ -424,6 +425,8 @@ uint8_t RS485_User_Tx_Data(void)
}
break;
case RS485_Tx_IDD0_Idx:
sendfinishflag = R485_Send_0xD0();
RS485_TX_finish = 1;
......
......@@ -83,6 +83,7 @@ void Sys_Startup_Init(void)
Key_Init( );
Buzzer_Init();
Fre_In_KL30_Wakeup_Init();
menuFeedbackinit();
UART_Channel_Config_st_t loc_config;
loc_config.enUARTLINMode = MODE_UART;
loc_config.u32UARTbps = 115200;
......
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