Commit 1b87c8ef authored by 何锐's avatar 何锐

feat:增加读写UUID功能

parent 945a3bb5
......@@ -49,6 +49,7 @@ uint8_t get_num_buf[34];
uint8_t comparestart;
uint8_t blename[5];
uint8_t btmac[6];
uint8_t uidread[33];
uint8_t firstpowerflag = 0;
uint16_t lightnumber = 0;
uint8_t writeflag = 0;
......@@ -140,6 +141,11 @@ void datacheck(void)
recvflag111 = 1;
RS485_TX_finish = 0;
// General_Number_Disp(blename, 3, 165);
for(int i = 0; i<32; i++)
{
uidread[i] = BarCode[i+17];
}
uidread[32] = 0xFF;
}
break;
case 0x4F:
......
......@@ -38,5 +38,6 @@ extern uint8_t recvflag111;
extern uint8_t firstpowerflag;
extern uint16_t lightnumber;
extern uint8_t btmac[6];
extern uint8_t uidread[33];
extern uint8_t writeflag;
#endif
\ No newline at end of file
......@@ -11,7 +11,14 @@
#include "TimerB.h"
#include "Analog_Signals.h"
#include "FreIn_User.h"
// clang-format off
#define UUID1_EFFECT_LEN 12 // uuidnumber1前12个有效元素
#define UUID2_EFFECT_LEN 20 // uuidnumber2前20个有效元素
#define UUID1_MSG_START 11 // uuidnumber1在R485消息中的起始位置
#define UUID2_MSG_START 23 // uuidnumber2在R485消息中的起始位置
#define CRC_MSG_POS 43 // CRC校验结果在R485消息中的位置
uint32_t Display_Menu_Type;
uint32_t Page_Refresh = 1;
uint32_t PageNum_history = 0xff;
......@@ -124,6 +131,29 @@ const unsigned char gImage_Dyy_words_2X6_Y46[]={/*Byte Size204*/
0X08U,0X00U,0X00U,0X18U,0X38U,0X38U,0X10U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,
0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,
0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,};
//:UID写入:
const unsigned char gImage_Dyy_words_3X6_Y75UID[]={/*Byte Size126*/
62U,16U,
0X10U,0Xf0U,0X10U,0X00U,0X10U,0Xf0U,0X10U,0X00U,0X10U,0Xf0U,0X10U,0X00U,0X10U,0Xf0U,0X10U,0X00U,
0X10U,0X10U,0Xf0U,0X10U,0X10U,0X00U,0X10U,0Xf0U,0X10U,0X10U,0X10U,0X20U,0Xc0U,0X00U,0X0cU,0X04U,
0X84U,0X74U,0X24U,0X24U,0X24U,0X24U,0X24U,0X24U,0X24U,0X04U,0X0cU,0X00U,0X00U,0X00U,0X00U,0X00U,
0X02U,0XccU,0X30U,0Xc0U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X00U,0X80U,0X80U,0X00U,0X1fU,
0X20U,0X20U,0X20U,0X1fU,0X00U,0X00U,0X00U,0X1fU,0X20U,0X20U,0X20U,0X1fU,0X00U,0X00U,0X20U,0X20U,
0X3fU,0X20U,0X20U,0X00U,0X20U,0X3fU,0X20U,0X20U,0X20U,0X10U,0X0fU,0X00U,0X08U,0X08U,0X09U,0X09U,
0X09U,0X09U,0X09U,0X09U,0X09U,0X49U,0X41U,0X3fU,0X00U,0X00U,0X40U,0X20U,0X10U,0X0cU,0X03U,0X00U,
0X00U,0X00U,0X03U,0X0cU,0X10U,0X20U,0X40U,0X00U,0X00U,0X00U,0X31U,0X31U,};
//UID读取
const unsigned char gImage_Dyy_words_3X6_Y75UIDRead[]={/*Byte Size130*/
64U,16U,
0X10U,0Xf0U,0X10U,0X00U,0X10U,0Xf0U,0X10U,0X00U,0X10U,0Xf0U,0X10U,0X00U,0X10U,0Xf0U,0X10U,0X00U,
0X10U,0X10U,0Xf0U,0X10U,0X10U,0X00U,0X10U,0Xf0U,0X10U,0X10U,0X10U,0X20U,0Xc0U,0X00U,0X00U,0X40U,
0X42U,0XccU,0X00U,0X20U,0X28U,0X68U,0Xa8U,0X3eU,0Xa8U,0X28U,0Xa8U,0X60U,0X00U,0X04U,0XfcU,0X24U,
0X24U,0XfcU,0X04U,0X08U,0Xf8U,0X08U,0X08U,0X08U,0Xf8U,0X00U,0X00U,0X00U,0X00U,0X80U,0X80U,0X00U,
0X00U,0X1fU,0X20U,0X20U,0X20U,0X1fU,0X00U,0X00U,0X00U,0X1fU,0X20U,0X20U,0X20U,0X1fU,0X00U,0X00U,
0X20U,0X20U,0X3fU,0X20U,0X20U,0X00U,0X20U,0X3fU,0X20U,0X20U,0X20U,0X10U,0X0fU,0X00U,0X00U,0X00U,
0X00U,0X3fU,0X10U,0X04U,0X45U,0X26U,0X14U,0X0cU,0X07U,0X14U,0X64U,0X04U,0X00U,0X08U,0X0fU,0X09U,
0X09U,0X7fU,0X04U,0X44U,0X20U,0X13U,0X0cU,0X13U,0X20U,0X40U,0X00U,0X00U,0X00U,0X31U,0X31U,0X00U,
};
//零件号:
const unsigned char gImage_Dyy_words_3X6_Y75[]={/*Byte Size204*/
101U,16U,
......@@ -2872,6 +2902,11 @@ void Display_TFT_Clear(void)
TFT_LCD_Draw_Box(0, 0, 239, 319, TFT_LCD_FILL_FULL, TFT_LCD_TYPE_CLR);
}
void Display_TFT_Clear_UID(void)
{
TFT_LCD_Draw_Box(0, 100, 239, 120, TFT_LCD_FILL_FULL, TFT_LCD_TYPE_CLR);
}
void Display_Add(void)
{
Display_Menu_Type++;
......@@ -3622,6 +3657,47 @@ void Check_PWM(void)
uint32_t test = Duty_VEHICLE / 10;
GUI_General_Digit_Display(test, Num_15, 3, 1, testNum, 160);
}
void uuidnumber2_increment_with_carry(void)
{
for(uint8_t i = 19; i > 1; i--)
{
if(uuidnumber2[i] < 0x39)
{
uuidnumber2[i] += 1;
return;
}
else
{
uuidnumber2[i] = 0x30;
}
}
}
uint8_t uuidnumber1[UUID1_EFFECT_LEN + 1] = {0x54,0x59,0x57,0x31,0x39,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xFF};
uint8_t uuidnumber2[UUID2_EFFECT_LEN + 1] = {0x32,0x30,0x32,0x35,0x30,0x35,0x31,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x39,0xFF};
uint8_t uuidmodel = 0;
void UUID_Write(void)
{
uint16_t uuidcrc = 0;
uint8_t i;
memcpy(&R485_0x80_msg[UUID1_MSG_START], uuidnumber1, UUID1_EFFECT_LEN);
memcpy(&R485_0x80_msg[UUID2_MSG_START], uuidnumber2, UUID2_EFFECT_LEN);
for (i = 0; i < UUID1_EFFECT_LEN; i++)
{
uuidcrc += uuidnumber1[i];
}
for (i = 0; i < UUID2_EFFECT_LEN; i++)
{
uuidcrc += uuidnumber2[i];
}
R485_0x80_msg[CRC_MSG_POS] = uuidcrc & 0xFF;
uuidnumber2_increment_with_carry();
}
uint8_t UUIDX = 190;
uint8_t change = 19;
uint32_t leftvoltage;
uint32_t rightvoltage;
uint8_t firstclearflag = 0;
......@@ -3653,7 +3729,20 @@ void Display_Version_Info(uint32_t ON_OFF)
}
else
{
if(uuidmodel == 1)
{
// uuidnumber[33] = 0xFF;
TFT_LCD_Draw_Bmp(3, 25, ( uint8_t * )gImage_Dyy_words_3X6_Y75UID ); //写入UID
General_Number_Disp(uuidnumber1,3, 50);
General_Number_Disp(uuidnumber2,3, 75);
uint8_t UUIDS[2] = {45,0xFF};
General_Number_Disp(UUIDS, UUIDX, 92); //UID下——
TFT_LCD_Draw_Bmp(3, 125, ( uint8_t * )gImage_Dyy_words_3X6_Y75UIDRead ); //读取UID
General_Number_Disp(uidread,3, 150);
}
else
{
if( loc_Type_back != loc_Type )
{
Display_TFT_Clear();
......@@ -3715,8 +3804,8 @@ void Display_Version_Info(uint32_t ON_OFF)
if(R485_ID4Dh.Sig.MaterialCode13 == 0x32)
{
nowbanbenhao = 2;
nowbanbenhaohoumian = 30;
nowbanbenhao = 1;
nowbanbenhaohoumian = 33;
}
else if(R485_ID4Dh.Sig.MaterialCode13 == 0x35)
{
......@@ -3775,27 +3864,27 @@ void Display_Version_Info(uint32_t ON_OFF)
}
TFT_LCD_Draw_Bmp(3, 90+25+25+30+30+30+5, ( uint8_t * )gImage_gImage_LEDwaif1X6_Y16 ); //硬线指示灯外发对比
TFT_LCD_Draw_Bmp(3, 90+25+25+30+25+30+30+5, ( uint8_t * )gImage_gImage_SV1X6_Y16 ); //软件版本号对比
if((R485_ID4Dh.Sig.ESP322 != 0) && ( R485_ID4Dh.Sig.G0312 != 0))
{
if((nowbanbenhao == R485_ID4Dh.Sig.ESP322) && (nowbanbenhaohoumian == R485_ID4Dh.Sig.ESP321) && (nowbanbenhao == R485_ID4Dh.Sig.G0312) && (nowbanbenhaohoumian == R485_ID4Dh.Sig.G0311))
{
TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_dui ); //软件版本号对比 对
firstpowerflag = 2;
}
else
{
TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_cuo ); //软件版本号对比 错
firstpowerflag = 3;
MENU_CHECK_STEP = 0;
//正在调试取消版本号对比 想要取消版本号对比将上方注释掉并解开下方注释即可
// if((R485_ID4Dh.Sig.ESP322 != 0) && ( R485_ID4Dh.Sig.G0312 != 0))
// {
// if((nowbanbenhao == R485_ID4Dh.Sig.ESP322) && (nowbanbenhaohoumian == R485_ID4Dh.Sig.ESP321) && (nowbanbenhao == R485_ID4Dh.Sig.G0312) && (nowbanbenhaohoumian == R485_ID4Dh.Sig.G0311))
// {
// TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_dui ); //软件版本号对比 对
// firstpowerflag = 2;
}
}
else
{
MENU_CHECK_STEP = 0;
}
// }
// else
// {
// TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_cuo ); //软件版本号对比 错
// firstpowerflag = 3;
// MENU_CHECK_STEP = 0;
// //正在调试取消版本号对比 想要取消版本号对比将上方注释掉并解开下方注释即可
// // TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+30+30, ( uint8_t * )gImage_dui ); //软件版本号对比 对
// // firstpowerflag = 2;
// }
// }
// else
// {
// MENU_CHECK_STEP = 0;
// }
// TFT_LCD_Draw_Bmp(200, 90+25+25+30+25+25, ( uint8_t * )gImage_cuo ); //软件版本号对比 错
// TFT_LCD_Draw_Bmp(3, 90+25+25+25+25+25, ( uint8_t * )gImage_gImage_SV1X6_Y16 ); //支持扫码功能个
// TFT_LCD_Draw_Bmp(3, 130, ( uint8_t * )gImage_Dyy_words_4X6_Y107); //供应商编码
......@@ -3813,10 +3902,11 @@ void Display_Version_Info(uint32_t ON_OFF)
// TFT_LCD_Draw_Bmp(3, 160, ( uint8_t * )gImage_Alarm_12_WordX6_Y165); //24脚输出占空比
// TFT_LCD_Draw_Bmp(210, 160, ( uint8_t * )gImage_Alarm_13_ImageX222_Y166); //%
TFT_LCD_Draw_Bmp(3, 290, ( uint8_t * )gImage_gImage_checkVX6_Y165 ); //检测台版本号
uint8_t mbuff [7] = {2,5,0,7,0,3,0xff};
uint8_t mbuff [7] = {2,5,1,0,0,7,0xff};
General_Number_Disp(mbuff, 160, 290);
}
}
}
......
......@@ -49,6 +49,9 @@ enum DisplayFont
extern unsigned int Display_Menu_Type;
extern uint32_t odo_val_Back ;
extern uint8_t uuidmodel;
extern uint8_t UUIDX;
extern uint8_t change;
void GeneralInfoDisp(unsigned char *p, unsigned short x, unsigned short y);
void Display_Title_Info(void);
void Display_Version_Info(uint32_t ON_OFF);
......@@ -56,6 +59,7 @@ void Display_Version_Info(uint32_t ON_OFF);
extern void HW_Static_Current_Check(uint32_t cmd);
void HW_Voltage_Check(uint32_t cmd);
void Display_TFT_Clear(void);
void Display_TFT_Clear_UID(void);
void Display_Add(void);
unsigned int Get_Display_Type(void);
void General_Number_Disp(unsigned char *p, unsigned short x, unsigned short y);
......@@ -77,7 +81,7 @@ void Buzzer_Start(void);
void Buzzer_Stop(void);
extern void Buzzer_Init(void);
extern void Buzzer_Warning(void);
extern void UUID_Write(void);
void GUI_General_Digit_Display(uint32_t Digit, const uint8_t *Font[], uint8_t Len, uint8_t Blank, const uint16_t *px, uint16_t y);
......@@ -90,7 +94,7 @@ extern const uint8_t *Num_09[];
extern const uint8_t *Num_10_03[];
extern const uint8_t *Num_13[];
extern const uint8_t *Num_30[];
extern uint8_t uuidnumber2[21];
extern const uint8_t * Letter_Num_11[];
extern uint32_t loc_Current_0;
......
......@@ -5,26 +5,32 @@
#include "Barcode_Scanner.h"
#include "Task.h"
#include "string.h"
#define R485_CLEAR_START 11 // 起始索引
#define R485_CLEAR_LEN 33 // 清零长度(元素个数)
void Key_Operation_SW5(Key_Event_en_t enKeyEvent)
{
if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
{
// if ( (LED_Waring == 1) || (UDS_Warning_Voltage ==1))
// {
// ;
// }
// else
// {
// Display_Add( );
// Display_TFT_Clear( );
// }
if(uuidmodel == 0)
{
if(firstpowerflag == 2)
{
MENU_CHECK_STEP_ADD( );
}
}
else
{
if(uuidnumber2[change] < 0x39)
{
uuidnumber2[change]++;
}
else
{
uuidnumber2[change] = 0x30;
}
}
}
else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
{
......@@ -41,42 +47,37 @@ void Key_Operation_SW5(Key_Event_en_t enKeyEvent)
}
}
}
// else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
// {
// if ( (LED_Waring == 1) || (UDS_Warning_Voltage ==1))
// {
// ;
// }
// else
// {
// Display_Add( );
// Display_TFT_Clear( );
// }
// }
else
{
}
}
void Key_Operation_SW4(Key_Event_en_t enKeyEvent)
{
if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
{
// if ( (LED_Waring == 1) || (UDS_Warning_Voltage ==1))
// {
// ;
// }
// else
// {
// Display_Sub( );
// Display_TFT_Clear( );
// }
if(uuidmodel == 0)
{
if(firstpowerflag == 2)
{
MENU_CHECK_STEP_SUB();
}
}
else
{
Display_TFT_Clear_UID();
if(UUIDX > 0)
{
UUIDX -= 10;
change--;
}
else
{
change = 19;
UUIDX = 190;
}
}
}
else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
{
......@@ -183,6 +184,17 @@ void Key_Operation_SW2(Key_Event_en_t enKeyEvent)
}
else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
{
if(firstpowerflag == 2)
{
if(Auto_ONOFF != 0)
{
Auto_ONOFF = 0;
}
else
{
Auto_ONOFF = 1;
}
}
}
else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
{
......@@ -233,21 +245,18 @@ void Key_Operation_SW1(Key_Event_en_t enKeyEvent)
/*清零ODO*/
if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
{
if(firstpowerflag == 2)
{
if(Auto_ONOFF != 0)
if(uuidmodel == 1)
{
Auto_ONOFF = 0;
UUID_Write();
}
else
{
Auto_ONOFF = 1;
}
}
uuidmodel = 1;
Display_TFT_Clear();
}
else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
{
uuidmodel = 0;
Display_TFT_Clear();
memset(&R485_0x80_msg[R485_CLEAR_START], 0, R485_CLEAR_LEN);
}
else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
{
......
......@@ -631,14 +631,14 @@ void Sys_Exact_100ms_Tasks(void)
startIGONtime++;
if(startIGONtime % 20 == 0)
{
if(R485_0x80_msg[11] < 5)
{
R485_0x80_msg[11]++;
}
else
{
R485_0x80_msg[11] = 0;
}
// if(R485_0x80_msg[11] < 5)
// {
// R485_0x80_msg[11]++;
// }
// else
// {
// R485_0x80_msg[11] = 0;
// }
}
}
......@@ -653,16 +653,16 @@ void Sys_Exact_100ms_Tasks(void)
clearodotimeflash++;
if (clearodotimeflash % 20 == 0)
{
if (R485_0x80_msg[11] < 5)
{
R485_0x80_msg[11]++;
R485_0x80_msg[10]++;
}
else
{
R485_0x80_msg[11] = 0;
R485_0x80_msg[10] = 0;
}
// if (R485_0x80_msg[11] < 5)
// {
// R485_0x80_msg[11]++;
// R485_0x80_msg[10]++;
// }
// else
// {
// R485_0x80_msg[11] = 0;
// R485_0x80_msg[10] = 0;
// }
}
// CHECK_IPK_COUNT( );
}
......
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