diff --git a/HAL_N_Middlewares/Src/main.c b/HAL_N_Middlewares/Src/main.c index 101809e..d1be4f8 100644 --- a/HAL_N_Middlewares/Src/main.c +++ b/HAL_N_Middlewares/Src/main.c @@ -134,13 +134,13 @@ int main(void) Elliptical_Draw(&graph[3],"s3",UI_Graph_ADD,0,UI_Color_Orange,3,960,540,100,20); Arc_Draw(&graph[4],"s4",UI_Graph_ADD,0,UI_Color_Purplish_red,30,160,3,1200,550,50,100); - Float_Draw(&num[0],"s5",UI_Graph_ADD,0,UI_Color_Pink,50,3,5,1050,660,111111111); + Float_Draw(&num[0],"s5",UI_Graph_ADD,0,UI_Color_Pink,50,3,5,1050,660,1245545); Integer_Draw(&num[1],"s6",UI_Graph_ADD,0,UI_Color_Cyan,50,5,1050,460,12345); UI_ReFresh(7,graph[0],graph[1],graph[2],graph[3],graph[4],num[0],num[1]); Char_Draw(&sdata[0],"s7",UI_Graph_ADD,0,UI_Color_Green,20,2,620,710); - Char_Write(&sdata[0],"number:%d",12345678); + Char_Write(&sdata[0],"number:%d",123); Char_ReFresh(sdata[0]); ////////////////////////////////////////////////// diff --git a/modules/referee/referee_UI.c b/modules/referee/referee_UI.c index e2b3068..e474e30 100644 --- a/modules/referee/referee_UI.c +++ b/modules/referee/referee_UI.c @@ -21,11 +21,12 @@ uint8_t UI_Seq; //包序号 void UI_Delete(uint8_t Del_Operate,uint8_t Del_Layer) { UI_delete_t UI_delete_data; + uint8_t temp_datalength = UI_Data_LEN_Head + UI_Operate_LEN_Del; //计算交互数据长度 UI_delete_data.FrameHeader.SOF = REFEREE_SOF; - UI_delete_data.FrameHeader.DataLength = UI_Data_LEN_Del; + UI_delete_data.FrameHeader.DataLength = temp_datalength; UI_delete_data.FrameHeader.Seq = UI_Seq; - UI_delete_data.FrameHeader.CRC8 = Get_CRC8_Check_Sum((uint8_t *)&UI_delete_data,4,0xFF); + UI_delete_data.FrameHeader.CRC8 = Get_CRC8_Check_Sum((uint8_t *)&UI_delete_data,LEN_CRC8,0xFF); UI_delete_data.CmdID = ID_student_interactive; @@ -36,10 +37,10 @@ void UI_Delete(uint8_t Del_Operate,uint8_t Del_Layer) UI_delete_data.Delete_Operate = Del_Operate; //删除操作 UI_delete_data.Layer = Del_Layer; - UI_delete_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_delete_data,LEN_HEADER+LEN_CMDID+UI_Data_LEN_Del,0xFFFF); + UI_delete_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_delete_data,LEN_HEADER+LEN_CMDID+temp_datalength,0xFFFF); /* syhtodo为什么填入0xFFFF */ - RefereeSend((uint8_t *)&UI_delete_data,LEN_HEADER+LEN_CMDID+UI_Data_LEN_Del+LEN_TAIL); //发送 + RefereeSend((uint8_t *)&UI_delete_data,LEN_HEADER+LEN_CMDID+temp_datalength+LEN_TAIL); //发送 UI_Seq++; //包序号+1 } @@ -327,7 +328,7 @@ void Char_Write(String_Data_t *graph,char* fmt, ...) uint16_t i = 0; va_list ap; va_start(ap,fmt); - vsprintf((char*)graph->show_Data, fmt, ap); + vsprintf((char*)graph->show_Data, fmt, ap);//使用参数列表发送格式化输出到字符串 va_end(ap); i = strlen((const char*)graph->show_Data); graph->Graph_Control.end_angle = i; @@ -344,18 +345,19 @@ int UI_ReFresh(int cnt,...) int i; UI_GraphReFresh_t UI_GraphReFresh_data; Graph_Data_t graphData; + // uint8_t temp_datalength = UI_Data_LEN_Head + UI_Operate_LEN_Del; //计算交互数据长度 va_list ap;//创建一个 va_list 类型变量 va_start(ap,cnt);//初始化 va_list 变量为一个参数列表 UI_GraphReFresh_data.FrameHeader.SOF = REFEREE_SOF; - UI_GraphReFresh_data.FrameHeader.DataLength = 6+cnt*15;//syhtodo 换成枚举 + UI_GraphReFresh_data.FrameHeader.DataLength = UI_Data_LEN_Head+cnt*UI_Operate_LEN_PerDraw; UI_GraphReFresh_data.FrameHeader.Seq = UI_Seq; - UI_GraphReFresh_data.FrameHeader.CRC8 = Get_CRC8_Check_Sum((uint8_t *)&UI_GraphReFresh_data,4,0xFF); + UI_GraphReFresh_data.FrameHeader.CRC8 = Get_CRC8_Check_Sum((uint8_t *)&UI_GraphReFresh_data,LEN_CRC8,0xFF); UI_GraphReFresh_data.CmdID = ID_student_interactive; - switch(cnt) //syhtodo可以直接计算式解决 + switch(cnt) { case 1: UI_GraphReFresh_data.datahead.data_cmd_id=UI_Data_ID_Draw1; @@ -372,26 +374,30 @@ int UI_ReFresh(int cnt,...) default: return (-1); } + UI_GraphReFresh_data.datahead.receiver_ID = Cilent_ID; UI_GraphReFresh_data.datahead.sender_ID = Robot_ID; - UI_GraphReFresh_data.frametail=Get_CRC16_Check_Sum((uint8_t *)&UI_GraphReFresh_data,LEN_HEADER+LEN_CMDID+6,0xFFFF); - RefereeSend((uint8_t *)&UI_GraphReFresh_data,LEN_HEADER+LEN_CMDID+6); + //先发送帧头、命令码、交互数据帧头三部分,并计算CRC16校验值 + UI_GraphReFresh_data.frametail=Get_CRC16_Check_Sum((uint8_t *)&UI_GraphReFresh_data,LEN_HEADER+LEN_CMDID+UI_Data_LEN_Head,0xFFFF); + RefereeSend((uint8_t *)&UI_GraphReFresh_data,LEN_HEADER+LEN_CMDID+UI_Data_LEN_Head); - unsigned char *framepoint; //读写指针 + unsigned char *framepoint; //读写指针 syhtodo是否可以去掉 - for(i=0;i