2023-01-09 16:17:03 +08:00
|
|
|
|
#include "referee_UI.h"
|
|
|
|
|
#include "string.h"
|
|
|
|
|
#include "crc.h"
|
|
|
|
|
#include "stdio.h"
|
2023-01-24 22:37:53 +08:00
|
|
|
|
#include "rm_referee.h"
|
2023-01-15 21:11:15 +08:00
|
|
|
|
|
|
|
|
|
static uint8_t UI_Seq; //包序号
|
2023-01-09 16:17:03 +08:00
|
|
|
|
/********************************************删除操作*************************************
|
2023-01-24 22:37:53 +08:00
|
|
|
|
**参数:_id 对应的id结构体
|
|
|
|
|
Del_Operate 对应头文件删除操作
|
2023-01-09 16:17:03 +08:00
|
|
|
|
Del_Layer 要删除的层 取值0-9
|
|
|
|
|
*****************************************************************************************/
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void UI_Delete(referee_id_t *_id,uint8_t Del_Operate,uint8_t Del_Layer)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_delete_t UI_delete_data;
|
2023-01-14 21:50:58 +08:00
|
|
|
|
uint8_t temp_datalength = UI_Data_LEN_Head + UI_Operate_LEN_Del; //计算交互数据长度
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
|
|
|
|
UI_delete_data.FrameHeader.SOF = REFEREE_SOF;
|
2023-01-14 21:50:58 +08:00
|
|
|
|
UI_delete_data.FrameHeader.DataLength = temp_datalength;
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_delete_data.FrameHeader.Seq = UI_Seq;
|
2023-01-14 21:50:58 +08:00
|
|
|
|
UI_delete_data.FrameHeader.CRC8 = Get_CRC8_Check_Sum((uint8_t *)&UI_delete_data,LEN_CRC8,0xFF);
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
|
|
|
|
UI_delete_data.CmdID = ID_student_interactive;
|
|
|
|
|
|
|
|
|
|
UI_delete_data.datahead.data_cmd_id = UI_Data_ID_Del;
|
2023-01-15 21:11:15 +08:00
|
|
|
|
UI_delete_data.datahead.receiver_ID = _id->Cilent_ID;
|
|
|
|
|
UI_delete_data.datahead.sender_ID = _id->Robot_ID;
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
|
|
|
|
UI_delete_data.Delete_Operate = Del_Operate; //删除操作
|
|
|
|
|
UI_delete_data.Layer = Del_Layer;
|
|
|
|
|
|
2023-01-14 21:50:58 +08:00
|
|
|
|
UI_delete_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_delete_data,LEN_HEADER+LEN_CMDID+temp_datalength,0xFFFF);
|
2023-01-26 15:07:00 +08:00
|
|
|
|
/* syhtodo为什么填入0xFFFF,关于crc校验 */
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
2023-01-14 21:50:58 +08:00
|
|
|
|
RefereeSend((uint8_t *)&UI_delete_data,LEN_HEADER+LEN_CMDID+temp_datalength+LEN_TAIL); //发送
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
2023-01-09 16:17:03 +08:00
|
|
|
|
UI_Seq++; //包序号+1
|
|
|
|
|
}
|
|
|
|
|
/************************************************绘制直线*************************************************
|
2023-01-09 21:50:17 +08:00
|
|
|
|
**参数:*graph Graph_Data类型变量指针,用于存放图形数据
|
|
|
|
|
graphname[3] 图片名称,用于标识更改
|
2023-01-09 16:17:03 +08:00
|
|
|
|
Graph_Operate 图片操作,见头文件
|
|
|
|
|
Graph_Layer 图层0-9
|
|
|
|
|
Graph_Color 图形颜色
|
|
|
|
|
Graph_Width 图形线宽
|
2023-01-09 21:50:17 +08:00
|
|
|
|
Start_x、Start_y 起点xy坐标
|
|
|
|
|
End_x、End_y 终点xy坐标
|
2023-01-09 16:17:03 +08:00
|
|
|
|
**********************************************************************************************************/
|
|
|
|
|
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void Line_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
|
2023-01-09 21:50:17 +08:00
|
|
|
|
uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t End_x,uint32_t End_y)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
2023-01-24 22:37:53 +08:00
|
|
|
|
// memset(graph,0,UI_Operate_LEN_PerDraw); //如果定义的是非静态变量,数据存在初始化未默认为0的情况,使用memset方法,以下类似 syhtodo
|
2023-01-09 16:17:03 +08:00
|
|
|
|
int i;
|
2023-01-24 22:37:53 +08:00
|
|
|
|
for(i=0;i<3&&graphname[i]!='\0';i++) //填充至‘0’为止
|
2023-01-09 21:50:17 +08:00
|
|
|
|
{
|
2023-01-24 22:37:53 +08:00
|
|
|
|
graph->graphic_name[2-i]=graphname[i]; //按内存地址增大方向填充,所以会有i与2-i
|
2023-01-09 21:50:17 +08:00
|
|
|
|
}
|
2023-01-24 22:37:53 +08:00
|
|
|
|
|
2023-01-09 21:50:17 +08:00
|
|
|
|
graph->operate_tpye = Graph_Operate;
|
|
|
|
|
graph->graphic_tpye = UI_Graph_Line;
|
|
|
|
|
graph->layer = Graph_Layer;
|
|
|
|
|
graph->color = Graph_Color;
|
|
|
|
|
|
|
|
|
|
graph->width = Graph_Width;
|
|
|
|
|
graph->start_x = Start_x;
|
|
|
|
|
graph->start_y = Start_y;
|
|
|
|
|
graph->end_x = End_x;
|
|
|
|
|
graph->end_y = End_y;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************************绘制矩形*************************************************
|
2023-01-09 21:50:17 +08:00
|
|
|
|
**参数:*graph Graph_Data类型变量指针,用于存放图形数据
|
|
|
|
|
graphname[3] 图片名称,用于标识更改
|
2023-01-09 16:17:03 +08:00
|
|
|
|
Graph_Operate 图片操作,见头文件
|
|
|
|
|
Graph_Layer 图层0-9
|
|
|
|
|
Graph_Color 图形颜色
|
|
|
|
|
Graph_Width 图形线宽
|
2023-01-09 21:50:17 +08:00
|
|
|
|
Start_x、Start_y 起点xy坐标
|
|
|
|
|
End_x、End_y 对角顶点xy坐标
|
|
|
|
|
**********************************************************************************************************/
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void Rectangle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
|
2023-01-09 21:50:17 +08:00
|
|
|
|
uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t End_x,uint32_t End_y)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
2023-01-24 22:37:53 +08:00
|
|
|
|
// memset(&graph,0,UI_Operate_LEN_PerDraw);
|
2023-01-09 16:17:03 +08:00
|
|
|
|
int i;
|
2023-01-09 21:50:17 +08:00
|
|
|
|
for(i=0;i<3&&graphname[i]!='\0';i++)
|
|
|
|
|
{
|
|
|
|
|
graph->graphic_name[2-i]=graphname[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
graph->graphic_tpye = UI_Graph_Rectangle;
|
|
|
|
|
graph->operate_tpye = Graph_Operate;
|
|
|
|
|
graph->layer = Graph_Layer;
|
|
|
|
|
graph->color = Graph_Color;
|
|
|
|
|
|
|
|
|
|
graph->width = Graph_Width;
|
|
|
|
|
graph->start_x = Start_x;
|
|
|
|
|
graph->start_y = Start_y;
|
|
|
|
|
graph->end_x = End_x;
|
|
|
|
|
graph->end_y = End_y;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************************绘制整圆*************************************************
|
2023-01-09 21:50:17 +08:00
|
|
|
|
**参数:*graph Graph_Data类型变量指针,用于存放图形数据
|
|
|
|
|
graphname[3] 图片名称,用于标识更改
|
2023-01-09 16:17:03 +08:00
|
|
|
|
Graph_Operate 图片操作,见头文件
|
|
|
|
|
Graph_Layer 图层0-9
|
|
|
|
|
Graph_Color 图形颜色
|
|
|
|
|
Graph_Width 图形线宽
|
2023-01-09 21:50:17 +08:00
|
|
|
|
Start_x、Start_y 圆心xy坐标
|
|
|
|
|
Graph_Radius 圆形半径
|
2023-01-09 16:17:03 +08:00
|
|
|
|
**********************************************************************************************************/
|
|
|
|
|
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void Circle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
|
2023-01-09 21:50:17 +08:00
|
|
|
|
uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t Graph_Radius)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
2023-01-24 22:37:53 +08:00
|
|
|
|
// memset(&graph,0,UI_Operate_LEN_PerDraw);
|
2023-01-09 16:17:03 +08:00
|
|
|
|
int i;
|
2023-01-09 21:50:17 +08:00
|
|
|
|
for(i=0;i<3&&graphname[i]!='\0';i++)
|
|
|
|
|
{
|
|
|
|
|
graph->graphic_name[2-i]=graphname[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
graph->graphic_tpye = UI_Graph_Circle;
|
|
|
|
|
graph->operate_tpye = Graph_Operate;
|
|
|
|
|
graph->layer = Graph_Layer;
|
|
|
|
|
graph->color = Graph_Color;
|
|
|
|
|
|
|
|
|
|
graph->width = Graph_Width;
|
|
|
|
|
graph->start_x = Start_x;
|
|
|
|
|
graph->start_y = Start_y;
|
|
|
|
|
graph->radius = Graph_Radius;
|
|
|
|
|
}
|
|
|
|
|
/************************************************绘制椭圆*************************************************
|
|
|
|
|
**参数:*graph Graph_Data类型变量指针,用于存放图形数据
|
|
|
|
|
graphname[3] 图片名称,用于标识更改
|
|
|
|
|
Graph_Operate 图片操作,见头文件
|
|
|
|
|
Graph_Layer 图层0-9
|
|
|
|
|
Graph_Color 图形颜色
|
|
|
|
|
Graph_Width 图形线宽
|
|
|
|
|
Start_x、Start_y 圆心xy坐标
|
|
|
|
|
End_x、End_y xy半轴长度
|
|
|
|
|
**********************************************************************************************************/
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void Elliptical_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
|
2023-01-09 21:50:17 +08:00
|
|
|
|
uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,uint32_t end_x,uint32_t end_y)
|
|
|
|
|
{
|
2023-01-24 22:37:53 +08:00
|
|
|
|
// memset(&graph,0,UI_Operate_LEN_PerDraw);
|
2023-01-09 21:50:17 +08:00
|
|
|
|
int i;
|
|
|
|
|
for(i=0;i<3&&graphname[i]!='\0';i++)
|
|
|
|
|
{
|
|
|
|
|
graph->graphic_name[2-i]=graphname[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
graph->graphic_tpye = UI_Graph_Ellipse;
|
|
|
|
|
graph->operate_tpye = Graph_Operate;
|
|
|
|
|
graph->layer = Graph_Layer;
|
|
|
|
|
graph->color = Graph_Color;
|
|
|
|
|
graph->width = Graph_Width;
|
|
|
|
|
|
|
|
|
|
graph->start_x = Start_x;
|
|
|
|
|
graph->start_y = Start_y;
|
|
|
|
|
graph->end_x = end_x;
|
|
|
|
|
graph->end_y = end_y;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-09 21:50:17 +08:00
|
|
|
|
|
2023-01-09 16:17:03 +08:00
|
|
|
|
/************************************************绘制圆弧*************************************************
|
2023-01-09 21:50:17 +08:00
|
|
|
|
**参数:*graph Graph_Data类型变量指针,用于存放图形数据
|
|
|
|
|
graphname[3] 图片名称,用于标识更改
|
2023-01-09 16:17:03 +08:00
|
|
|
|
Graph_Operate 图片操作,见头文件
|
|
|
|
|
Graph_Layer 图层0-9
|
|
|
|
|
Graph_Color 图形颜色
|
2023-01-09 21:50:17 +08:00
|
|
|
|
Graph_StartAngle,Graph_EndAngle 起始终止角度
|
|
|
|
|
Graph_Width 图形线宽
|
|
|
|
|
Start_y,Start_y 圆心xy坐标
|
|
|
|
|
x_Length,y_Length xy半轴长度
|
2023-01-09 16:17:03 +08:00
|
|
|
|
**********************************************************************************************************/
|
|
|
|
|
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void Arc_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
|
2023-01-12 15:24:56 +08:00
|
|
|
|
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)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
2023-01-24 22:37:53 +08:00
|
|
|
|
//memset(&graph,0,UI_Operate_LEN_PerDraw);
|
2023-01-09 16:17:03 +08:00
|
|
|
|
int i;
|
2023-01-09 21:50:17 +08:00
|
|
|
|
for(i=0;i<3&&graphname[i]!='\0';i++)
|
|
|
|
|
{
|
|
|
|
|
graph->graphic_name[2-i]=graphname[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
graph->graphic_tpye = UI_Graph_Arc;
|
|
|
|
|
graph->operate_tpye = Graph_Operate;
|
|
|
|
|
graph->layer = Graph_Layer;
|
|
|
|
|
graph->color = Graph_Color;
|
|
|
|
|
|
|
|
|
|
graph->start_angle = Graph_StartAngle;
|
|
|
|
|
graph->end_angle = Graph_EndAngle;
|
|
|
|
|
graph->width = Graph_Width;
|
|
|
|
|
graph->start_x = Start_x;
|
|
|
|
|
graph->start_y = Start_y;
|
|
|
|
|
graph->end_x = end_x;
|
|
|
|
|
graph->end_y = end_y;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************************绘制浮点型数据*************************************************
|
2023-01-09 21:50:17 +08:00
|
|
|
|
**参数:*graph Graph_Data类型变量指针,用于存放图形数据
|
|
|
|
|
graphname[3] 图片名称,用于标识更改
|
2023-01-09 16:17:03 +08:00
|
|
|
|
Graph_Operate 图片操作,见头文件
|
|
|
|
|
Graph_Layer 图层0-9
|
|
|
|
|
Graph_Color 图形颜色
|
|
|
|
|
Graph_Size 字号
|
|
|
|
|
Graph_Digit 小数位数
|
2023-01-09 21:50:17 +08:00
|
|
|
|
Graph_Width 图形线宽
|
2023-01-09 16:17:03 +08:00
|
|
|
|
Start_x、Start_y 开始坐标
|
2023-01-12 15:24:56 +08:00
|
|
|
|
radius=a&0x3FF; a为浮点数乘以1000后的32位整型数
|
|
|
|
|
end_x=(a>>10)&0x7FF;
|
|
|
|
|
end_y=(a>>21)&0x7FF;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
**********************************************************************************************************/
|
2023-01-12 15:24:56 +08:00
|
|
|
|
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void Float_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
|
2023-01-12 15:24:56 +08:00
|
|
|
|
uint32_t Graph_Size,uint32_t Graph_Digit,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,int32_t Graph_Float)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
2023-01-24 22:37:53 +08:00
|
|
|
|
//memset(&graph,0,UI_Operate_LEN_PerDraw);
|
2023-01-12 15:24:56 +08:00
|
|
|
|
int i;
|
2023-01-09 21:50:17 +08:00
|
|
|
|
for(i=0;i<3&&graphname[i]!='\0';i++)
|
2023-01-12 15:24:56 +08:00
|
|
|
|
{
|
2023-01-09 21:50:17 +08:00
|
|
|
|
graph->graphic_name[2-i]=graphname[i];
|
2023-01-12 15:24:56 +08:00
|
|
|
|
}
|
2023-01-09 21:50:17 +08:00
|
|
|
|
graph->graphic_tpye = UI_Graph_Float;
|
|
|
|
|
graph->operate_tpye = Graph_Operate;
|
|
|
|
|
graph->layer = Graph_Layer;
|
|
|
|
|
graph->color = Graph_Color;
|
2023-01-12 15:24:56 +08:00
|
|
|
|
|
2023-01-09 21:50:17 +08:00
|
|
|
|
graph->width = Graph_Width;
|
|
|
|
|
graph->start_x = Start_x;
|
|
|
|
|
graph->start_y = Start_y;
|
|
|
|
|
graph->start_angle = Graph_Size;
|
|
|
|
|
graph->end_angle = Graph_Digit;
|
2023-01-12 15:24:56 +08:00
|
|
|
|
|
|
|
|
|
graph->radius=Graph_Float&0x3FF;
|
|
|
|
|
graph->end_x=(Graph_Float>>10)&0x7FF;
|
|
|
|
|
graph->end_y=(Graph_Float>>21)&0x7FF;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-12 15:24:56 +08:00
|
|
|
|
/************************************************绘制整型数据*************************************************
|
2023-01-09 21:50:17 +08:00
|
|
|
|
**参数:*graph Graph_Data类型变量指针,用于存放图形数据
|
|
|
|
|
graphname[3] 图片名称,用于标识更改
|
2023-01-09 16:17:03 +08:00
|
|
|
|
Graph_Operate 图片操作,见头文件
|
|
|
|
|
Graph_Layer 图层0-9
|
|
|
|
|
Graph_Color 图形颜色
|
2023-01-12 15:24:56 +08:00
|
|
|
|
Graph_Size 字号
|
|
|
|
|
Graph_Width 图形线宽
|
2023-01-09 16:17:03 +08:00
|
|
|
|
Start_x、Start_y 开始坐标
|
2023-01-12 15:24:56 +08:00
|
|
|
|
radius=a&0x3FF; a为32位整型数
|
|
|
|
|
end_x=(a>>10)&0x7FF;
|
|
|
|
|
end_y=(a>>21)&0x7FF;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
**********************************************************************************************************/
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void Integer_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
|
2023-01-12 15:24:56 +08:00
|
|
|
|
uint32_t Graph_Size,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,int32_t Graph_Integer)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
2023-01-24 22:37:53 +08:00
|
|
|
|
//memset(&graph,0,UI_Operate_LEN_PerDraw);
|
2023-01-12 15:24:56 +08:00
|
|
|
|
int i;
|
2023-01-09 21:50:17 +08:00
|
|
|
|
for(i=0;i<3&&graphname[i]!='\0';i++)
|
2023-01-12 15:24:56 +08:00
|
|
|
|
{
|
|
|
|
|
graph->graphic_name[2-i]=graphname[i];
|
|
|
|
|
}
|
|
|
|
|
graph->graphic_tpye = UI_Graph_Int;
|
|
|
|
|
graph->operate_tpye = Graph_Operate;
|
|
|
|
|
graph->layer = Graph_Layer;
|
|
|
|
|
graph->color = Graph_Color;
|
|
|
|
|
|
|
|
|
|
graph->start_angle = Graph_Size;
|
|
|
|
|
graph->width = Graph_Width;
|
|
|
|
|
graph->start_x = Start_x;
|
|
|
|
|
graph->start_y = Start_y;
|
|
|
|
|
|
|
|
|
|
graph->radius=Graph_Integer&0x3FF;
|
|
|
|
|
graph->end_x=(Graph_Integer>>10)&0x7FF;
|
|
|
|
|
graph->end_y=(Graph_Integer>>21)&0x7FF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************绘制字符型数据*************************************************
|
|
|
|
|
**参数:*graph Graph_Data类型变量指针,用于存放图形数据
|
|
|
|
|
graphname[3] 图片名称,用于标识更改
|
|
|
|
|
Graph_Operate 图片操作,见头文件
|
|
|
|
|
Graph_Layer 图层0-9
|
|
|
|
|
Graph_Color 图形颜色
|
|
|
|
|
Graph_Size 字号
|
|
|
|
|
Graph_Width 图形线宽
|
|
|
|
|
Start_x、Start_y 开始坐标
|
|
|
|
|
**********************************************************************************************************/
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void Char_Draw(String_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color,
|
2023-01-12 15:24:56 +08:00
|
|
|
|
uint32_t Graph_Size,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y)
|
|
|
|
|
{
|
2023-01-24 22:37:53 +08:00
|
|
|
|
// //memset(graph->Graph_Control.graphic_name, 0, 3);//syhtodo 是否需要手动清零
|
|
|
|
|
//memset(&graph,0,UI_Operate_LEN_DrawChar);
|
2023-01-12 15:24:56 +08:00
|
|
|
|
int i;
|
|
|
|
|
for(i=0;i<3&&graphname[i]!='\0';i++)
|
|
|
|
|
{
|
|
|
|
|
graph->Graph_Control.graphic_name[2-i]=graphname[i];
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-09 21:50:17 +08:00
|
|
|
|
graph->Graph_Control.graphic_tpye = UI_Graph_Char;
|
|
|
|
|
graph->Graph_Control.operate_tpye = Graph_Operate;
|
|
|
|
|
graph->Graph_Control.layer = Graph_Layer;
|
|
|
|
|
graph->Graph_Control.color = Graph_Color;
|
2023-01-12 15:24:56 +08:00
|
|
|
|
|
2023-01-09 21:50:17 +08:00
|
|
|
|
graph->Graph_Control.width = Graph_Width;
|
|
|
|
|
graph->Graph_Control.start_x = Start_x;
|
|
|
|
|
graph->Graph_Control.start_y = Start_y;
|
|
|
|
|
graph->Graph_Control.start_angle = Graph_Size;
|
2023-01-12 15:24:56 +08:00
|
|
|
|
|
|
|
|
|
//syhtodo无关的赋值为0
|
|
|
|
|
graph->Graph_Control.radius=0;
|
|
|
|
|
graph->Graph_Control.end_x=0;
|
|
|
|
|
graph->Graph_Control.end_y=0;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-12 15:24:56 +08:00
|
|
|
|
/************************************************绘制字符型数据*************************************************
|
|
|
|
|
**参数:*graph Graph_Data类型变量指针,用于存放图形数据
|
|
|
|
|
fmt需要显示的字符串
|
2023-01-24 22:37:53 +08:00
|
|
|
|
此函数的实现和具体使用类似于printf函数
|
2023-01-12 15:24:56 +08:00
|
|
|
|
**********************************************************************************************************/
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void Char_Write(String_Data_t *graph,char* fmt, ...)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
|
|
|
|
uint16_t i = 0;
|
|
|
|
|
va_list ap;
|
2023-01-12 15:24:56 +08:00
|
|
|
|
va_start(ap,fmt);
|
2023-01-24 22:37:53 +08:00
|
|
|
|
vsprintf((char*)graph->show_Data,fmt,ap);//使用参数列表进行格式化并输出到字符串
|
2023-01-09 16:17:03 +08:00
|
|
|
|
va_end(ap);
|
2023-01-09 21:50:17 +08:00
|
|
|
|
i = strlen((const char*)graph->show_Data);
|
|
|
|
|
graph->Graph_Control.end_angle = i;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
2023-01-12 15:24:56 +08:00
|
|
|
|
/* UI推送函数(使更改生效)
|
|
|
|
|
参数: cnt 图形个数
|
|
|
|
|
... 图形变量参数
|
|
|
|
|
Tips::该函数只能推送1,2,5,7个图形,其他数目协议未涉及
|
|
|
|
|
*/
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void UI_ReFresh(referee_id_t *_id,int cnt,...)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
2023-01-09 21:50:17 +08:00
|
|
|
|
int i;
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_GraphReFresh_t UI_GraphReFresh_data;
|
|
|
|
|
Graph_Data_t graphData;
|
2023-01-09 21:50:17 +08:00
|
|
|
|
|
|
|
|
|
va_list ap;//创建一个 va_list 类型变量
|
|
|
|
|
va_start(ap,cnt);//初始化 va_list 变量为一个参数列表
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
|
|
|
|
UI_GraphReFresh_data.FrameHeader.SOF = REFEREE_SOF;
|
2023-01-14 21:50:58 +08:00
|
|
|
|
UI_GraphReFresh_data.FrameHeader.DataLength = UI_Data_LEN_Head+cnt*UI_Operate_LEN_PerDraw;
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_GraphReFresh_data.FrameHeader.Seq = UI_Seq;
|
2023-01-14 21:50:58 +08:00
|
|
|
|
UI_GraphReFresh_data.FrameHeader.CRC8 = Get_CRC8_Check_Sum((uint8_t *)&UI_GraphReFresh_data,LEN_CRC8,0xFF);
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
|
|
|
|
UI_GraphReFresh_data.CmdID = ID_student_interactive;
|
|
|
|
|
|
2023-01-14 21:50:58 +08:00
|
|
|
|
switch(cnt)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
|
|
|
|
case 1:
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_GraphReFresh_data.datahead.data_cmd_id=UI_Data_ID_Draw1;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_GraphReFresh_data.datahead.data_cmd_id=UI_Data_ID_Draw2;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
break;
|
|
|
|
|
case 5:
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_GraphReFresh_data.datahead.data_cmd_id=UI_Data_ID_Draw5;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
break;
|
|
|
|
|
case 7:
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_GraphReFresh_data.datahead.data_cmd_id=UI_Data_ID_Draw7;
|
2023-01-09 16:17:03 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2023-01-14 21:50:58 +08:00
|
|
|
|
|
2023-01-15 21:11:15 +08:00
|
|
|
|
UI_GraphReFresh_data.datahead.receiver_ID = _id->Cilent_ID;
|
|
|
|
|
UI_GraphReFresh_data.datahead.sender_ID = _id->Robot_ID;
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
2023-01-14 21:50:58 +08:00
|
|
|
|
//先发送帧头、命令码、交互数据帧头三部分,并计算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);
|
2023-01-14 22:39:26 +08:00
|
|
|
|
|
2023-01-14 21:50:58 +08:00
|
|
|
|
for(i=0;i<cnt;i++) //发送交互数据的数据帧,并计算CRC16校验值
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
2023-01-13 21:45:04 +08:00
|
|
|
|
graphData=va_arg(ap,Graph_Data_t);//访问参数列表中的每个项,第二个参数是你要返回的参数的类型,在取值时需要将其强制转化为指定类型的变量
|
2023-01-14 22:39:26 +08:00
|
|
|
|
//发送并计算CRC16
|
2023-01-14 21:50:58 +08:00
|
|
|
|
RefereeSend((uint8_t *)&graphData,UI_Operate_LEN_PerDraw);
|
2023-01-14 22:39:26 +08:00
|
|
|
|
UI_GraphReFresh_data.frametail=Get_CRC16_Check_Sum((uint8_t *)&graphData,UI_Operate_LEN_PerDraw,UI_GraphReFresh_data.frametail);
|
2023-01-09 16:17:03 +08:00
|
|
|
|
}
|
2023-01-09 21:50:17 +08:00
|
|
|
|
|
2023-01-13 21:45:04 +08:00
|
|
|
|
RefereeSend((uint8_t *)&UI_GraphReFresh_data.frametail,LEN_TAIL); //发送CRC16校验值
|
2023-01-09 21:50:17 +08:00
|
|
|
|
|
|
|
|
|
va_end(ap);//结束可变参数的获取
|
|
|
|
|
UI_Seq++; //包序号+1
|
2023-01-09 16:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************************UI推送字符(使更改生效)*********************************/
|
2023-01-24 22:37:53 +08:00
|
|
|
|
void Char_ReFresh(referee_id_t *_id,String_Data_t string_Data)
|
2023-01-09 16:17:03 +08:00
|
|
|
|
{
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_CharReFresh_t UI_CharReFresh_data;
|
|
|
|
|
|
2023-01-14 21:50:58 +08:00
|
|
|
|
uint8_t temp_datalength = UI_Data_LEN_Head + UI_Operate_LEN_DrawChar; //计算交互数据长度
|
|
|
|
|
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_CharReFresh_data.FrameHeader.SOF = REFEREE_SOF;
|
2023-01-14 21:50:58 +08:00
|
|
|
|
UI_CharReFresh_data.FrameHeader.DataLength = temp_datalength;
|
2023-01-13 21:45:04 +08:00
|
|
|
|
UI_CharReFresh_data.FrameHeader.Seq = UI_Seq;
|
2023-01-14 21:50:58 +08:00
|
|
|
|
UI_CharReFresh_data.FrameHeader.CRC8 = Get_CRC8_Check_Sum((uint8_t *)&UI_CharReFresh_data,LEN_CRC8,0xFF);
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
|
|
|
|
UI_CharReFresh_data.CmdID = ID_student_interactive;
|
|
|
|
|
|
|
|
|
|
UI_CharReFresh_data.datahead.data_cmd_id = UI_Data_ID_DrawChar;
|
2023-01-15 21:11:15 +08:00
|
|
|
|
|
|
|
|
|
UI_CharReFresh_data.datahead.receiver_ID = _id->Cilent_ID;
|
|
|
|
|
UI_CharReFresh_data.datahead.sender_ID = _id->Robot_ID;
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
|
|
|
|
UI_CharReFresh_data.String_Data = string_Data;
|
|
|
|
|
|
2023-01-14 21:50:58 +08:00
|
|
|
|
UI_CharReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_CharReFresh_data,LEN_HEADER+LEN_CMDID+temp_datalength,0xFFFF);
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
2023-01-14 21:50:58 +08:00
|
|
|
|
RefereeSend((uint8_t *)&UI_CharReFresh_data,LEN_HEADER+LEN_CMDID+temp_datalength+LEN_TAIL); //发送
|
2023-01-13 21:45:04 +08:00
|
|
|
|
|
2023-01-09 16:17:03 +08:00
|
|
|
|
UI_Seq++; //包序号+1
|
|
|
|
|
}
|
2023-01-15 21:11:15 +08:00
|
|
|
|
|