优化数据发送方式,整包发送

This commit is contained in:
kidneygood 2023-01-13 21:45:04 +08:00
parent 9b16407b57
commit e0abbf95ca
5 changed files with 197 additions and 190 deletions

View File

@ -36,6 +36,7 @@
//////////////////////////////////////////////////syhtodo
#include "referee_UI.h"
#include "referee.h"
#include "referee_def.h"
//////////////////////////////////////////////////
/* USER CODE END Includes */
@ -119,10 +120,12 @@ int main(void)
//////////////////////////////////////////////////syhtodo
Graph_Data graph[5];
Graph_Data num[2];
String_Data sdata[1];
Graph_Data_t graph[5];
Graph_Data_t num[2];
String_Data_t sdata[1];
memset(sdata[0].show_Data, 0, 30); //使用memset方法 syhtodo 数据存在初始化未默认为0的情况
memset(&graph[0], 0, 15);
UI_Delete(UI_Data_Del_ALL,0);
Line_Draw(&graph[0],"s0",UI_Graph_ADD,0,UI_Color_White,3,710,540,1210,540);
@ -135,8 +138,9 @@ int main(void)
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",12345);
Char_Write(&sdata[0],"number:%d",12345678);
Char_ReFresh(sdata[0]);
//////////////////////////////////////////////////

View File

@ -57,7 +57,7 @@ static void JudgeReadData(uint8_t *ReadFromUsart)
memcpy(&referee_info.FrameHeader, ReadFromUsart, LEN_HEADER);
// 判断帧头数据(0)是否为0xA5
if (ReadFromUsart[SOF] == JUDGE_FRAME_HEADER)
if (ReadFromUsart[SOF] == REFEREE_SOF)
{
// 帧头CRC8校验
if (Verify_CRC8_Check_Sum(ReadFromUsart, LEN_HEADER) == TRUE)

View File

@ -5,7 +5,10 @@
#include "dma.h"
#include "stdio.h"
#include "referee.h"
/* syhtodo 根据自身id判断客户端id */
/* syhtodo 根据自身id判断客户端id
*/
uint16_t Robot_ID = UI_Data_RobotID_BHero;
uint16_t Cilent_ID = UI_Data_CilentID_BHero;
@ -17,39 +20,26 @@ uint8_t UI_Seq; //包序号
*****************************************************************************************/
void UI_Delete(uint8_t Del_Operate,uint8_t Del_Layer)
{
/* syhtodo可化简去掉读写指针 */
unsigned char *framepoint; //读写指针
uint16_t frametail=0xFFFF; //CRC16校验值
UI_delete_t UI_delete_data;
UI_Packhead framehead; //帧头
UI_Data_Operate datahead; //数据交互帧
UI_Data_Delete del; //删除图层帧
UI_delete_data.FrameHeader.SOF = REFEREE_SOF;
UI_delete_data.FrameHeader.DataLength = UI_Data_LEN_Del;
UI_delete_data.FrameHeader.Seq = UI_Seq;
UI_delete_data.FrameHeader.CRC8 = Get_CRC8_Check_Sum((uint8_t *)&UI_delete_data,4,0xFF);
framepoint=(unsigned char *)&framehead;
UI_delete_data.CmdID = ID_student_interactive;
framehead.SOF=UI_SOF;
framehead.Data_Length=8;
framehead.Seq=UI_Seq;
framehead.CRC8=Get_CRC8_Check_Sum(framepoint,4,0xFF);
framehead.CMD_ID=UI_CMD_Robo_Exchange; //填充包头数据
UI_delete_data.datahead.data_cmd_id = UI_Data_ID_Del;
UI_delete_data.datahead.receiver_ID = Cilent_ID;
UI_delete_data.datahead.sender_ID = Robot_ID;
datahead.Data_ID=UI_Data_ID_Del;
datahead.Sender_ID=Robot_ID;
datahead.Receiver_ID=Cilent_ID; //填充操作数据
UI_delete_data.Delete_Operate = Del_Operate; //删除操作
UI_delete_data.Layer = Del_Layer;
del.Delete_Operate=Del_Operate;
del.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);
/* syhtodo为什么填入0xFFFF */
frametail=Get_CRC16_Check_Sum(framepoint,sizeof(framehead),frametail);
framepoint=(unsigned char *)&datahead;
frametail=Get_CRC16_Check_Sum(framepoint,sizeof(datahead),frametail);
framepoint=(unsigned char *)&del;
frametail=Get_CRC16_Check_Sum(framepoint,sizeof(del),frametail); //CRC16校验值计算
RefereeSend((uint8_t *)&framehead,sizeof(framehead));
RefereeSend((uint8_t *)&datahead,sizeof(datahead));
RefereeSend((uint8_t *)&del,sizeof(del)); //发送所有帧
RefereeSend((uint8_t *)&frametail,sizeof(frametail)); //发送CRC16校验值
RefereeSend((uint8_t *)&UI_delete_data,LEN_HEADER+LEN_CMDID+UI_Data_LEN_Del+LEN_TAIL); //发送
UI_Seq++; //包序号+1
}
@ -64,11 +54,11 @@ void UI_Delete(uint8_t Del_Operate,uint8_t Del_Layer)
End_xEnd_y xy坐标
**********************************************************************************************************/
void Line_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
void Line_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t End_x,uint32_t End_y)
{
int i;
//??????
//??????syhtodo
for(i=0;i<3&&graphname[i]!='\0';i++)
{
graph->graphic_name[2-i]=graphname[i];
@ -96,7 +86,7 @@ void Line_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32
Start_xStart_y xy坐标
End_xEnd_y xy坐标
**********************************************************************************************************/
void Rectangle_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
void Rectangle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t End_x,uint32_t End_y)
{
int i;
@ -128,7 +118,7 @@ void Rectangle_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,u
Graph_Radius
**********************************************************************************************************/
void Circle_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
void Circle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t Graph_Radius)
{
int i;
@ -157,7 +147,7 @@ void Circle_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint
Start_xStart_y xy坐标
End_xEnd_y xy半轴长度
**********************************************************************************************************/
void Elliptical_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
void Elliptical_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t end_x,uint32_t end_y)
{
int i;
@ -191,7 +181,7 @@ void Elliptical_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,
x_Length,y_Length xy半轴长度
**********************************************************************************************************/
void Arc_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
void Arc_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
uint32_t Graph_StartAngle,uint32_t Graph_EndAngle,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,
uint32_t end_x,uint32_t end_y)
{
@ -230,7 +220,7 @@ void Arc_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_
end_y=(a>>21)&0x7FF;
**********************************************************************************************************/
void Float_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
void Float_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
uint32_t Graph_Size,uint32_t Graph_Digit,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,int32_t Graph_Float)
{
int i;
@ -267,7 +257,7 @@ void Float_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint3
end_x=(a>>10)&0x7FF;
end_y=(a>>21)&0x7FF;
**********************************************************************************************************/
void Integer_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
void Integer_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
uint32_t Graph_Size,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,int32_t Graph_Integer)
{
int i;
@ -301,10 +291,10 @@ void Integer_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uin
Graph_Width 线
Start_xStart_y
**********************************************************************************************************/
void Char_Draw(String_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
void Char_Draw(String_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
uint32_t Graph_Size,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y)
{
memset(graph->Graph_Control.graphic_name, 0, 3);
memset(graph->Graph_Control.graphic_name, 0, 3);//syhtodo 是否需要手动清零
int i;
for(i=0;i<3&&graphname[i]!='\0';i++)
{
@ -332,7 +322,7 @@ void Char_Draw(String_Data *graph,char graphname[3],uint32_t Graph_Operate,uint3
fmt需要显示的字符串
syhtodo
**********************************************************************************************************/
void Char_Write(String_Data *graph,char* fmt, ...)
void Char_Write(String_Data_t *graph,char* fmt, ...)
{
uint16_t i = 0;
va_list ap;
@ -343,6 +333,7 @@ void Char_Write(String_Data *graph,char* fmt, ...)
graph->Graph_Control.end_angle = i;
}
/* UI推送函数使更改生效
cnt
...
@ -351,107 +342,88 @@ void Char_Write(String_Data *graph,char* fmt, ...)
int UI_ReFresh(int cnt,...)
{
int i;
UI_Packhead framehead;
UI_Data_Operate datahead;
Graph_Data graphData;
unsigned char *framepoint; //读写指针
uint16_t frametail=0xFFFF; //CRC16校验值
UI_GraphReFresh_t UI_GraphReFresh_data;
Graph_Data_t graphData;
va_list ap;//创建一个 va_list 类型变量
va_start(ap,cnt);//初始化 va_list 变量为一个参数列表
framepoint=(unsigned char *)&framehead;
framehead.SOF=UI_SOF;
framehead.Data_Length=6+cnt*15;
framehead.Seq=UI_Seq;
framehead.CRC8=Get_CRC8_Check_Sum(framepoint,4,0xFF);
framehead.CMD_ID=UI_CMD_Robo_Exchange; //填充包头数据
UI_GraphReFresh_data.FrameHeader.SOF = REFEREE_SOF;
UI_GraphReFresh_data.FrameHeader.DataLength = 6+cnt*15;//syhtodo 换成枚举
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.CmdID = ID_student_interactive;
switch(cnt) //syhtodo可以直接计算式解决
{
case 1:
datahead.Data_ID=UI_Data_ID_Draw1;
UI_GraphReFresh_data.datahead.data_cmd_id=UI_Data_ID_Draw1;
break;
case 2:
datahead.Data_ID=UI_Data_ID_Draw2;
UI_GraphReFresh_data.datahead.data_cmd_id=UI_Data_ID_Draw2;
break;
case 5:
datahead.Data_ID=UI_Data_ID_Draw5;
UI_GraphReFresh_data.datahead.data_cmd_id=UI_Data_ID_Draw5;
break;
case 7:
datahead.Data_ID=UI_Data_ID_Draw7;
UI_GraphReFresh_data.datahead.data_cmd_id=UI_Data_ID_Draw7;
break;
default:
return (-1);
}
datahead.Sender_ID=Robot_ID;
datahead.Receiver_ID=Cilent_ID; //填充操作数据
UI_GraphReFresh_data.datahead.receiver_ID = Cilent_ID;
UI_GraphReFresh_data.datahead.sender_ID = Robot_ID;
framepoint=(unsigned char *)&framehead;
frametail=Get_CRC16_Check_Sum(framepoint,sizeof(framehead),frametail);
framepoint=(unsigned char *)&datahead;
frametail=Get_CRC16_Check_Sum(framepoint,sizeof(datahead),frametail); //CRC16校验值计算部分
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);
RefereeSend((uint8_t *)&framehead,sizeof(framehead));
RefereeSend((uint8_t *)&datahead,sizeof(datahead));
unsigned char *framepoint; //读写指针
for(i=0;i<cnt;i++) //发送图片帧
{
graphData=va_arg(ap,Graph_Data);//访问参数列表中的每个项
RefereeSend((uint8_t *)&graphData,sizeof(graphData));
framepoint=(unsigned char *)&graphData;
frametail=Get_CRC16_Check_Sum(framepoint,sizeof(graphData),frametail);
graphData=va_arg(ap,Graph_Data_t);//访问参数列表中的每个项,第二个参数是你要返回的参数的类型,在取值时需要将其强制转化为指定类型的变量
RefereeSend((uint8_t *)&graphData,15);//syhtod 15可否计算
framepoint=(uint8_t *)&graphData;
UI_GraphReFresh_data.frametail=Get_CRC16_Check_Sum(framepoint,15,UI_GraphReFresh_data.frametail);
}
RefereeSend((uint8_t *)&frametail,sizeof(frametail)); //发送CRC16校验值
RefereeSend((uint8_t *)&UI_GraphReFresh_data.frametail,LEN_TAIL); //发送CRC16校验值
va_end(ap);//结束可变参数的获取
UI_Seq++; //包序号+1
return 0;
}
/************************************************UI推送字符使更改生效*********************************/
int Char_ReFresh(String_Data string_Data)
int Char_ReFresh(String_Data_t string_Data)
{
String_Data graphData;
unsigned char *framepoint; //读写指针
uint16_t frametail=0xFFFF; //CRC16校验值
UI_CharReFresh_t UI_CharReFresh_data;
UI_Packhead framehead;
UI_Data_Operate datahead;
graphData=string_Data;
UI_CharReFresh_data.FrameHeader.SOF = REFEREE_SOF;
UI_CharReFresh_data.FrameHeader.DataLength = UI_Data_LEN_DrawChar;
UI_CharReFresh_data.FrameHeader.Seq = UI_Seq;
UI_CharReFresh_data.FrameHeader.CRC8 = Get_CRC8_Check_Sum((uint8_t *)&UI_CharReFresh_data,4,0xFF);
UI_CharReFresh_data.CmdID = ID_student_interactive;
framepoint=(unsigned char *)&framehead;
framehead.SOF=UI_SOF;
framehead.Data_Length=6+45;
framehead.Seq=UI_Seq;
framehead.CRC8=Get_CRC8_Check_Sum(framepoint,4,0xFF);
framehead.CMD_ID=UI_CMD_Robo_Exchange; //填充包头数据
UI_CharReFresh_data.datahead.data_cmd_id = UI_Data_ID_DrawChar;
UI_CharReFresh_data.datahead.receiver_ID = Cilent_ID;
UI_CharReFresh_data.datahead.sender_ID = Robot_ID;
datahead.Data_ID=UI_Data_ID_DrawChar;
datahead.Sender_ID=Robot_ID;
datahead.Receiver_ID=Cilent_ID; //填充操作数据
UI_CharReFresh_data.String_Data = string_Data;
framepoint=(unsigned char *)&framehead;
frametail=Get_CRC16_Check_Sum(framepoint,sizeof(framehead),frametail);
framepoint=(unsigned char *)&datahead;
frametail=Get_CRC16_Check_Sum(framepoint,sizeof(datahead),frametail);
framepoint=(unsigned char *)&graphData;
frametail=Get_CRC16_Check_Sum(framepoint,sizeof(graphData),frametail); //CRC16校验 //CRC16校验值计算部分
UI_CharReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_CharReFresh_data,LEN_HEADER+LEN_CMDID+UI_Data_LEN_DrawChar,0xFFFF);
RefereeSend((uint8_t *)&framehead,sizeof(framehead));
RefereeSend((uint8_t *)&datahead,sizeof(datahead));
RefereeSend((uint8_t *)&graphData,sizeof(graphData)); //发送操作数据
RefereeSend((uint8_t *)&frametail,sizeof(frametail)); //发送CRC16校验值
RefereeSend((uint8_t *)&UI_CharReFresh_data,LEN_HEADER+LEN_CMDID+UI_Data_LEN_DrawChar+LEN_TAIL); //发送
UI_Seq++; //包序号+1
return 0;
}
// #define send_max_len 200
// unsigned char CliendTxBuffer[send_max_len];
// void JUDGE_Show_Data(void)

View File

@ -4,22 +4,12 @@
#include "stdarg.h"
#include "usart.h"
#include "stdint.h"
#include "referee_def.h"
#pragma pack(1) //按1字节对齐
// #define NULL 0
#define __FALSE 100
/****************************开始标志*********************/
#define UI_SOF 0xA5
/****************************CMD_ID数据********************/
#define UI_CMD_Robo_Exchange 0x0301
/****************************内容ID数据********************/
#define UI_Data_ID_Del 0x100
#define UI_Data_ID_Draw1 0x101
#define UI_Data_ID_Draw2 0x102
#define UI_Data_ID_Draw5 0x103
#define UI_Data_ID_Draw7 0x104
#define UI_Data_ID_DrawChar 0x110
/****************************红方机器人ID********************/
#define UI_Data_RobotID_RHero 1
#define UI_Data_RobotID_REngineer 2
@ -82,67 +72,49 @@
typedef struct
{
uint8_t SOF; //起始字节,固定0xA5
uint16_t Data_Length; //帧数据长度
uint8_t Seq; //包序号
uint8_t CRC8; //CRC8校验值
uint16_t CMD_ID; //命令ID
} UI_Packhead; //帧头
typedef struct
{
uint16_t Data_ID; //内容ID
uint16_t Sender_ID; //发送者ID
uint16_t Receiver_ID; //接收者ID
} UI_Data_Operate; //操作定义帧
typedef struct
{
xFrameHeader FrameHeader;
uint16_t CmdID;
ext_student_interactive_header_data_t datahead;
uint8_t Delete_Operate; //删除操作
uint8_t Layer; //删除图层
} UI_Data_Delete; //删除图层帧
uint8_t Layer;
uint16_t frametail;
} UI_delete_t;
/* 图形数据 */
typedef struct
{
uint8_t graphic_name[3];
uint32_t operate_tpye:3;
uint32_t graphic_tpye:3;
uint32_t layer:4;
uint32_t color:4;
uint32_t start_angle:9;
uint32_t end_angle:9;
uint32_t width:10;
uint32_t start_x:11;
uint32_t start_y:11;
uint32_t radius:10;
uint32_t end_x:11;
uint32_t end_y:11;
} Graph_Data;
xFrameHeader FrameHeader;
uint16_t CmdID;
ext_student_interactive_header_data_t datahead;
uint16_t frametail;
} UI_GraphReFresh_t;
typedef struct
{
Graph_Data Graph_Control;
uint8_t show_Data[30];
} String_Data; //打印字符串数据
xFrameHeader FrameHeader;
uint16_t CmdID;
ext_student_interactive_header_data_t datahead;
String_Data_t String_Data;
uint16_t frametail;
} UI_CharReFresh_t; //打印字符串数据
#pragma pack()
void UI_Delete(uint8_t Del_Operate,uint8_t Del_Layer);
void Line_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t End_x,uint32_t End_y);
void Circle_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t Graph_Radius);
void Elliptical_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t end_x,uint32_t end_y);
void Rectangle_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t End_x,uint32_t End_y);
void Arc_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_StartAngle,uint32_t Graph_EndAngle,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t end_x,uint32_t end_y);
void Float_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Size,uint32_t Graph_Digit,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,int32_t Graph_Float);
void Integer_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Size,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,int32_t Graph_Integer);
void Line_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t End_x,uint32_t End_y);
void Circle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t Graph_Radius);
void Elliptical_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t end_x,uint32_t end_y);
void Rectangle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t End_x,uint32_t End_y);
void Arc_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_StartAngle,uint32_t Graph_EndAngle,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t end_x,uint32_t end_y);
void Float_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Size,uint32_t Graph_Digit,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,int32_t Graph_Float);
void Integer_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Size,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,int32_t Graph_Integer);
int UI_ReFresh(int cnt,...);
void Char_Draw(String_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Size,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y);
void Char_Write(String_Data *graph,char* fmt, ...);
int Char_ReFresh(String_Data string_Data);
void Char_Draw(String_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,uint32_t Graph_Size,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y);
void Char_Write(String_Data_t *graph,char* fmt, ...);
int Char_ReFresh(String_Data_t string_Data);
#endif

View File

@ -37,8 +37,8 @@ typedef enum
/****************************帧头****************************/
/****************************帧头****************************/
#define JUDGE_FRAME_HEADER (0xA5) // 起始字节,协议固定为0xA5
#define REFEREE_SOF 0xA5 // 起始字节,协议固定为0xA5
/* 帧头偏移 */
typedef enum
{
@ -57,7 +57,6 @@ typedef struct
uint8_t CRC8;
} xFrameHeader;
/****************************cmd_id命令码说明****************************/
/****************************cmd_id命令码说明****************************/
@ -220,8 +219,68 @@ typedef struct
float bullet_speed;
} ext_shoot_data_t;
/****************************机器人间交互数据****************************/
/****************************机器人间交互数据****************************/
/* 发送的内容数据段最大为 113 检测是否超出大小限制
30
syhtodo */
/* 交互数据头结构 */
typedef struct
{
uint16_t data_cmd_id;
uint16_t sender_ID;
uint16_t receiver_ID;
} ext_student_interactive_header_data_t;
/* 内容ID数据 */
//己方机器人通信未写实际上删除几个图形的id可以直接计算得出
typedef enum
{
UI_Data_ID_Del = 0x100,
UI_Data_ID_Draw1 = 0x101,
UI_Data_ID_Draw2 = 0x102,
UI_Data_ID_Draw5 = 0x103,
UI_Data_ID_Draw7 = 0x104,
UI_Data_ID_DrawChar = 0x110,
} UI_Data_ID;
typedef enum
{
UI_Data_LEN_Del = 6+2,
UI_Data_LEN_Draw1 = 6+15,
UI_Data_LEN_Draw2 = 6+30,
UI_Data_LEN_Draw5 = 6+75,
UI_Data_LEN_Draw7 = 6+105,
UI_Data_LEN_DrawChar = 6+15+30,//syhtodo 其实没啥用,换成各部分,可以直接带入计算
} UI_Data_Length;
/* 图形数据 */
typedef struct
{
uint8_t graphic_name[3];
uint32_t operate_tpye:3;
uint32_t graphic_tpye:3;
uint32_t layer:4;
uint32_t color:4;
uint32_t start_angle:9;
uint32_t end_angle:9;
uint32_t width:10;
uint32_t start_x:11;
uint32_t start_y:11;
uint32_t radius:10;
uint32_t end_x:11;
uint32_t end_y:11;
} Graph_Data_t;//syhtodo 定义要有-t
typedef struct
{
Graph_Data_t Graph_Control;
uint8_t show_Data[30];
} String_Data_t; //打印字符串数据
#pragma pack()
#endif