diff --git a/HAL_N_Middlewares/Src/main.c b/HAL_N_Middlewares/Src/main.c index d1be4f8..b89d655 100644 --- a/HAL_N_Middlewares/Src/main.c +++ b/HAL_N_Middlewares/Src/main.c @@ -33,11 +33,6 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "robot.h" -//////////////////////////////////////////////////syhtodo -#include "referee_UI.h" -#include "referee.h" -#include "referee_def.h" -////////////////////////////////////////////////// /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -118,33 +113,6 @@ int main(void) RobotInit(); - -//////////////////////////////////////////////////syhtodo - 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); - 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,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",123); - Char_ReFresh(sdata[0]); - -////////////////////////////////////////////////// - /* USER CODE END 2 */ /* Call init function for freertos objects (in freertos.c) */ diff --git a/application/chassis/chassis.c b/application/chassis/chassis.c index 75ede1f..184045a 100644 --- a/application/chassis/chassis.c +++ b/application/chassis/chassis.c @@ -19,7 +19,7 @@ #include "referee.h" #include "general_def.h" #include "bsp_dwt.h" - +#include "referee_UI.h" #include "arm_math.h" /* 根据robot_def.h中的macro自动计算的参数 */ @@ -41,7 +41,7 @@ static Subscriber_t *chassis_sub; // 用于订阅底盘的控 static Chassis_Ctrl_Cmd_s chassis_cmd_recv; // 底盘接收到的控制命令 static Chassis_Upload_Data_s chassis_feedback_data; // 底盘回传的反馈数据 -static referee_info_t *referee_data; // 裁判系统的数据 +static referee_info_t *referee_data; // 裁判系统相关数据 static SuperCapInstance *cap; // 超级电容 static DJIMotorInstance *motor_lf; // left right forward back static DJIMotorInstance *motor_rf; @@ -101,6 +101,10 @@ void ChassisInit() referee_data = RefereeInit(&huart6); // 裁判系统初始化 + while (referee_data->GameRobotState.robot_id ==0); + Interactive_init(referee_data); + + SuperCap_Init_Config_s cap_conf = { .can_config = { .can_handle = &hcan2, diff --git a/modules/referee/referee.c b/modules/referee/referee.c index 3e9256f..7500ccf 100644 --- a/modules/referee/referee.c +++ b/modules/referee/referee.c @@ -22,7 +22,6 @@ referee_info_t *RefereeInit(UART_HandleTypeDef *referee_usart_handle) return &referee_info; } - /** * @brief 发送函数 * @param send 待发送数据 @@ -30,11 +29,10 @@ referee_info_t *RefereeInit(UART_HandleTypeDef *referee_usart_handle) void RefereeSend(uint8_t *send,uint16_t tx_len) { USARTSend(referee_usart_instance,send,tx_len); - /* syhtodo DMA请求过快会导致数据发送丢失,考虑数据尽可能打成一阵个包 */ + /* syhtodo DMA请求过快会导致数据发送丢失,考虑数据尽可能打成一个整包以及队列发送 */ HAL_Delay(5); } - /*裁判系统串口接收回调函数,解析数据 */ static void RefereeRxCallback() { @@ -76,49 +74,38 @@ static void JudgeReadData(uint8_t *ReadFromUsart) case ID_game_state: // 0x0001 memcpy(&referee_info.GameState, (ReadFromUsart + DATA_Offset), LEN_game_state); break; - case ID_game_result: // 0x0002 memcpy(&referee_info.GameResult, (ReadFromUsart + DATA_Offset), LEN_game_result); break; - case ID_game_robot_survivors: // 0x0003 memcpy(&referee_info.GameRobotHP, (ReadFromUsart + DATA_Offset), LEN_game_robot_HP); break; - case ID_event_data: // 0x0101 memcpy(&referee_info.EventData, (ReadFromUsart + DATA_Offset), LEN_event_data); break; - case ID_supply_projectile_action: // 0x0102 memcpy(&referee_info.SupplyProjectileAction, (ReadFromUsart + DATA_Offset), LEN_supply_projectile_action); break; - case ID_game_robot_state: // 0x0201 memcpy(&referee_info.GameRobotState, (ReadFromUsart + DATA_Offset), LEN_game_robot_state); break; case ID_power_heat_data: // 0x0202 memcpy(&referee_info.PowerHeatData, (ReadFromUsart + DATA_Offset), LEN_power_heat_data); break; - case ID_game_robot_pos: // 0x0203 memcpy(&referee_info.GameRobotPos, (ReadFromUsart + DATA_Offset), LEN_game_robot_pos); break; - case ID_buff_musk: // 0x0204 memcpy(&referee_info.BuffMusk, (ReadFromUsart + DATA_Offset), LEN_buff_musk); break; - case ID_aerial_robot_energy: // 0x0205 memcpy(&referee_info.AerialRobotEnergy, (ReadFromUsart + DATA_Offset), LEN_aerial_robot_energy); break; - case ID_robot_hurt: // 0x0206 memcpy(&referee_info.RobotHurt, (ReadFromUsart + DATA_Offset), LEN_robot_hurt); break; - case ID_shoot_data: // 0x0207 memcpy(&referee_info.ShootData, (ReadFromUsart + DATA_Offset), LEN_shoot_data); - // JUDGE_ShootNumCount();//发弹量统计 break; } } @@ -130,4 +117,4 @@ static void JudgeReadData(uint8_t *ReadFromUsart) JudgeReadData(ReadFromUsart + sizeof(xFrameHeader) + LEN_CMDID + referee_info.FrameHeader.DataLength + LEN_TAIL); } } -} \ No newline at end of file +} diff --git a/modules/referee/referee.h b/modules/referee/referee.h index 377129b..798f24b 100644 --- a/modules/referee/referee.h +++ b/modules/referee/referee.h @@ -16,18 +16,21 @@ #include "referee_def.h" #include "bsp_usart.h" - -#define FALSE 0 -#define TRUE 1 - -#define JUDGE_DATA_ERROR 0 -#define JUDGE_DATA_CORRECT 1 - #pragma pack(1) -// 裁判系统接收数据整合进一个结构体 typedef struct { + uint8_t Robot_Color; //机器人颜色 + uint16_t Robot_ID; //本机器人ID + uint16_t Cilent_ID; //本机器人对应的客户端ID + uint16_t Receiver_Robot_ID; //机器人车间通信时接收者的ID +} referee_id_t; + +// 次结构体包含裁判系统接收数据以及UI绘制与机器人车间通信的相关信息 +typedef struct +{ + referee_id_t referee_id; + xFrameHeader FrameHeader; // 接收到的帧头信息 uint16_t CmdID; ext_game_state_t GameState; // 0x0001 @@ -43,8 +46,7 @@ typedef struct ext_robot_hurt_t RobotHurt; // 0x0206 ext_shoot_data_t ShootData; // 0x0207 - // ext_SendClientData_t ShowData; // 客户端信息 - // ext_CommunatianData_t CommuData; // 队友通信信息 + // syhtodo 机器人间通信如何获取数据 } referee_info_t; @@ -52,19 +54,19 @@ typedef struct /** * @brief 初始化裁判系统,返回接收数据指针 - * - * @param referee_usart_handle - * @return referee_info_t* + * + * @param referee_usart_handle + * @return referee_info_t* */ -referee_info_t* RefereeInit(UART_HandleTypeDef *referee_usart_handle); +referee_info_t *RefereeInit(UART_HandleTypeDef *referee_usart_handle); /** * @brief 发送函数 - * @todo + * @todo * @param send 待发送数据 */ -void RefereeSend(uint8_t *send,uint16_t tx_len); +void RefereeSend(uint8_t *send, uint16_t tx_len); -extern USARTInstance *referee_usart_instance; +extern USARTInstance *referee_usart_instance; #endif // !REFEREE_H diff --git a/modules/referee/referee_UI.c b/modules/referee/referee_UI.c index ec436cd..852a399 100644 --- a/modules/referee/referee_UI.c +++ b/modules/referee/referee_UI.c @@ -2,23 +2,90 @@ #include "string.h" #include "crc.h" #include "bsp_usart.h" -#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; +static void UI_Delete(referee_id_t *_id,uint8_t Del_Operate,uint8_t Del_Layer); +static 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); +static 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); +static 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); +static 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); +static 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); +static 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); +static 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); +static 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); +static void Char_Write(String_Data_t *graph,char* fmt, ...); +static int UI_ReFresh(referee_id_t *_id,int cnt,...); +static int Char_ReFresh(referee_id_t *_id,String_Data_t string_Data); + +static void determine_ID(referee_info_t *_referee_info); + +static uint8_t UI_Seq; //包序号 + +void Interactive_init(referee_info_t *_referee_info) +{ + determine_ID(_referee_info); + + + 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(&_referee_info->referee_id,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,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,1245545); + Integer_Draw(&num[1],"s6",UI_Graph_ADD,0,UI_Color_Cyan,50,5,1050,460,12345); + UI_ReFresh(&_referee_info->referee_id,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",123); + Char_ReFresh(&_referee_info->referee_id,sdata[0]); + +} + +/** + * @brief 判断各种ID,选择客户端ID + * @param void + * @retval referee_info + * @attention + */ +static void determine_ID(referee_info_t *_referee_info) +{ + //id小于7是红色,大于7是蓝色,0为红色,1为蓝色 #define Robot_Red 0 #define Robot_Blue 1 + _referee_info->referee_id.Robot_Color = _referee_info->GameRobotState.robot_id >7 ? Robot_Blue : Robot_Red; + _referee_info->referee_id.Robot_ID=_referee_info->GameRobotState.robot_id; + _referee_info->referee_id.Cilent_ID = 0x0100 + _referee_info->referee_id.Robot_ID;//计算客户端ID + _referee_info->referee_id.Receiver_Robot_ID = 0x00; //机器人车间通信时接收者的ID暂时为0 +} + + + + -uint8_t UI_Seq; //包序号 /********************************************删除操作************************************* **参数:Del_Operate 对应头文件删除操作 Del_Layer 要删除的层 取值0-9 *****************************************************************************************/ -void UI_Delete(uint8_t Del_Operate,uint8_t Del_Layer) +static void UI_Delete(referee_id_t *_id,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; //计算交互数据长度 @@ -31,8 +98,8 @@ void UI_Delete(uint8_t Del_Operate,uint8_t Del_Layer) UI_delete_data.CmdID = ID_student_interactive; 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; + UI_delete_data.datahead.receiver_ID = _id->Cilent_ID; + UI_delete_data.datahead.sender_ID = _id->Robot_ID; UI_delete_data.Delete_Operate = Del_Operate; //删除操作 UI_delete_data.Layer = Del_Layer; @@ -55,7 +122,7 @@ void UI_Delete(uint8_t Del_Operate,uint8_t Del_Layer) End_x、End_y 终点xy坐标 **********************************************************************************************************/ -void Line_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color, +static 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; @@ -87,7 +154,7 @@ void Line_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint Start_x、Start_y 起点xy坐标 End_x、End_y 对角顶点xy坐标 **********************************************************************************************************/ -void Rectangle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color, +static 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; @@ -119,7 +186,7 @@ void Rectangle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate Graph_Radius 圆形半径 **********************************************************************************************************/ -void Circle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color, +static 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; @@ -148,7 +215,7 @@ void Circle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,ui Start_x、Start_y 圆心xy坐标 End_x、End_y xy半轴长度 **********************************************************************************************************/ -void Elliptical_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color, +static 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; @@ -182,7 +249,7 @@ void Elliptical_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operat x_Length,y_Length xy半轴长度 **********************************************************************************************************/ -void Arc_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color, +static 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) { @@ -221,7 +288,7 @@ void Arc_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint3 end_y=(a>>21)&0x7FF; **********************************************************************************************************/ -void Float_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color, +static 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; @@ -258,7 +325,7 @@ void Float_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uin end_x=(a>>10)&0x7FF; end_y=(a>>21)&0x7FF; **********************************************************************************************************/ -void Integer_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color, +static 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; @@ -292,7 +359,7 @@ void Integer_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operate,u Graph_Width 图形线宽 Start_x、Start_y 开始坐标 **********************************************************************************************************/ -void Char_Draw(String_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uint32_t Graph_Layer,uint32_t Graph_Color, +static 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);//syhtodo 是否需要手动清零 @@ -323,7 +390,7 @@ void Char_Draw(String_Data_t *graph,char graphname[3],uint32_t Graph_Operate,uin fmt需要显示的字符串 syhtodo 尚未理解该函数的写法 **********************************************************************************************************/ -void Char_Write(String_Data_t *graph,char* fmt, ...) +static void Char_Write(String_Data_t *graph,char* fmt, ...) { uint16_t i = 0; va_list ap; @@ -340,7 +407,7 @@ void Char_Write(String_Data_t *graph,char* fmt, ...) ... 图形变量参数 Tips::该函数只能推送1,2,5,7个图形,其他数目协议未涉及 */ -int UI_ReFresh(int cnt,...) +static int UI_ReFresh(referee_id_t *_id,int cnt,...) { int i; UI_GraphReFresh_t UI_GraphReFresh_data; @@ -374,8 +441,8 @@ int UI_ReFresh(int cnt,...) return (-1); } - UI_GraphReFresh_data.datahead.receiver_ID = Cilent_ID; - UI_GraphReFresh_data.datahead.sender_ID = Robot_ID; + UI_GraphReFresh_data.datahead.receiver_ID = _id->Cilent_ID; + UI_GraphReFresh_data.datahead.sender_ID = _id->Robot_ID; //先发送帧头、命令码、交互数据帧头三部分,并计算CRC16校验值 UI_GraphReFresh_data.frametail=Get_CRC16_Check_Sum((uint8_t *)&UI_GraphReFresh_data,LEN_HEADER+LEN_CMDID+UI_Data_LEN_Head,0xFFFF); @@ -398,7 +465,7 @@ int UI_ReFresh(int cnt,...) } /************************************************UI推送字符(使更改生效)*********************************/ -int Char_ReFresh(String_Data_t string_Data) +static int Char_ReFresh(referee_id_t *_id,String_Data_t string_Data) { UI_CharReFresh_t UI_CharReFresh_data; @@ -412,8 +479,9 @@ int Char_ReFresh(String_Data_t string_Data) UI_CharReFresh_data.CmdID = ID_student_interactive; 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; + + UI_CharReFresh_data.datahead.receiver_ID = _id->Cilent_ID; + UI_CharReFresh_data.datahead.sender_ID = _id->Robot_ID; UI_CharReFresh_data.String_Data = string_Data; @@ -424,50 +492,4 @@ int Char_ReFresh(String_Data_t string_Data) UI_Seq++; //包序号+1 return 0; } - - - - - - - -// /** -// * @brief 判断自己红蓝方 -// * @param void -// * @retval RED BLUE -// * @attention 数据打包,打包完成后通过串口发送到裁判系统 -// */ - -// bool is_red_or_blue(void) -// { -// Judge_Self_ID = GameRobotStat.robot_id;//读取当前机器人ID - -// if(GameRobotStat.robot_id > 10) -// { -// return BLUE; -// } -// else -// { -// return RED; -// } -// } - -// /** -// * @brief 判断自身ID,选择客户端ID -// * @param void -// * @retval RED BLUE -// * @attention 数据打包,打包完成后通过串口发送到裁判系统 -// */ -// void determine_ID(void) -// { -// Color = is_red_or_blue(); -// if(Color == BLUE) -// { - -// Judge_SelfClient_ID = 0x0110 + (Judge_Self_ID-10);//计算客户端ID -// } -// else if(Color == RED) -// { -// Judge_SelfClient_ID = 0x0100 + Judge_Self_ID;//计算客户端ID -// } -// } \ No newline at end of file + \ No newline at end of file diff --git a/modules/referee/referee_UI.h b/modules/referee/referee_UI.h index eff18ce..85752e2 100644 --- a/modules/referee/referee_UI.h +++ b/modules/referee/referee_UI.h @@ -5,44 +5,11 @@ #include "usart.h" #include "stdint.h" #include "referee_def.h" -#pragma pack(1) //按1字节对齐 +#include "referee.h" -// #define NULL 0 -#define __FALSE 100 - -/****************************红方机器人ID********************/ -#define UI_Data_RobotID_RHero 1 -#define UI_Data_RobotID_REngineer 2 -#define UI_Data_RobotID_RStandard1 3 -#define UI_Data_RobotID_RStandard2 4 -#define UI_Data_RobotID_RStandard3 5 -#define UI_Data_RobotID_RAerial 6 -#define UI_Data_RobotID_RSentry 7 -#define UI_Data_RobotID_RRadar 9 -/****************************蓝方机器人ID********************/ -#define UI_Data_RobotID_BHero 101 -#define UI_Data_RobotID_BEngineer 102 -#define UI_Data_RobotID_BStandard1 103 -#define UI_Data_RobotID_BStandard2 104 -#define UI_Data_RobotID_BStandard3 105 -#define UI_Data_RobotID_BAerial 106 -#define UI_Data_RobotID_BSentry 107 -#define UI_Data_RobotID_BRadar 109 -/**************************红方操作手ID************************/ -#define UI_Data_CilentID_RHero 0x0101 -#define UI_Data_CilentID_REngineer 0x0102 -#define UI_Data_CilentID_RStandard1 0x0103 -#define UI_Data_CilentID_RStandard2 0x0104 -#define UI_Data_CilentID_RStandard3 0x0105 -#define UI_Data_CilentID_RAerial 0x0106 -/***************************蓝方操作手ID***********************/ -#define UI_Data_CilentID_BHero 0x0165 -#define UI_Data_CilentID_BEngineer 0x0166 -#define UI_Data_CilentID_BStandard1 0x0167 -#define UI_Data_CilentID_BStandard2 0x0168 -#define UI_Data_CilentID_BStandard3 0x0169 -#define UI_Data_CilentID_BAerial 0x016A +#pragma pack(1) //按1字节对齐 +/* 此处的定义只与UI绘制有关 */ typedef struct { xFrameHeader FrameHeader; @@ -61,7 +28,6 @@ typedef struct uint16_t frametail; } UI_GraphReFresh_t; - typedef struct { xFrameHeader FrameHeader; @@ -71,23 +37,8 @@ typedef struct uint16_t frametail; } UI_CharReFresh_t; //打印字符串数据 - #pragma pack() -void UI_Delete(uint8_t Del_Operate,uint8_t Del_Layer); - -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_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); +void Interactive_init(referee_info_t *_referee_info); #endif diff --git a/modules/referee/referee_def.h b/modules/referee/referee_def.h index 24a7b07..e598af3 100644 --- a/modules/referee/referee_def.h +++ b/modules/referee/referee_def.h @@ -13,6 +13,13 @@ #include "stdint.h" +/****************************宏定义部分****************************/ +/****************************宏定义部分****************************/ + +#define REFEREE_SOF 0xA5 // 起始字节,协议固定为0xA5 +#define Robot_Red 0 +#define Robot_Blue 1 + #pragma pack(1) /****************************通信协议格式****************************/ @@ -24,7 +31,7 @@ typedef enum FRAME_HEADER_Offset = 0, CMD_ID_Offset = 5, DATA_Offset = 7, -} JudgeFrameOffset; +} JudgeFrameOffset_e; /* 通信协议长度 */ typedef enum @@ -34,12 +41,11 @@ typedef enum LEN_TAIL = 2, // 帧尾CRC16 LEN_CRC8 = 4, // 帧头CRC8校验长度=帧头+数据长+包序号 -} JudgeFrameLength; +} JudgeFrameLength_e; /****************************帧头****************************/ /****************************帧头****************************/ -#define REFEREE_SOF 0xA5 // 起始字节,协议固定为0xA5 /* 帧头偏移 */ typedef enum { @@ -47,7 +53,7 @@ typedef enum DATA_LENGTH = 1, // 帧内数据长度,根据这个来获取数据长度 SEQ = 3, // 包序号 CRC8 = 4 // CRC8 -} FrameHeaderOffset; +} FrameHeaderOffset_e; /* 帧头定义 */ typedef struct @@ -78,7 +84,7 @@ typedef enum ID_robot_hurt = 0x0206, // 伤害状态数据 ID_shoot_data = 0x0207, // 实时射击数据 ID_student_interactive = 0x0301, // 机器人间交互数据 -} CmdID; +} CmdID_e; /* 命令码数据段长,根据官方协议来定义长度 */ typedef enum @@ -95,7 +101,7 @@ typedef enum LEN_aerial_robot_energy = 1, // 0x0205 LEN_robot_hurt = 1, // 0x0206 LEN_shoot_data = 7, // 0x0207 -} JudgeDataLength; +} JudgeDataLength_e; /****************************接收数据的详细说明****************************/ /****************************接收数据的详细说明****************************/ @@ -242,7 +248,7 @@ typedef enum UI_Data_ID_Draw5 = 0x103, UI_Data_ID_Draw7 = 0x104, UI_Data_ID_DrawChar = 0x110, -} Interactive_Data_ID; +} Interactive_Data_ID_e; /* 交互数据长度 */ typedef enum { @@ -250,7 +256,7 @@ typedef enum UI_Operate_LEN_Del = 2, UI_Operate_LEN_PerDraw = 15, UI_Operate_LEN_DrawChar = 15 + 30, -} UI_Data_Length; +} UI_Data_Length_e; /****************************UI交互数据****************************/ @@ -286,7 +292,7 @@ typedef enum UI_Data_Del_NoOperate = 0, UI_Data_Del_Layer = 1, UI_Data_Del_ALL = 2, // 删除全部图层,后面的参数已经不重要了。 -} UI_Delete_Operate; +} UI_Delete_Operate_e; /* 图形配置参数__图形操作 */ typedef enum @@ -294,7 +300,7 @@ typedef enum UI_Graph_ADD = 1, UI_Graph_Change = 2, UI_Graph_Del = 3, -} UI_Graph_Operate; +} UI_Graph_Operate_e; /* 图形配置参数__图形类型 */ typedef enum @@ -308,7 +314,7 @@ typedef enum UI_Graph_Int = 6, // 整形 UI_Graph_Char = 7, // 字符型 -} UI_Graph_Type; +} UI_Graph_Type_e; /* 图形配置参数__图形颜色 */ typedef enum @@ -323,8 +329,7 @@ typedef enum UI_Color_Black = 7, UI_Color_White = 8, -} UI_Graph_Color; - +} UI_Graph_Color_e; #pragma pack()