操作部分宏定义换枚举

This commit is contained in:
kidneygood 2023-01-14 22:39:26 +08:00
parent 2d41034769
commit a9e1eb6247
5 changed files with 129 additions and 127 deletions

View File

@ -345,7 +345,6 @@ 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 变量为一个参数列表
@ -382,15 +381,12 @@ int UI_ReFresh(int cnt,...)
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; //读写指针 syhtodo是否可以去掉
for(i=0;i<cnt;i++) //发送交互数据的数据帧并计算CRC16校验值
{
graphData=va_arg(ap,Graph_Data_t);//访问参数列表中的每个项,第二个参数是你要返回的参数的类型,在取值时需要将其强制转化为指定类型的变量
//发送
//发送并计算CRC16
RefereeSend((uint8_t *)&graphData,UI_Operate_LEN_PerDraw);
framepoint=(uint8_t *)&graphData;
UI_GraphReFresh_data.frametail=Get_CRC16_Check_Sum(framepoint,UI_Operate_LEN_PerDraw,UI_GraphReFresh_data.frametail);
UI_GraphReFresh_data.frametail=Get_CRC16_Check_Sum((uint8_t *)&graphData,UI_Operate_LEN_PerDraw,UI_GraphReFresh_data.frametail);
}
RefereeSend((uint8_t *)&UI_GraphReFresh_data.frametail,LEN_TAIL); //发送CRC16校验值
@ -432,53 +428,6 @@ int Char_ReFresh(String_Data_t string_Data)
// #define send_max_len 200
// unsigned char CliendTxBuffer[send_max_len];
// void JUDGE_Show_Data(void)
// {
// static uint8_t datalength,i;
// uint8_t judge_led = 0xff;//初始化led为全绿
// static uint8_t auto_led_time = 0;
// static uint8_t buff_led_time = 0;
// determine_ID();//判断发送者ID和其对应的客户端ID
// ShowData.txFrameHeader.SOF = 0xA5;
// ShowData.txFrameHeader.DataLength = sizeof(ext_student_interactive_header_data_t) + sizeof(client_custom_data_t);
// ShowData.txFrameHeader.Seq = 0;
// memcpy(CliendTxBuffer, &ShowData.txFrameHeader, sizeof(xFrameHeader));//写入帧头数据
// Append_CRC8_Check_Sum(CliendTxBuffer, sizeof(xFrameHeader));//写入帧头CRC8校验码
// ShowData.CmdID = 0x0301;
// ShowData.dataFrameHeader.data_cmd_id = 0xD180;//发给客户端的cmd,官方固定
// //ID已经是自动读取的了
// ShowData.dataFrameHeader.send_ID = Judge_Self_ID;//发送者的ID
// ShowData.dataFrameHeader.receiver_ID = Judge_SelfClient_ID;//客户端的ID只能为发送者机器人对应的客户端
// /*- 自定义内容 -*/
// ShowData.clientData.data1 = (float)Capvoltage_Percent();//电容剩余电量
// ShowData.clientData.data2 = (float)Base_Angle_Measure();//吊射角度测
// ShowData.clientData.data3 = GIMBAL_PITCH_Judge_Angle();//云台抬头角度
// ShowData.clientData.masks = judge_led;//0~5位0红灯,1绿灯
// //打包写入数据段
// memcpy(
// CliendTxBuffer + 5,
// (uint8_t*)&ShowData.CmdID,
// (sizeof(ShowData.CmdID)+ sizeof(ShowData.dataFrameHeader)+ sizeof(ShowData.clientData))
// );
// Append_CRC16_Check_Sum(CliendTxBuffer,sizeof(ShowData));//写入数据段CRC16校验码
// datalength = sizeof(ShowData);
// for(i = 0;i < datalength;i++)
// {
// USART_SendData(UART5,(uint16_t)CliendTxBuffer[i]);
// while(USART_GetFlagStatus(UART5,USART_FLAG_TC)==RESET);
// }
// }
@ -488,7 +437,7 @@ int Char_ReFresh(String_Data_t string_Data)
// * @retval RED BLUE
// * @attention 数据打包,打包完成后通过串口发送到裁判系统
// */
// bool Color;
// bool is_red_or_blue(void)
// {
// Judge_Self_ID = GameRobotStat.robot_id;//读取当前机器人ID

View File

@ -42,33 +42,6 @@
#define UI_Data_CilentID_BStandard2 0x0168
#define UI_Data_CilentID_BStandard3 0x0169
#define UI_Data_CilentID_BAerial 0x016A
/***************************删除操作***************************/
#define UI_Data_Del_NoOperate 0
#define UI_Data_Del_Layer 1
#define UI_Data_Del_ALL 2 //删除全部图层,后面的参数已经不重要了。
/***************************图形配置参数__图形操作********************/
#define UI_Graph_ADD 1
#define UI_Graph_Change 2
#define UI_Graph_Del 3
/***************************图形配置参数__图形类型********************/
#define UI_Graph_Line 0 //直线
#define UI_Graph_Rectangle 1 //矩形
#define UI_Graph_Circle 2 //整圆
#define UI_Graph_Ellipse 3 //椭圆
#define UI_Graph_Arc 4 //圆弧
#define UI_Graph_Float 5 //浮点型
#define UI_Graph_Int 6 //整形
#define UI_Graph_Char 7 //字符型
/***************************图形配置参数__图形颜色********************/
#define UI_Color_Main 0 //红蓝主色
#define UI_Color_Yellow 1
#define UI_Color_Green 2
#define UI_Color_Orange 3
#define UI_Color_Purplish_red 4 //紫红色
#define UI_Color_Pink 5
#define UI_Color_Cyan 6 //青色
#define UI_Color_Black 7
#define UI_Color_White 8
typedef struct
{

View File

@ -0,0 +1,51 @@
// #define send_max_len 200
// unsigned char CliendTxBuffer[send_max_len];
// void JUDGE_Show_Data(void)
// {
// static uint8_t datalength,i;
// uint8_t judge_led = 0xff;//初始化led为全绿
// static uint8_t auto_led_time = 0;
// static uint8_t buff_led_time = 0;
// determine_ID();//判断发送者ID和其对应的客户端ID
// ShowData.txFrameHeader.SOF = 0xA5;
// ShowData.txFrameHeader.DataLength = sizeof(ext_student_interactive_header_data_t) + sizeof(client_custom_data_t);
// ShowData.txFrameHeader.Seq = 0;
// memcpy(CliendTxBuffer, &ShowData.txFrameHeader, sizeof(xFrameHeader));//写入帧头数据
// Append_CRC8_Check_Sum(CliendTxBuffer, sizeof(xFrameHeader));//写入帧头CRC8校验码
// ShowData.CmdID = 0x0301;
// ShowData.dataFrameHeader.data_cmd_id = 0xD180;//发给客户端的cmd,官方固定
// //ID已经是自动读取的了
// ShowData.dataFrameHeader.send_ID = Judge_Self_ID;//发送者的ID
// ShowData.dataFrameHeader.receiver_ID = Judge_SelfClient_ID;//客户端的ID只能为发送者机器人对应的客户端
// /*- 自定义内容 -*/
// ShowData.clientData.data1 = (float)Capvoltage_Percent();//电容剩余电量
// ShowData.clientData.data2 = (float)Base_Angle_Measure();//吊射角度测
// ShowData.clientData.data3 = GIMBAL_PITCH_Judge_Angle();//云台抬头角度
// ShowData.clientData.masks = judge_led;//0~5位0红灯,1绿灯
// //打包写入数据段
// memcpy(
// CliendTxBuffer + 5,
// (uint8_t*)&ShowData.CmdID,
// (sizeof(ShowData.CmdID)+ sizeof(ShowData.dataFrameHeader)+ sizeof(ShowData.clientData))
// );
// Append_CRC16_Check_Sum(CliendTxBuffer,sizeof(ShowData));//写入数据段CRC16校验码
// datalength = sizeof(ShowData);
// for(i = 0;i < datalength;i++)
// {
// USART_SendData(UART5,(uint16_t)CliendTxBuffer[i]);
// while(USART_GetFlagStatus(UART5,USART_FLAG_TC)==RESET);
// }
// }

View File

@ -16,20 +16,7 @@
#pragma pack(1)
//暂时放在这里
/***************交互数据********************/
/*
0x0301 10Hz
UI绘制共用同一个cmd_id
ID的不同区分
*/
/* 交互数据接收信息0x0301 */
typedef struct
{
uint16_t data_cmd_id;
uint16_t send_ID;
uint16_t receiver_ID;
} ext_student_interactive_header_data_t;
/*
cmd_id:0x0301 ID:0xD180

View File

@ -33,13 +33,12 @@ typedef enum
LEN_CMDID = 2, // 命令码长度
LEN_TAIL = 2, // 帧尾CRC16
LEN_CRC8 = 4, //帧头CRC8校验长度=帧头+数据长+包序号
LEN_CRC8 = 4, // 帧头CRC8校验长度=帧头+数据长+包序号
} JudgeFrameLength;
/****************************帧头****************************/
/****************************帧头****************************/
#define REFEREE_SOF 0xA5 // 起始字节,协议固定为0xA5
/* 帧头偏移 */
typedef enum
@ -234,11 +233,7 @@ typedef struct
uint16_t receiver_ID;
} ext_student_interactive_header_data_t;
/* 内容ID数据 */
//己方机器人通信未写实际上删除几个图形的id可以直接计算得出
/* 交互数据ID */
typedef enum
{
UI_Data_ID_Del = 0x100,
@ -247,41 +242,88 @@ typedef enum
UI_Data_ID_Draw5 = 0x103,
UI_Data_ID_Draw7 = 0x104,
UI_Data_ID_DrawChar = 0x110,
} UI_Data_ID;
} Interactive_Data_ID;
/* 交互数据长度 */
typedef enum
{
UI_Data_LEN_Head = 6,
UI_Operate_LEN_Del =2,
UI_Operate_LEN_Del = 2,
UI_Operate_LEN_PerDraw = 15,
UI_Operate_LEN_DrawChar = 15+30,
UI_Operate_LEN_DrawChar = 15 + 30,
} UI_Data_Length;
/****************************UI交互数据****************************/
/****************************UI交互数据****************************/
/* 图形数据 */
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
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; //打印字符串数据
} String_Data_t; // 打印字符串数据
/* 删除操作 */
typedef enum
{
UI_Data_Del_NoOperate = 0,
UI_Data_Del_Layer = 1,
UI_Data_Del_ALL = 2, // 删除全部图层,后面的参数已经不重要了。
} UI_Delete_Operate;
/* 图形配置参数__图形操作 */
typedef enum
{
UI_Graph_ADD = 1,
UI_Graph_Change = 2,
UI_Graph_Del = 3,
} UI_Graph_Operate;
/* 图形配置参数__图形类型 */
typedef enum
{
UI_Graph_Line = 0, // 直线
UI_Graph_Rectangle = 1, // 矩形
UI_Graph_Circle = 2, // 整圆
UI_Graph_Ellipse = 3, // 椭圆
UI_Graph_Arc = 4, // 圆弧
UI_Graph_Float = 5, // 浮点型
UI_Graph_Int = 6, // 整形
UI_Graph_Char = 7, // 字符型
} UI_Graph_Type;
/* 图形配置参数__图形颜色 */
typedef enum
{
UI_Color_Main = 0, // 红蓝主色
UI_Color_Yellow = 1,
UI_Color_Green = 2,
UI_Color_Orange = 3,
UI_Color_Purplish_red = 4, // 紫红色
UI_Color_Pink = 5,
UI_Color_Cyan = 6, // 青色
UI_Color_Black = 7,
UI_Color_White = 8,
} UI_Graph_Color;
#pragma pack()