diff --git a/HAL_N_Middlewares/Src/main.c b/HAL_N_Middlewares/Src/main.c index 4c31f58..662fda8 100644 --- a/HAL_N_Middlewares/Src/main.c +++ b/HAL_N_Middlewares/Src/main.c @@ -120,13 +120,24 @@ int main(void) ////////////////////////////////////////////////// Graph_Data graph[5]; + Graph_Data num[2]; + String_Data sdata[1]; + memset(sdata[0].show_Data, 0, 30); //使用memset方法 UI_Delete(UI_Data_Del_ALL,0); + Line_Draw(&graph[0],"s0",UI_Graph_ADD,0,UI_Color_White,3,710,540,1210,540); - Rectangle_Draw(&graph[1],"s1",UI_Graph_ADD,1,UI_Color_Yellow,4,600,200,800,500); - Circle_Draw(&graph[2],"s2",UI_Graph_ADD,2,UI_Color_Green,5,960,540,100); - Elliptical_Draw(&graph[3],"s3",UI_Graph_ADD,3,UI_Color_Orange,3,960,540,100,20); - Arc_Draw(&graph[4],"s4",UI_Graph_ADD,4,UI_Color_Purplish_red,30,160,3,1200,550,50,100); - UI_ReFresh(5,graph[0],graph[1],graph[2],graph[3],graph[4]); + Rectangle_Draw(&graph[1],"s1",UI_Graph_ADD,0,UI_Color_Yellow,4,600,200,800,500); + Circle_Draw(&graph[2],"s2",UI_Graph_ADD,0,UI_Color_Green,5,960,540,100); + 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); + 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",1234); + Char_ReFresh(sdata[0]); ////////////////////////////////////////////////// diff --git a/application/gimbal/gimbal.c b/application/gimbal/gimbal.c index 6081847..c193e87 100644 --- a/application/gimbal/gimbal.c +++ b/application/gimbal/gimbal.c @@ -16,7 +16,9 @@ static Gimbal_Ctrl_Cmd_s gimbal_cmd_recv; // 来自cmd的控制信息 void GimbalInit() { - gimba_IMU_data = INS_Init(); // IMU先初始化,获取姿态数据指针赋给yaw电机的其他数据来源 + /* syh referee不需要imu + 暂时关闭以加快初始化速度 */ + // gimba_IMU_data = INS_Init(); // IMU先初始化,获取姿态数据指针赋给yaw电机的其他数据来源 // YAW Motor_Init_Config_s yaw_config = { diff --git a/modules/referee/referee.c b/modules/referee/referee.c index 96df982..c486ddc 100644 --- a/modules/referee/referee.c +++ b/modules/referee/referee.c @@ -34,7 +34,7 @@ void RefereeSend(uint8_t *send,uint16_t tx_len) { USARTSend(referee_usart_instance,send,tx_len); /* syhtodo DMA请求过快会导致数据发送丢失,考虑数据尽可能打成一阵个包 */ - HAL_Delay(1); + HAL_Delay(5); } diff --git a/modules/referee/referee_UI.c b/modules/referee/referee_UI.c index 994d5d3..5f1b5dc 100644 --- a/modules/referee/referee_UI.c +++ b/modules/referee/referee_UI.c @@ -5,11 +5,11 @@ #include "dma.h" #include "stdio.h" #include "referee.h" - +/* syhtodo 根据自身id判断客户端id */ uint16_t Robot_ID = UI_Data_RobotID_BHero; uint16_t Cilent_ID = UI_Data_CilentID_BHero; -unsigned char UI_Seq; //包序号 +uint8_t UI_Seq; //包序号 /********************************************删除操作************************************* **参数:Del_Operate 对应头文件删除操作 @@ -192,7 +192,8 @@ void Elliptical_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate, **********************************************************************************************************/ 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) + 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) { int i; for(i=0;i<3&&graphname[i]!='\0';i++) @@ -214,8 +215,6 @@ void Arc_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_ graph->end_y = end_y; } - - /************************************************绘制浮点型数据************************************************* **参数:*graph Graph_Data类型变量指针,用于存放图形数据 graphname[3] 图片名称,用于标识更改 @@ -226,69 +225,129 @@ void Arc_Draw(Graph_Data *graph,char graphname[3],uint32_t Graph_Operate,uint32_ Graph_Digit 小数位数 Graph_Width 图形线宽 Start_x、Start_y 开始坐标 - Graph_Float 要显示的浮点数数值*1000 + radius=a&0x3FF; a为浮点数乘以1000后的32位整型数 + end_x=(a>>10)&0x7FF; + end_y=(a>>21)&0x7FF; **********************************************************************************************************/ -/* syhtodo浮点,整形,字符待编写或检查 */ -/* syhtodo需要解决位分配问腿,更换结构体 */ -void Float_Draw(Float_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 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) { - int i; + int i; for(i=0;i<3&&graphname[i]!='\0';i++) + { graph->graphic_name[2-i]=graphname[i]; + } graph->graphic_tpye = UI_Graph_Float; 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->start_angle = Graph_Size; graph->end_angle = Graph_Digit; - graph->graph_Float = Graph_Float; + + graph->radius=Graph_Float&0x3FF; + graph->end_x=(Graph_Float>>10)&0x7FF; + graph->end_y=(Graph_Float>>21)&0x7FF; } +/************************************************绘制整型数据************************************************* +**参数:*graph Graph_Data类型变量指针,用于存放图形数据 + graphname[3] 图片名称,用于标识更改 + Graph_Operate 图片操作,见头文件 + Graph_Layer 图层0-9 + Graph_Color 图形颜色 + Graph_Size 字号 + Graph_Width 图形线宽 + Start_x、Start_y 开始坐标 + radius=a&0x3FF; a为32位整型数 + 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, + uint32_t Graph_Size,uint32_t Graph_Width,uint32_t Start_x,uint32_t Start_y,int32_t Graph_Integer) +{ + int i; + for(i=0;i<3&&graphname[i]!='\0';i++) + { + 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_Size 字号 Graph_Width 图形线宽 Start_x、Start_y 开始坐标 -**********************************************************************************************************/ - -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) -{ - int i; +**********************************************************************************************************/ +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) +{ + memset(graph->Graph_Control.graphic_name, 0, 3); + int i; for(i=0;i<3&&graphname[i]!='\0';i++) - graph->Graph_Control.graphic_name[2-i]=graphname[i]; + { + graph->Graph_Control.graphic_name[2-i]=graphname[i]; + } + 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; + 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; + + //syhtodo无关的赋值为0 + graph->Graph_Control.radius=0; + graph->Graph_Control.end_x=0; + graph->Graph_Control.end_y=0; } +/************************************************绘制字符型数据************************************************* +**参数:*graph Graph_Data类型变量指针,用于存放图形数据 + fmt需要显示的字符串 +syhtodo 尚未理解该函数的写法 +**********************************************************************************************************/ void Char_Write(String_Data *graph,char* fmt, ...) { uint16_t i = 0; va_list ap; - va_start(ap, fmt); + va_start(ap,fmt); vsprintf((char*)graph->show_Data, fmt, ap); va_end(ap); i = strlen((const char*)graph->show_Data); graph->Graph_Control.end_angle = i; } -/************************************************UI推送函数(使更改生效)********************************* -**参数: cnt 图形个数 - ... 图形变量参数 -Tips::该函数只能推送1,2,5,7个图形,其他数目协议未涉及 -**********************************************************************************************************/ +/* UI推送函数(使更改生效) + 参数: cnt 图形个数 + ... 图形变量参数 + Tips::该函数只能推送1,2,5,7个图形,其他数目协议未涉及 + */ int UI_ReFresh(int cnt,...) { int i; @@ -386,7 +445,6 @@ int Char_ReFresh(String_Data string_Data) 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校验值 @@ -394,14 +452,6 @@ int Char_ReFresh(String_Data string_Data) return 0; } - - -// /** -// * @brief 上传自定义数据 -// * @param void -// * @retval void -// * @attention 数据打包,打包完成后通过串口发送到裁判系统 -// */ // #define send_max_len 200 // unsigned char CliendTxBuffer[send_max_len]; // void JUDGE_Show_Data(void) @@ -417,7 +467,7 @@ int Char_ReFresh(String_Data string_Data) // 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校验码 +// Append_CRC8_Check_Sum(CliendTxBuffer, sizeof(xFrameHeader));//写入帧头CRC8校验码 // ShowData.CmdID = 0x0301; diff --git a/modules/referee/referee_UI.h b/modules/referee/referee_UI.h index e6b1712..1b72fb9 100644 --- a/modules/referee/referee_UI.h +++ b/modules/referee/referee_UI.h @@ -55,7 +55,7 @@ /***************************删除操作***************************/ #define UI_Data_Del_NoOperate 0 #define UI_Data_Del_Layer 1 -#define UI_Data_Del_ALL 2 +#define UI_Data_Del_ALL 2 //删除全部图层,后面的参数已经不重要了。 /***************************图形配置参数__图形操作********************/ #define UI_Graph_ADD 1 #define UI_Graph_Change 2 @@ -80,16 +80,6 @@ #define UI_Color_Black 7 #define UI_Color_White 8 - - -typedef unsigned char Uint8_t; -typedef unsigned char uint8_t; - -extern uint16_t Robot_ID; -extern uint16_t Cilent_ID; - - - typedef struct { uint8_t SOF; //起始字节,固定0xA5 @@ -112,7 +102,7 @@ typedef struct uint8_t Layer; //删除图层 } UI_Data_Delete; //删除图层帧 -/* 是否有必要专门为浮点数定义?? */ +/* 图形数据 */ typedef struct { uint8_t graphic_name[3]; @@ -125,30 +115,9 @@ typedef struct uint32_t width:10; uint32_t start_x:11; uint32_t start_y:11; - int32_t graph_Float; - /* syhtodo - uint32_t 正好对应 - radius:10; uint32_t end_x:11; uint32_t end_y:11; - 三个变量,考虑位操作赋值,则不需要专门定义结构体 - */ -} Float_Data; - -/* 图形数据 */ -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; + uint32_t radius:10; + uint32_t end_x:11; + uint32_t end_y:11; } Graph_Data; @@ -161,22 +130,19 @@ typedef struct #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 Float_Draw(Float_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 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, ...); 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); -int Char_ReFresh(String_Data string_Data); +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); int UI_ReFresh(int cnt,...); -unsigned char Get_CRC8_Check_Sum_UI(unsigned char *pchMessage,unsigned int dwLength,unsigned char ucCRC8); -uint16_t Get_CRC16_Check_Sum_UI(uint8_t *pchMessage,uint32_t dwLength,uint16_t wCRC); +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); #endif