application中分离referee部分,相关代码重构,完成步兵UI的init

This commit is contained in:
kidneygood 2023-01-24 22:37:53 +08:00
parent 289530ac10
commit 68f7e64c2a
11 changed files with 385 additions and 133 deletions

View File

@ -198,7 +198,7 @@ void StartROBOTTASK(void const * argument)
{
// 200Hz
RobotTask();
osDelay(5);
osDelay(10);//syh此处暂时将时间改为10ms原因在于未使用缓冲区发送发送时延时5ms
}
}

View File

@ -131,7 +131,7 @@ modules/motor/step_motor/step_motor.c \
modules/motor/servo_motor/servo_motor.c \
modules/motor/motor_task.c \
modules/referee/crc.c \
modules/referee/referee.c \
modules/referee/rm_referee.c \
modules/referee/referee_UI.c \
modules/referee/referee_communication.c \
modules/remote/remote_control.c \
@ -143,6 +143,7 @@ modules/vofa/vofa.c \
application/gimbal/gimbal.c \
application/chassis/chassis.c \
application/shoot/shoot.c \
application/referee/referee.c \
application/cmd/robot_cmd.c \
application/robot.c
@ -224,6 +225,7 @@ C_INCLUDES = \
-Iapplication/shoot \
-Iapplication/gimbal \
-Iapplication/cmd \
-Iapplication/referee \
-Iapplication \
-Ibsp/dwt \
-Ibsp/can \

View File

@ -384,8 +384,8 @@ ROOT:.
├─referee
│ crc.c
│ crc.h
│ referee.c
│ referee.h
│ rm_referee.c
│ rm_referee.h
│ referee.md
│ referee_communication.c
│ referee_UI.c

View File

@ -16,7 +16,12 @@
#include "dji_motor.h"
#include "super_cap.h"
#include "message_center.h"
/////////////////////////
#include "referee.h"
#include "rm_referee.h"
/////////////////////////
#include "general_def.h"
#include "bsp_dwt.h"
#include "referee_UI.h"
@ -41,7 +46,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;
@ -99,10 +104,10 @@ void ChassisInit()
chassis_motor_config.controller_setting_init_config.reverse_flag = MOTOR_DIRECTION_NORMAL;
motor_rb = DJIMotorInit(&chassis_motor_config);
referee_data = RefereeInit(&huart6); // 裁判系统初始化
// referee_data = RefereeInit(&huart6); // 裁判系统初始化
while (referee_data->GameRobotState.robot_id ==0);
Interactive_init(referee_data);
// while (referee_data->GameRobotState.robot_id ==0);
// Referee_Interactive_init(referee_data);
SuperCap_Init_Config_s cap_conf = {
@ -240,12 +245,12 @@ void ChassisTask()
// 根据电机的反馈速度和IMU(如果有)计算真实速度
EstimateSpeed();
// 获取裁判系统数据
// 我方颜色id小于7是红色,大于7是蓝色,注意这里发送的是对方的颜色, 0:blue , 1:red
chassis_feedback_data.enemy_color = referee_data->GameRobotState.robot_id > 7 ? 1 : 0;
// 当前只做了17mm热量的数据获取,后续根据robot_def中的宏切换双枪管和英雄42mm的情况
chassis_feedback_data.bullet_speed = referee_data->GameRobotState.shooter_id1_17mm_speed_limit;
chassis_feedback_data.rest_heat = referee_data->PowerHeatData.shooter_heat0;
// // 获取裁判系统数据 建议将裁判系统与底盘分离,所以此处数据应使用消息中心发送
// // 我方颜色id小于7是红色,大于7是蓝色,注意这里发送的是对方的颜色, 0:blue , 1:red
// chassis_feedback_data.enemy_color = referee_data->GameRobotState.robot_id > 7 ? 1 : 0;
// // 当前只做了17mm热量的数据获取,后续根据robot_def中的宏切换双枪管和英雄42mm的情况
// chassis_feedback_data.bullet_speed = referee_data->GameRobotState.shooter_id1_17mm_speed_limit;
// chassis_feedback_data.rest_heat = referee_data->PowerHeatData.shooter_heat0;
// 推送反馈消息
#ifdef ONE_BOARD

View File

@ -0,0 +1,235 @@
/**
* @file referee.C
* @author kidneygood (you@domain.com)
* @brief
* @version 0.1
* @date 2022-11-18
*
* @copyright Copyright (c) 2022
*
*/
#include "referee.h"
#include "robot_def.h"
#include "rm_referee.h"
#include "referee_UI.h"
static Referee_Interactive_info_t *Interactive_data;// 非裁判系统数据
static referee_info_t *referee_data; // 裁判系统相关数据
static void determine_ID(referee_info_t *_referee_info);
static void My_UI_init(referee_info_t *_referee_info);
static void My_UI_Refresh(referee_info_t *_referee_info,Referee_Interactive_info_t *_Interactive_data);
void Referee_Interactive_init()
{
referee_data = RefereeInit(&huart6); // 裁判系统初始化
while (referee_data->GameRobotState.robot_id ==0);
determine_ID(referee_data);
My_UI_init(referee_data);
}
void Referee_Interactive_task()
{
My_UI_Refresh(referee_data,Interactive_data);
}
static Graph_Data_t UI_shoot_line[10];//射击准线
static String_Data_t UI_State_sta[5];//机器人状态,静态只需画一次
static String_Data_t UI_State_dyn[5];//机器人状态,动态先add才能change
static uint32_t shoot_line_location[10]={540,960,490,515,565};
static void My_UI_init(referee_info_t *_referee_info)
{
UI_Delete(&_referee_info->referee_id,UI_Data_Del_ALL,0);
//绘制发射基准线
Line_Draw(&UI_shoot_line[0],"sl0",UI_Graph_ADD,7,UI_Color_White,3,710,shoot_line_location[0],1210,shoot_line_location[0]);
Line_Draw(&UI_shoot_line[1],"sl1",UI_Graph_ADD,7,UI_Color_White,3,shoot_line_location[1],340,shoot_line_location[1],740);
Line_Draw(&UI_shoot_line[2],"sl2",UI_Graph_ADD,7,UI_Color_Yellow,2,810,shoot_line_location[2],1110,shoot_line_location[2]);
Line_Draw(&UI_shoot_line[3],"sl3",UI_Graph_ADD,7,UI_Color_Yellow,2,810,shoot_line_location[3],1110,shoot_line_location[3]);
Line_Draw(&UI_shoot_line[4],"sl4",UI_Graph_ADD,7,UI_Color_Yellow,2,810,shoot_line_location[4],1110,shoot_line_location[4]);
UI_ReFresh(&_referee_info->referee_id,5,UI_shoot_line[0],UI_shoot_line[1],UI_shoot_line[2],UI_shoot_line[3],UI_shoot_line[4]);
//绘制车辆状态标志,静态
Char_Draw(&UI_State_sta[0],"ss0",UI_Graph_ADD,8,UI_Color_Main,15,2,150,750);
Char_Write(&UI_State_sta[0],"chassis:");
Char_ReFresh(&_referee_info->referee_id,UI_State_sta[0]);
Char_Draw(&UI_State_sta[1],"ss1",UI_Graph_ADD,8,UI_Color_Yellow,15,2,150,700);
Char_Write(&UI_State_sta[1],"gimbal:");
Char_ReFresh(&_referee_info->referee_id,UI_State_sta[1]);
Char_Draw(&UI_State_sta[2],"ss2",UI_Graph_ADD,8,UI_Color_Orange,15,2,150,650);
Char_Write(&UI_State_sta[2],"cover:");
Char_ReFresh(&_referee_info->referee_id,UI_State_sta[2]);
Char_Draw(&UI_State_sta[3],"ss3",UI_Graph_ADD,8,UI_Color_Pink,15,2,150,600);
Char_Write(&UI_State_sta[3],"frict:");
Char_ReFresh(&_referee_info->referee_id,UI_State_sta[3]);
//底盘功率显示,静态
Char_Draw(&UI_State_sta[4],"ss4",UI_Graph_ADD,8,UI_Color_Green,18,2,720,210);
Char_Write(&UI_State_sta[4],"Power:");
Char_ReFresh(&_referee_info->referee_id,UI_State_sta[4]);
//绘制车辆状态标志,动态
Char_Draw(&UI_State_dyn[0],"sd0",UI_Graph_ADD,8,UI_Color_Main,15,2,270,750);
Char_Write(&UI_State_dyn[0],"0000");
Char_ReFresh(&_referee_info->referee_id,UI_State_dyn[0]);
Char_Draw(&UI_State_dyn[1],"sd1",UI_Graph_ADD,8,UI_Color_Yellow,15,2,270,700);
Char_Write(&UI_State_dyn[1],"0000");
Char_ReFresh(&_referee_info->referee_id,UI_State_dyn[1]);
Char_Draw(&UI_State_dyn[2],"sd2",UI_Graph_ADD,8,UI_Color_Orange,15,2,270,650);
Char_Write(&UI_State_dyn[2],"0000");
Char_ReFresh(&_referee_info->referee_id,UI_State_dyn[2]);
Char_Draw(&UI_State_dyn[3],"sd3",UI_Graph_ADD,8,UI_Color_Pink,15,2,270,600);
Char_Write(&UI_State_dyn[3],"0000");
Char_ReFresh(&_referee_info->referee_id,UI_State_dyn[3]);
//底盘功率显示,动态
Char_Draw(&UI_State_dyn[4],"sd4",UI_Graph_ADD,8,UI_Color_Green,18,2,840,210);
Char_Write(&UI_State_dyn[4],"0000");
Char_ReFresh(&_referee_info->referee_id,UI_State_dyn[4]);
}
static void My_UI_Refresh(referee_info_t *_referee_info,Referee_Interactive_info_t *_Interactive_data)
{
// syhtodo 按键刷新
// syhtodo与上次不一样才要进入刷新避免重复发送
// switch(dbus_infomation.chassis_mode)
// {
// case rotate_mode:
// {
// Char_Draw(&UI_State[0],"s1",UI_Graph_Change,8,UI_Color_Main,15,2,150,750);
// Char_Write(&UI_State[0],"chassis:rotate");
// break;
// }
// case back_middle_mode:
// {
// if (dbus_infomation.back_middle_mode_XL == X)
// {
// Char_Draw(&UI_State[0],"s1",UI_Graph_Change,8,UI_Color_Main,15,2,150,750);
// Char_Write(&UI_State[0],"chassis:follow_x");
// }
// else if (dbus_infomation.back_middle_mode_XL == L)
// {
// Char_Draw(&UI_State[0],"s1",UI_Graph_Change,8,UI_Color_Main,15,2,150,750);
// Char_Write(&UI_State[0],"chassis:follow_l");
// }
// break;
// }
// case free_mode:
// {
// Char_Draw(&UI_State[0],"s1",UI_Graph_Change,8,UI_Color_Main,15,2,150,750);
// Char_Write(&UI_State[0],"chassis:free ");
// break;
// }
// }
// Char_ReFresh(UI_State[0]);
// switch(dbus_infomation.gimbal_mode)
// {
// case mechanical_mode:
// {
// Char_Draw(&UI_State[1],"s2",UI_Graph_Change,8,UI_Color_Yellow,15,2,150,700);
// Char_Write(&UI_State[1],"gimbal:mech ");
// break;
// }
// case visual_mode:
// {
// Char_Draw(&UI_State[1],"s2",UI_Graph_Change,8,UI_Color_Yellow,15,2,150,700);
// Char_Write(&UI_State[1],"gimbal:visual");
// break;
// }
// case gyro_mode:
// {
// Char_Draw(&UI_State[1],"s2",UI_Graph_Change,8,UI_Color_Yellow,15,2,150,700);
// Char_Write(&UI_State[1],"gimbal:gyro ");
// break;
// }
// }
// Char_ReFresh(UI_State[1]);
// switch(dbus_infomation.cover_state)
// {
// case cover_close_sign:
// {
// Char_Draw(&UI_State[2],"s3",UI_Graph_Change,8,UI_Color_Orange,15,2,150,650);
// Char_Write(&UI_State[2],"cover:OFF");
// break;
// }
// case cover_open_sign:
// {
// Char_Draw(&UI_State[2],"s3",UI_Graph_Change,8,UI_Color_Orange,15,2,150,650);
// Char_Write(&UI_State[2],"cover:ON ");
// break;
// }
// }
// Char_ReFresh(UI_State[2]);
// switch(dbus_infomation.friction_state)
// {
// case friction_stop_sign:
// {
// Char_Draw(&UI_State[3],"s4",UI_Graph_Change,8,UI_Color_Pink,15,2,150,600);
// Char_Write(&UI_State[3],"friction:OFF");
// break;
// }
// case friction_start_sign:
// {
// Char_Draw(&UI_State[3],"s4",UI_Graph_Change,8,UI_Color_Pink,15,2,150,600);
// Char_Write(&UI_State[3],"friction:ON ");
// break;
// }
// }
// Char_ReFresh(UI_State[3]);
// }
// else if(timer_count == PEFEREE_PERIOD_TX_C/2)
// {
// //功率值变化
// Char_Draw(&UI_State[4],"s5",UI_Graph_Change,8,UI_Color_Green,18,2,720,240);
// Char_Write(&UI_State[4],"Voltage:%dV",super_cap_info.cap_voltage_cap);
// Char_ReFresh(UI_State[4]);
// }
// }
}
/**
* @brief IDID
* @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
}

View File

@ -0,0 +1,45 @@
#ifndef REFEREE_H
#define REFEREE_H
#include "rm_referee.h"
#include "robot_def.h"
#pragma pack(1)
typedef struct
{
uint32_t chassis_flag : 1;
uint32_t gimbal_flag : 1;
uint32_t cover_flag : 1;
uint32_t friction_flag : 1;
uint32_t Power_flag : 1;
uint32_t end_angle_flag : 1;
} Referee_Interactive_Flag_t;
// 此结构体包含UI绘制与机器人车间通信的需要的其他非裁判系统数据
typedef struct
{
Referee_Interactive_Flag_t Referee_Interactive_Flag;
//为UI绘制以及交互数据所用
Robot_Status_e Robot_Status;// 机器人状态
App_Status_e App_Status;// 应用状态
chassis_mode_e chassis_mode;//底盘模式
gimbal_mode_e gimbal_mode;//云台模式
shoot_mode_e shoot_mode;//发射模式设置
friction_mode_e friction_mode;//摩擦轮关闭
lid_mode_e lid_mode;//弹舱盖打开
loader_mode_e loader_mode;//单发...连发
Chassis_Power_Data_s Chassis_Power_Data;// 功率控制
} Referee_Interactive_info_t;
#pragma pack()
void Referee_Interactive_init(void);
void Referee_Interactive_task(void);
#endif // REFEREE_H

View File

@ -4,6 +4,7 @@
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
#include "chassis.h"
#include "referee.h"
#endif
#if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
@ -23,6 +24,7 @@ void RobotInit()
#endif
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
Referee_Interactive_init();//syh
ChassisInit();
#endif
}
@ -37,5 +39,6 @@ void RobotTask()
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
ChassisTask();
Referee_Interactive_task();
#endif
}

View File

@ -1,91 +1,16 @@
#include "referee_UI.h"
#include "string.h"
#include "crc.h"
#include "bsp_usart.h"
#include "stdio.h"
#include "referee.h"
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);
#include "rm_referee.h"
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 IDID
* @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
}
/********************************************删除操作*************************************
**Del_Operate
**_id id结构体
Del_Operate
Del_Layer 0-9
*****************************************************************************************/
static void UI_Delete(referee_id_t *_id,uint8_t Del_Operate,uint8_t Del_Layer)
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; //计算交互数据长度
@ -122,14 +47,14 @@ static void UI_Delete(referee_id_t *_id,uint8_t Del_Operate,uint8_t Del_Layer)
End_xEnd_y xy坐标
**********************************************************************************************************/
static void Line_Draw(Graph_Data_t *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)
{
// memset(graph,0,UI_Operate_LEN_PerDraw); //如果定义的是非静态变量数据存在初始化未默认为0的情况使用memset方法以下类似 syhtodo
int i;
//??????syhtodo
for(i=0;i<3&&graphname[i]!='\0';i++)
for(i=0;i<3&&graphname[i]!='\0';i++) //填充至0为止
{
graph->graphic_name[2-i]=graphname[i];
graph->graphic_name[2-i]=graphname[i]; //按内存地址增大方向填充所以会有i与2-i
}
graph->operate_tpye = Graph_Operate;
@ -154,9 +79,10 @@ static void Line_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Opera
Start_xStart_y xy坐标
End_xEnd_y xy坐标
**********************************************************************************************************/
static void Rectangle_Draw(Graph_Data_t *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)
{
// memset(&graph,0,UI_Operate_LEN_PerDraw);
int i;
for(i=0;i<3&&graphname[i]!='\0';i++)
{
@ -186,9 +112,10 @@ static void Rectangle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_
Graph_Radius
**********************************************************************************************************/
static void Circle_Draw(Graph_Data_t *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)
{
// memset(&graph,0,UI_Operate_LEN_PerDraw);
int i;
for(i=0;i<3&&graphname[i]!='\0';i++)
{
@ -215,9 +142,10 @@ static void Circle_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Ope
Start_xStart_y xy坐标
End_xEnd_y xy半轴长度
**********************************************************************************************************/
static void Elliptical_Draw(Graph_Data_t *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)
{
// memset(&graph,0,UI_Operate_LEN_PerDraw);
int i;
for(i=0;i<3&&graphname[i]!='\0';i++)
{
@ -249,10 +177,11 @@ static void Elliptical_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph
x_Length,y_Length xy半轴长度
**********************************************************************************************************/
static void Arc_Draw(Graph_Data_t *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)
{
//memset(&graph,0,UI_Operate_LEN_PerDraw);
int i;
for(i=0;i<3&&graphname[i]!='\0';i++)
{
@ -288,9 +217,10 @@ static void Arc_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Operat
end_y=(a>>21)&0x7FF;
**********************************************************************************************************/
static void Float_Draw(Graph_Data_t *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)
{
//memset(&graph,0,UI_Operate_LEN_PerDraw);
int i;
for(i=0;i<3&&graphname[i]!='\0';i++)
{
@ -325,9 +255,10 @@ static void Float_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Oper
end_x=(a>>10)&0x7FF;
end_y=(a>>21)&0x7FF;
**********************************************************************************************************/
static void Integer_Draw(Graph_Data_t *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)
{
//memset(&graph,0,UI_Operate_LEN_PerDraw);
int i;
for(i=0;i<3&&graphname[i]!='\0';i++)
{
@ -359,10 +290,11 @@ static void Integer_Draw(Graph_Data_t *graph,char graphname[3],uint32_t Graph_Op
Graph_Width 线
Start_xStart_y
**********************************************************************************************************/
static void Char_Draw(String_Data_t *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);//syhtodo 是否需要手动清零
// //memset(graph->Graph_Control.graphic_name, 0, 3);//syhtodo 是否需要手动清零
//memset(&graph,0,UI_Operate_LEN_DrawChar);
int i;
for(i=0;i<3&&graphname[i]!='\0';i++)
{
@ -388,14 +320,15 @@ static void Char_Draw(String_Data_t *graph,char graphname[3],uint32_t Graph_Oper
/************************************************绘制字符型数据*************************************************
***graph Graph_Data类型变量指针
fmt需要显示的字符串
使printf函数
syhtodo
**********************************************************************************************************/
static void Char_Write(String_Data_t *graph,char* fmt, ...)
void Char_Write(String_Data_t *graph,char* fmt, ...)
{
uint16_t i = 0;
va_list ap;
va_start(ap,fmt);
vsprintf((char*)graph->show_Data, fmt, ap);//使用参数列表发送格式化输出到字符串
vsprintf((char*)graph->show_Data,fmt,ap);//使用参数列表进行格式化并输出到字符串
va_end(ap);
i = strlen((const char*)graph->show_Data);
graph->Graph_Control.end_angle = i;
@ -407,7 +340,7 @@ static void Char_Write(String_Data_t *graph,char* fmt, ...)
...
Tips1257
*/
static int UI_ReFresh(referee_id_t *_id,int cnt,...)
void UI_ReFresh(referee_id_t *_id,int cnt,...)
{
int i;
UI_GraphReFresh_t UI_GraphReFresh_data;
@ -437,8 +370,6 @@ static int UI_ReFresh(referee_id_t *_id,int cnt,...)
case 7:
UI_GraphReFresh_data.datahead.data_cmd_id=UI_Data_ID_Draw7;
break;
default:
return (-1);
}
UI_GraphReFresh_data.datahead.receiver_ID = _id->Cilent_ID;
@ -460,12 +391,10 @@ static int UI_ReFresh(referee_id_t *_id,int cnt,...)
va_end(ap);//结束可变参数的获取
UI_Seq++; //包序号+1
return 0;
}
/************************************************UI推送字符使更改生效*********************************/
static int Char_ReFresh(referee_id_t *_id,String_Data_t string_Data)
void Char_ReFresh(referee_id_t *_id,String_Data_t string_Data)
{
UI_CharReFresh_t UI_CharReFresh_data;
@ -490,6 +419,5 @@ static int Char_ReFresh(referee_id_t *_id,String_Data_t string_Data)
RefereeSend((uint8_t *)&UI_CharReFresh_data,LEN_HEADER+LEN_CMDID+temp_datalength+LEN_TAIL); //发送
UI_Seq++; //包序号+1
return 0;
}

View File

@ -2,10 +2,9 @@
#define REFEREE_UI_H
#include "stdarg.h"
#include "usart.h"
#include "stdint.h"
#include "referee_def.h"
#include "referee.h"
#include "rm_referee.h"
#pragma pack(1) //按1字节对齐
@ -39,6 +38,40 @@ typedef struct
#pragma pack()
void Interactive_init(referee_info_t *_referee_info);
void UI_Delete(referee_id_t *_id,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 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 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 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);
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, ...);
void UI_ReFresh(referee_id_t *_id,int cnt,...);
void Char_ReFresh(referee_id_t *_id,String_Data_t string_Data);
#endif

View File

@ -1,4 +1,15 @@
#include "referee.h"
/**
* @file rm_referee.C
* @author kidneygood (you@domain.com)
* @brief
* @version 0.1
* @date 2022-11-18
*
* @copyright Copyright (c) 2022
*
*/
#include "rm_referee.h"
#include "string.h"
#include "crc.h"
#include "bsp_usart.h"

View File

@ -1,20 +1,10 @@
/**
* @file referee.h
* @author kidneygood (you@domain.com)
* @brief
* @version 0.1
* @date 2022-11-18
*
* @copyright Copyright (c) 2022
*
*/
#ifndef REFEREE_H
#define REFEREE_H
#ifndef RM_REFEREE_H
#define RM_REFEREE_H
#include "usart.h"
#include "referee_def.h"
#include "bsp_usart.h"
#include "robot_def.h"
#pragma pack(1)
@ -26,7 +16,7 @@ typedef struct
uint16_t Receiver_Robot_ID; //机器人车间通信时接收者的ID
} referee_id_t;
// 结构体包含裁判系统接收数据以及UI绘制与机器人车间通信的相关信息
// 结构体包含裁判系统接收数据以及UI绘制与机器人车间通信的相关信息
typedef struct
{
referee_id_t referee_id;