2023-01-24 22:37:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @file referee.C
|
|
|
|
|
|
* @author kidneygood (you@domain.com)
|
|
|
|
|
|
* @brief
|
|
|
|
|
|
* @version 0.1
|
|
|
|
|
|
* @date 2022-11-18
|
|
|
|
|
|
*
|
|
|
|
|
|
* @copyright Copyright (c) 2022
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2023-04-19 18:52:40 +08:00
|
|
|
|
#include "referee_task.h"
|
2023-01-24 22:37:53 +08:00
|
|
|
|
#include "robot_def.h"
|
|
|
|
|
|
#include "rm_referee.h"
|
|
|
|
|
|
#include "referee_UI.h"
|
2023-04-19 22:51:02 +08:00
|
|
|
|
#include "string.h"
|
2023-06-08 15:53:53 +08:00
|
|
|
|
#include "cmsis_os.h"
|
2024-05-24 22:05:40 +08:00
|
|
|
|
#include "balance.h"
|
2023-04-24 10:24:36 +08:00
|
|
|
|
|
2023-04-19 18:52:40 +08:00
|
|
|
|
static Referee_Interactive_info_t *Interactive_data; // UI绘制需要的机器人状态数据
|
|
|
|
|
|
static referee_info_t *referee_recv_info; // 接收到的裁判系统数据
|
2023-06-08 15:53:53 +08:00
|
|
|
|
uint8_t UI_Seq; // 包序号,供整个referee文件使用
|
|
|
|
|
|
// @todo 不应该使用全局变量
|
2023-01-26 19:52:07 +08:00
|
|
|
|
|
2023-04-19 19:28:17 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 判断各种ID,选择客户端ID
|
|
|
|
|
|
* @param referee_info_t *referee_recv_info
|
|
|
|
|
|
* @retval none
|
|
|
|
|
|
* @attention
|
|
|
|
|
|
*/
|
|
|
|
|
|
static void DeterminRobotID()
|
|
|
|
|
|
{
|
|
|
|
|
|
// id小于7是红色,大于7是蓝色,0为红色,1为蓝色 #define Robot_Red 0 #define Robot_Blue 1
|
|
|
|
|
|
referee_recv_info->referee_id.Robot_Color = referee_recv_info->GameRobotState.robot_id > 7 ? Robot_Blue : Robot_Red;
|
|
|
|
|
|
referee_recv_info->referee_id.Robot_ID = referee_recv_info->GameRobotState.robot_id;
|
|
|
|
|
|
referee_recv_info->referee_id.Cilent_ID = 0x0100 + referee_recv_info->referee_id.Robot_ID; // 计算客户端ID
|
|
|
|
|
|
referee_recv_info->referee_id.Receiver_Robot_ID = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-15 12:19:32 +08:00
|
|
|
|
static void MyUIRefresh(referee_info_t *referee_recv_info, Referee_Interactive_info_t *_Interactive_data);
|
|
|
|
|
|
static void UIChangeCheck(Referee_Interactive_info_t *_Interactive_data); // 模式切换检测
|
2026-07-14 01:07:48 +08:00
|
|
|
|
static void RobotModeTest(Referee_Interactive_info_t *_Interactive_data) __attribute__((unused)); // 测试用函数,实现模式自动变化
|
2023-01-24 22:37:53 +08:00
|
|
|
|
|
2023-06-15 12:19:32 +08:00
|
|
|
|
referee_info_t *UITaskInit(UART_HandleTypeDef *referee_usart_handle, Referee_Interactive_info_t *UI_data)
|
2023-01-24 22:37:53 +08:00
|
|
|
|
{
|
2023-04-19 19:28:17 +08:00
|
|
|
|
referee_recv_info = RefereeInit(referee_usart_handle); // 初始化裁判系统的串口,并返回裁判系统反馈数据指针
|
|
|
|
|
|
Interactive_data = UI_data; // 获取UI绘制需要的机器人状态数据
|
2023-06-08 15:53:53 +08:00
|
|
|
|
referee_recv_info->init_flag = 1;
|
2023-04-19 19:28:17 +08:00
|
|
|
|
return referee_recv_info;
|
2023-01-25 22:32:13 +08:00
|
|
|
|
}
|
2023-01-24 22:37:53 +08:00
|
|
|
|
|
2023-06-15 12:19:32 +08:00
|
|
|
|
void UITask()
|
2023-01-24 22:37:53 +08:00
|
|
|
|
{
|
2024-05-24 20:49:07 +08:00
|
|
|
|
// RobotModeTest(Interactive_data); // 测试用函数,实现模式自动变化,用于检查该任务和裁判系统是否连接正常
|
2023-06-15 12:19:32 +08:00
|
|
|
|
MyUIRefresh(referee_recv_info, Interactive_data);
|
2023-01-24 22:37:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-25 22:32:13 +08:00
|
|
|
|
static Graph_Data_t UI_shoot_line[10]; // 射击准线
|
2023-04-19 22:51:02 +08:00
|
|
|
|
static Graph_Data_t UI_Energy[3]; // 电容能量条
|
2024-05-24 20:49:07 +08:00
|
|
|
|
static Graph_Data_t UI_Vision[3]; // 视觉标识框
|
2023-01-26 15:07:00 +08:00
|
|
|
|
static String_Data_t UI_State_sta[6]; // 机器人状态,静态只需画一次
|
|
|
|
|
|
static String_Data_t UI_State_dyn[6]; // 机器人状态,动态先add才能change
|
2024-05-24 20:49:07 +08:00
|
|
|
|
static uint32_t shoot_line_location[10] = {540, 960, 600, 460, 420, 350};
|
2023-01-24 22:37:53 +08:00
|
|
|
|
|
2024-05-24 22:05:40 +08:00
|
|
|
|
#define Leg_X_Offset 1650
|
|
|
|
|
|
#define Leg_Y_Offset 500
|
|
|
|
|
|
#define Leg_Gain 500
|
|
|
|
|
|
static Graph_Data_t Leg_Graph_sta[2];
|
|
|
|
|
|
static Graph_Data_t Leg_Graph_dyn[6];
|
|
|
|
|
|
static uint32_t Processed_coord[6] = {1605, 455, 1695, 410, 1785, 455}; // Y坐标取反,放大,平移后的
|
|
|
|
|
|
|
2023-06-15 12:19:32 +08:00
|
|
|
|
void MyUIInit()
|
2023-01-24 22:37:53 +08:00
|
|
|
|
{
|
2023-06-08 15:53:53 +08:00
|
|
|
|
if (!referee_recv_info->init_flag)
|
|
|
|
|
|
vTaskDelete(NULL); // 如果没有初始化裁判系统则直接删除ui任务
|
2024-05-24 20:49:07 +08:00
|
|
|
|
|
|
|
|
|
|
if (Interactive_data->ui_mode == UI_KEEP)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2023-04-19 22:51:02 +08:00
|
|
|
|
while (referee_recv_info->GameRobotState.robot_id == 0)
|
2023-06-08 15:53:53 +08:00
|
|
|
|
osDelay(100); // 若还未收到裁判系统数据,等待一段时间后再检查
|
2023-06-15 12:19:32 +08:00
|
|
|
|
|
|
|
|
|
|
DeterminRobotID(); // 确定ui要发送到的目标客户端
|
2023-04-19 19:28:17 +08:00
|
|
|
|
UIDelete(&referee_recv_info->referee_id, UI_Data_Del_ALL, 0); // 清空UI
|
2023-01-25 22:32:13 +08:00
|
|
|
|
|
2023-04-19 22:51:02 +08:00
|
|
|
|
// 绘制发射基准线
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UILineDraw(&UI_shoot_line[0], "sl0", UI_Graph_ADD, 7, UI_Color_White, 3, 710, shoot_line_location[0], 1210, shoot_line_location[0]);
|
|
|
|
|
|
UILineDraw(&UI_shoot_line[1], "sl1", UI_Graph_ADD, 7, UI_Color_White, 3, shoot_line_location[1], 340, shoot_line_location[1], 740);
|
|
|
|
|
|
UILineDraw(&UI_shoot_line[2], "sl2", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[2], 1110, shoot_line_location[2]);
|
|
|
|
|
|
UILineDraw(&UI_shoot_line[3], "sl3", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[3], 1110, shoot_line_location[3]);
|
|
|
|
|
|
UILineDraw(&UI_shoot_line[4], "sl4", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[4], 1110, shoot_line_location[4]);
|
2024-05-24 20:49:07 +08:00
|
|
|
|
UILineDraw(&UI_shoot_line[5], "sl5", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[5], 1110, shoot_line_location[5]);
|
|
|
|
|
|
UIGraphRefresh(&referee_recv_info->referee_id, 7, UI_shoot_line[0], UI_shoot_line[1], UI_shoot_line[2], UI_shoot_line[3], UI_shoot_line[4], UI_shoot_line[5], UI_shoot_line[6]);
|
2023-01-25 22:32:13 +08:00
|
|
|
|
|
2023-04-19 18:52:40 +08:00
|
|
|
|
// 绘制车辆状态标志指示
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharDraw(&UI_State_sta[0], "ss0", UI_Graph_ADD, 8, UI_Color_Main, 15, 2, 150, 750, "chassis:");
|
|
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[0]);
|
2024-05-24 20:49:07 +08:00
|
|
|
|
UICharDraw(&UI_State_sta[1], "ss1", UI_Graph_ADD, 8, UI_Color_Yellow, 15, 2, 150, 700, "frict:");
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[1]);
|
2024-05-24 20:49:07 +08:00
|
|
|
|
UICharDraw(&UI_State_sta[2], "ss2", UI_Graph_ADD, 8, UI_Color_Orange, 15, 2, 150, 650, "vision:");
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[2]);
|
2024-05-24 20:49:07 +08:00
|
|
|
|
UICharDraw(&UI_State_sta[4], "ss4", UI_Graph_ADD, 8, UI_Color_Cyan, 15, 2, 150, 600, "loader:");
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[4]);
|
2023-01-25 22:32:13 +08:00
|
|
|
|
|
2023-01-26 15:07:00 +08:00
|
|
|
|
// 绘制车辆状态标志,动态
|
|
|
|
|
|
// 由于初始化时xxx_last_mode默认为0,所以此处对应UI也应该设为0时对应的UI,防止模式不变的情况下无法置位flag,导致UI无法刷新
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_ADD, 8, UI_Color_Main, 15, 2, 270, 750, "zeroforce");
|
|
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[0]);
|
2024-05-24 20:49:07 +08:00
|
|
|
|
UICharDraw(&UI_State_dyn[1], "sd1", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 270, 700, "off");
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[1]);
|
2024-05-24 20:49:07 +08:00
|
|
|
|
UICharDraw(&UI_State_dyn[2], "sd2", UI_Graph_ADD, 8, UI_Color_Orange, 15, 2, 270, 650, "unlock");
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[2]);
|
2024-05-24 20:49:07 +08:00
|
|
|
|
UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_ADD, 8, UI_Color_Cyan, 15, 2, 270, 600, "stop");
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[4]);
|
2023-01-26 15:07:00 +08:00
|
|
|
|
|
2024-05-24 20:49:07 +08:00
|
|
|
|
// 绘制视觉标识框
|
|
|
|
|
|
UIRectangleDraw(&UI_Vision[0], "sd3", UI_Graph_ADD, 9, UI_Color_Green, 2, 650, 700, 1270, 380);
|
|
|
|
|
|
UIGraphRefresh(&referee_recv_info->referee_id, 1, UI_Vision[0]);
|
|
|
|
|
|
|
2023-04-19 22:51:02 +08:00
|
|
|
|
// 底盘功率显示,静态
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharDraw(&UI_State_sta[5], "ss5", UI_Graph_ADD, 7, UI_Color_Green, 18, 2, 620, 230, "Power:");
|
|
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[5]);
|
2023-04-19 22:51:02 +08:00
|
|
|
|
// 能量条框
|
2024-05-24 20:49:07 +08:00
|
|
|
|
UIRectangleDraw(&UI_Energy[0], "ss6", UI_Graph_ADD, 7, UI_Color_Green, 2, 720, 140, 1420, 180);
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UIGraphRefresh(&referee_recv_info->referee_id, 1, UI_Energy[0]);
|
2023-04-19 22:51:02 +08:00
|
|
|
|
|
2023-04-19 18:52:40 +08:00
|
|
|
|
// 底盘功率显示,动态
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UIFloatDraw(&UI_Energy[1], "sd5", UI_Graph_ADD, 8, UI_Color_Green, 18, 2, 2, 750, 230, 24000);
|
2023-04-19 22:51:02 +08:00
|
|
|
|
// 能量条初始状态
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UILineDraw(&UI_Energy[2], "sd6", UI_Graph_ADD, 8, UI_Color_Pink, 30, 720, 160, 1020, 160);
|
|
|
|
|
|
UIGraphRefresh(&referee_recv_info->referee_id, 2, UI_Energy[1], UI_Energy[2]);
|
2024-05-24 22:05:40 +08:00
|
|
|
|
|
|
|
|
|
|
// 底盘方向--指示云台方向
|
|
|
|
|
|
UILineDraw(&Leg_Graph_sta[0], "ws0", UI_Graph_ADD, 9, UI_Color_Purplish_red, 4, 1700, 600, 1700, 705);
|
|
|
|
|
|
UIGraphRefresh(&referee_recv_info->referee_id, 1, Leg_Graph_sta[0]);
|
|
|
|
|
|
|
|
|
|
|
|
// 腿部运动,五连杆
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[1], "wd1", UI_Graph_ADD, 7, UI_Color_Yellow, 5,
|
|
|
|
|
|
0 + Leg_X_Offset, 0 + Leg_Y_Offset, (uint32_t)(JOINT_DISTANCE * Leg_Gain + Leg_X_Offset), 0 + Leg_Y_Offset); // 水平线
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[2], "wd2", UI_Graph_ADD, 7, UI_Color_Green, 5,
|
|
|
|
|
|
0 + Leg_X_Offset, 0 + Leg_Y_Offset, Processed_coord[0], Processed_coord[1]); // 左大腿
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[3], "wd3", UI_Graph_ADD, 7, UI_Color_Green, 5,
|
|
|
|
|
|
Processed_coord[0], Processed_coord[1], Processed_coord[2], Processed_coord[3]); // 左小腿
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[4], "wd4", UI_Graph_ADD, 7, UI_Color_Purplish_red, 5,
|
|
|
|
|
|
(uint32_t)(JOINT_DISTANCE * Leg_Gain + Leg_X_Offset), 0 + Leg_Y_Offset, Processed_coord[4], Processed_coord[5]); // 右大腿
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[5], "wd5", UI_Graph_ADD, 7, UI_Color_Purplish_red, 5,
|
|
|
|
|
|
Processed_coord[2], Processed_coord[3], Processed_coord[4], Processed_coord[5]); // 右小腿
|
|
|
|
|
|
UIGraphRefresh(&referee_recv_info->referee_id, 5, Leg_Graph_dyn[1], Leg_Graph_dyn[2], Leg_Graph_dyn[3], Leg_Graph_dyn[4], Leg_Graph_dyn[5]);
|
2023-01-24 22:37:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-15 12:19:32 +08:00
|
|
|
|
// 测试用函数,实现模式自动变化,用于检查该任务和裁判系统是否连接正常
|
2023-01-25 22:32:13 +08:00
|
|
|
|
static uint8_t count = 0;
|
|
|
|
|
|
static uint16_t count1 = 0;
|
2023-06-15 12:19:32 +08:00
|
|
|
|
static void RobotModeTest(Referee_Interactive_info_t *_Interactive_data) // 测试用函数,实现模式自动变化
|
2023-01-25 22:32:13 +08:00
|
|
|
|
{
|
|
|
|
|
|
count++;
|
|
|
|
|
|
if (count >= 50)
|
|
|
|
|
|
{
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
count1++;
|
|
|
|
|
|
}
|
2023-01-26 15:07:00 +08:00
|
|
|
|
switch (count1 % 4)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->chassis_mode = CHASSIS_ZERO_FORCE;
|
|
|
|
|
|
_Interactive_data->gimbal_mode = GIMBAL_ZERO_FORCE;
|
|
|
|
|
|
_Interactive_data->shoot_mode = SHOOT_ON;
|
|
|
|
|
|
_Interactive_data->friction_mode = FRICTION_ON;
|
|
|
|
|
|
_Interactive_data->lid_mode = LID_OPEN;
|
2023-04-19 22:51:02 +08:00
|
|
|
|
_Interactive_data->Chassis_Power_Data.chassis_power_mx += 3.5;
|
|
|
|
|
|
if (_Interactive_data->Chassis_Power_Data.chassis_power_mx >= 18)
|
|
|
|
|
|
_Interactive_data->Chassis_Power_Data.chassis_power_mx = 0;
|
2023-01-26 15:07:00 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->chassis_mode = CHASSIS_ROTATE;
|
|
|
|
|
|
_Interactive_data->gimbal_mode = GIMBAL_FREE_MODE;
|
|
|
|
|
|
_Interactive_data->shoot_mode = SHOOT_OFF;
|
|
|
|
|
|
_Interactive_data->friction_mode = FRICTION_OFF;
|
|
|
|
|
|
_Interactive_data->lid_mode = LID_CLOSE;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
{
|
2024-05-24 20:49:07 +08:00
|
|
|
|
_Interactive_data->chassis_mode = CHASSIS_RESET;
|
2023-01-26 15:07:00 +08:00
|
|
|
|
_Interactive_data->gimbal_mode = GIMBAL_GYRO_MODE;
|
|
|
|
|
|
_Interactive_data->shoot_mode = SHOOT_ON;
|
|
|
|
|
|
_Interactive_data->friction_mode = FRICTION_ON;
|
|
|
|
|
|
_Interactive_data->lid_mode = LID_OPEN;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
|
|
|
|
|
|
_Interactive_data->gimbal_mode = GIMBAL_ZERO_FORCE;
|
|
|
|
|
|
_Interactive_data->shoot_mode = SHOOT_OFF;
|
|
|
|
|
|
_Interactive_data->friction_mode = FRICTION_OFF;
|
|
|
|
|
|
_Interactive_data->lid_mode = LID_CLOSE;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-15 12:19:32 +08:00
|
|
|
|
static void MyUIRefresh(referee_info_t *referee_recv_info, Referee_Interactive_info_t *_Interactive_data)
|
2023-01-26 15:07:00 +08:00
|
|
|
|
{
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UIChangeCheck(_Interactive_data);
|
2023-01-26 15:07:00 +08:00
|
|
|
|
// chassis
|
|
|
|
|
|
if (_Interactive_data->Referee_Interactive_Flag.chassis_flag == 1)
|
2023-01-25 22:32:13 +08:00
|
|
|
|
{
|
2023-01-26 15:07:00 +08:00
|
|
|
|
switch (_Interactive_data->chassis_mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case CHASSIS_ZERO_FORCE:
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "zeroforce");
|
2023-01-25 22:32:13 +08:00
|
|
|
|
break;
|
2023-01-26 15:07:00 +08:00
|
|
|
|
case CHASSIS_ROTATE:
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "rotate ");
|
2023-04-19 18:52:40 +08:00
|
|
|
|
// 此处注意字数对齐问题,字数相同才能覆盖掉
|
2023-01-25 22:32:13 +08:00
|
|
|
|
break;
|
2024-05-24 20:49:07 +08:00
|
|
|
|
case CHASSIS_RESET:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "reset ");
|
|
|
|
|
|
break;
|
2023-01-26 15:07:00 +08:00
|
|
|
|
case CHASSIS_FOLLOW_GIMBAL_YAW:
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "follow ");
|
2023-01-25 22:32:13 +08:00
|
|
|
|
break;
|
2026-07-14 01:07:48 +08:00
|
|
|
|
case CHASSIS_STOOL_MODE:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "stool ");
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CHASSIS_FREE_DEBUG:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "debug ");
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CHASSIS_ROTATE_REVERSE:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "revrot ");
|
|
|
|
|
|
break;
|
2023-01-25 22:32:13 +08:00
|
|
|
|
}
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[0]);
|
2023-01-26 15:07:00 +08:00
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.chassis_flag = 0;
|
|
|
|
|
|
}
|
2024-05-24 20:49:07 +08:00
|
|
|
|
// friction
|
|
|
|
|
|
if (_Interactive_data->Referee_Interactive_Flag.friction_flag == 1)
|
2023-01-25 22:32:13 +08:00
|
|
|
|
{
|
2024-05-24 20:49:07 +08:00
|
|
|
|
UICharDraw(&UI_State_dyn[1], "sd1", UI_Graph_Change, 8, UI_Color_Pink, 15, 2, 270, 700, _Interactive_data->friction_mode == FRICTION_ON ? "on " : "off");
|
|
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[1]);
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.friction_flag = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
// vision
|
|
|
|
|
|
if (_Interactive_data->Referee_Interactive_Flag.vision_flag == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (_Interactive_data->vision_mode)
|
2023-01-26 15:07:00 +08:00
|
|
|
|
{
|
2024-05-24 20:49:07 +08:00
|
|
|
|
case UNLOCK:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[2], "sd2", UI_Graph_Change, 8, UI_Color_Orange, 15, 2, 270, 650, "unlock ");
|
|
|
|
|
|
UIRectangleDraw(&UI_Vision[0], "sd3", UI_Graph_Change, 9, UI_Color_Green, 2, 650, 700, 1270, 380);
|
2023-01-26 15:07:00 +08:00
|
|
|
|
break;
|
2024-05-24 20:49:07 +08:00
|
|
|
|
case CONVERGE:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[2], "sd2", UI_Graph_Change, 8, UI_Color_Orange, 15, 2, 270, 650, "converge");
|
|
|
|
|
|
UIRectangleDraw(&UI_Vision[0], "sd3", UI_Graph_Change, 9, UI_Color_Purplish_red, 2, 650, 700, 1270, 380);
|
2023-01-26 15:07:00 +08:00
|
|
|
|
break;
|
2024-05-24 20:49:07 +08:00
|
|
|
|
case LOCK:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[2], "sd2", UI_Graph_Change, 8, UI_Color_Orange, 15, 2, 270, 650, "lock ");
|
|
|
|
|
|
UIRectangleDraw(&UI_Vision[0], "sd3", UI_Graph_Change, 9, UI_Color_Purplish_red, 2, 650, 700, 1270, 380);
|
2023-01-26 15:07:00 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[2]);
|
2024-05-24 20:49:07 +08:00
|
|
|
|
UIGraphRefresh(&referee_recv_info->referee_id, 1, UI_Vision[0]);
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.vision_flag = 0;
|
2023-01-25 22:32:13 +08:00
|
|
|
|
}
|
2024-05-24 20:49:07 +08:00
|
|
|
|
// loader
|
|
|
|
|
|
if (_Interactive_data->Referee_Interactive_Flag.loader_flag == 1)
|
2023-01-26 15:07:00 +08:00
|
|
|
|
{
|
2024-05-24 20:49:07 +08:00
|
|
|
|
switch (_Interactive_data->loader_mode)
|
|
|
|
|
|
{
|
2026-07-14 01:07:48 +08:00
|
|
|
|
case LOAD_REVERSE:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_Change, 8, UI_Color_Purplish_red, 15, 2, 270, 600, "rev ");
|
|
|
|
|
|
break;
|
2024-05-24 20:49:07 +08:00
|
|
|
|
case LOAD_1_BULLET:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_Change, 8, UI_Color_Cyan, 15, 2, 270, 600, "1 bull");
|
|
|
|
|
|
break;
|
|
|
|
|
|
case LOAD_3_BULLET:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_Change, 8, UI_Color_Purplish_red, 15, 2, 270, 600, "3 bull");
|
|
|
|
|
|
break;
|
|
|
|
|
|
case LOAD_BURSTFIRE:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_Change, 8, UI_Color_Purplish_red, 15, 2, 270, 600, "burst ");
|
|
|
|
|
|
break;
|
|
|
|
|
|
case LOAD_STOP:
|
|
|
|
|
|
UICharDraw(&UI_State_dyn[4], "sd4", UI_Graph_Change, 8, UI_Color_Purplish_red, 15, 2, 270, 600, "stop ");
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[4]);
|
2024-05-24 20:49:07 +08:00
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.loader_flag = 0;
|
2023-01-26 15:07:00 +08:00
|
|
|
|
}
|
2023-04-19 22:51:02 +08:00
|
|
|
|
// power
|
|
|
|
|
|
if (_Interactive_data->Referee_Interactive_Flag.Power_flag == 1)
|
|
|
|
|
|
{
|
2023-06-15 12:19:32 +08:00
|
|
|
|
UIFloatDraw(&UI_Energy[1], "sd5", UI_Graph_Change, 8, UI_Color_Green, 18, 2, 2, 750, 230, _Interactive_data->Chassis_Power_Data.chassis_power_mx * 1000);
|
|
|
|
|
|
UILineDraw(&UI_Energy[2], "sd6", UI_Graph_Change, 8, UI_Color_Pink, 30, 720, 160, (uint32_t)750 + _Interactive_data->Chassis_Power_Data.chassis_power_mx * 30, 160);
|
|
|
|
|
|
UIGraphRefresh(&referee_recv_info->referee_id, 2, UI_Energy[1], UI_Energy[2]);
|
2023-04-19 22:51:02 +08:00
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.Power_flag = 0;
|
|
|
|
|
|
}
|
2024-05-24 22:05:40 +08:00
|
|
|
|
|
|
|
|
|
|
// 底盘方向
|
|
|
|
|
|
if (_Interactive_data->Referee_Interactive_Flag.direction_flag == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (_Interactive_data->direction)
|
|
|
|
|
|
{
|
|
|
|
|
|
case CHASSIS_SIDLE:
|
|
|
|
|
|
{
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[0], "wd0", UI_Graph_Change, 9, UI_Color_Green, 7, 1700, 600, 1700, 700);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case CHASSIS_ALIGN:
|
|
|
|
|
|
{
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[0], "wd0", UI_Graph_Change, 9, UI_Color_Green, 7, 1650, 600, 1750, 600);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
UIGraphRefresh(&referee_recv_info->referee_id, 1, Leg_Graph_dyn[0]);
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.direction_flag = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Processed_coord[0] != (uint32_t)(_Interactive_data->coord[0] * Leg_Gain + Leg_X_Offset))
|
|
|
|
|
|
{
|
|
|
|
|
|
Processed_coord[0] = (uint32_t)(_Interactive_data->coord[0] * Leg_Gain + Leg_X_Offset);
|
|
|
|
|
|
Processed_coord[1] = (uint32_t)(_Interactive_data->coord[1] * -Leg_Gain + Leg_Y_Offset);
|
|
|
|
|
|
Processed_coord[2] = (uint32_t)(_Interactive_data->coord[2] * Leg_Gain + Leg_X_Offset);
|
|
|
|
|
|
Processed_coord[3] = (uint32_t)(_Interactive_data->coord[3] * -Leg_Gain + Leg_Y_Offset);
|
|
|
|
|
|
Processed_coord[4] = (uint32_t)(_Interactive_data->coord[4] * Leg_Gain + Leg_X_Offset);
|
|
|
|
|
|
Processed_coord[5] = (uint32_t)(_Interactive_data->coord[5] * -Leg_Gain + Leg_Y_Offset);
|
|
|
|
|
|
|
|
|
|
|
|
// 腿部运动,五连杆,不需要检测变更,实时显示变化
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[2], "wd2", UI_Graph_Change, 7, UI_Color_Green, 5,
|
|
|
|
|
|
0 + Leg_X_Offset, 0 + Leg_Y_Offset, Processed_coord[0], Processed_coord[1]); // 左大腿
|
|
|
|
|
|
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[3], "wd3", UI_Graph_Change, 7, UI_Color_Green, 5,
|
|
|
|
|
|
Processed_coord[0], Processed_coord[1], Processed_coord[2], Processed_coord[3]); // 左小腿
|
|
|
|
|
|
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[4], "wd4", UI_Graph_Change, 7, UI_Color_Purplish_red, 5,
|
|
|
|
|
|
(uint32_t)(JOINT_DISTANCE * Leg_Gain + Leg_X_Offset), 0 + Leg_Y_Offset, Processed_coord[4], Processed_coord[5]); // 右大腿
|
|
|
|
|
|
|
|
|
|
|
|
UILineDraw(&Leg_Graph_dyn[5], "wd5", UI_Graph_Change, 7, UI_Color_Purplish_red, 5,
|
|
|
|
|
|
Processed_coord[2], Processed_coord[3], Processed_coord[4], Processed_coord[5]); // 右小腿
|
|
|
|
|
|
UIGraphRefresh(&referee_recv_info->referee_id, 5, Leg_Graph_dyn[1], Leg_Graph_dyn[2], Leg_Graph_dyn[3], Leg_Graph_dyn[4], Leg_Graph_dyn[5]);
|
|
|
|
|
|
}
|
2023-01-26 15:07:00 +08:00
|
|
|
|
}
|
2023-01-25 22:32:13 +08:00
|
|
|
|
|
2023-01-26 15:07:00 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 模式切换检测,模式发生切换时,对flag置位
|
|
|
|
|
|
* @param Referee_Interactive_info_t *_Interactive_data
|
|
|
|
|
|
* @retval none
|
|
|
|
|
|
* @attention
|
|
|
|
|
|
*/
|
2023-06-15 12:19:32 +08:00
|
|
|
|
static void UIChangeCheck(Referee_Interactive_info_t *_Interactive_data)
|
2023-01-26 15:07:00 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (_Interactive_data->chassis_mode != _Interactive_data->chassis_last_mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.chassis_flag = 1;
|
|
|
|
|
|
_Interactive_data->chassis_last_mode = _Interactive_data->chassis_mode;
|
|
|
|
|
|
}
|
2023-01-25 22:32:13 +08:00
|
|
|
|
|
2023-01-26 15:07:00 +08:00
|
|
|
|
if (_Interactive_data->gimbal_mode != _Interactive_data->gimbal_last_mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.gimbal_flag = 1;
|
|
|
|
|
|
_Interactive_data->gimbal_last_mode = _Interactive_data->gimbal_mode;
|
|
|
|
|
|
}
|
2023-01-25 22:32:13 +08:00
|
|
|
|
|
2023-01-26 15:07:00 +08:00
|
|
|
|
if (_Interactive_data->shoot_mode != _Interactive_data->shoot_last_mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.shoot_flag = 1;
|
|
|
|
|
|
_Interactive_data->shoot_last_mode = _Interactive_data->shoot_mode;
|
|
|
|
|
|
}
|
2023-01-25 22:32:13 +08:00
|
|
|
|
|
2023-01-26 15:07:00 +08:00
|
|
|
|
if (_Interactive_data->friction_mode != _Interactive_data->friction_last_mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.friction_flag = 1;
|
|
|
|
|
|
_Interactive_data->friction_last_mode = _Interactive_data->friction_mode;
|
|
|
|
|
|
}
|
2023-01-25 22:32:13 +08:00
|
|
|
|
|
2023-01-26 15:07:00 +08:00
|
|
|
|
if (_Interactive_data->lid_mode != _Interactive_data->lid_last_mode)
|
|
|
|
|
|
{
|
2023-04-24 10:24:36 +08:00
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.lid_flag = 1;
|
2023-01-26 15:07:00 +08:00
|
|
|
|
_Interactive_data->lid_last_mode = _Interactive_data->lid_mode;
|
|
|
|
|
|
}
|
2023-04-19 22:51:02 +08:00
|
|
|
|
|
|
|
|
|
|
if (_Interactive_data->Chassis_Power_Data.chassis_power_mx != _Interactive_data->Chassis_last_Power_Data.chassis_power_mx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.Power_flag = 1;
|
|
|
|
|
|
_Interactive_data->Chassis_last_Power_Data.chassis_power_mx = _Interactive_data->Chassis_Power_Data.chassis_power_mx;
|
|
|
|
|
|
}
|
2024-05-24 20:49:07 +08:00
|
|
|
|
|
|
|
|
|
|
if(_Interactive_data->vision_mode != _Interactive_data->vision_last_mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.vision_flag = 1;
|
|
|
|
|
|
_Interactive_data->vision_last_mode = _Interactive_data->vision_mode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_Interactive_data->loader_mode != _Interactive_data->loader_last_mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.loader_flag = 1;
|
|
|
|
|
|
_Interactive_data->loader_last_mode = _Interactive_data->loader_mode;
|
|
|
|
|
|
}
|
2024-05-24 22:05:40 +08:00
|
|
|
|
|
|
|
|
|
|
if (_Interactive_data->direction != _Interactive_data->last_direction)
|
|
|
|
|
|
{
|
|
|
|
|
|
_Interactive_data->Referee_Interactive_Flag.direction_flag = 1;
|
|
|
|
|
|
_Interactive_data->last_direction = _Interactive_data->direction;
|
|
|
|
|
|
}
|
2023-01-24 22:37:53 +08:00
|
|
|
|
}
|