增加上一次未提交的部分

This commit is contained in:
Kidenygood
2023-04-19 22:51:02 +08:00
parent fb3472b556
commit 4bb45d1f18
4 changed files with 145 additions and 35 deletions

View File

@@ -12,7 +12,7 @@
#include "robot_def.h"
#include "rm_referee.h"
#include "referee_UI.h"
#include "string.h"
static Referee_Interactive_info_t *Interactive_data; // UI绘制需要的机器人状态数据
static referee_info_t *referee_recv_info; // 接收到的裁判系统数据
@@ -51,23 +51,24 @@ void Referee_Interactive_task()
}
static Graph_Data_t UI_shoot_line[10]; // 射击准线
static Graph_Data_t UI_energy_line[1]; // 电容能量条
static Graph_Data_t UI_Energy[3]; // 电容能量条
static String_Data_t UI_State_sta[6]; // 机器人状态,静态只需画一次
static String_Data_t UI_State_dyn[6]; // 机器人状态,动态先add才能change
static uint32_t shoot_line_location[10] = {540, 960, 490, 515, 565};
void My_UI_init()
{
while (referee_recv_info->GameRobotState.robot_id == 0)
;
DeterminRobotID();
UIDelete(&referee_recv_info->referee_id, UI_Data_Del_ALL, 0); // 清空UI
// // 绘制发射基准线
// 绘制发射基准线
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_recv_info->referee_id, 5, UI_shoot_line[0], UI_shoot_line[1], UI_shoot_line[2], UI_shoot_line[3], UI_shoot_line[4]);
// 绘制车辆状态标志指示
@@ -82,10 +83,6 @@ void My_UI_init()
Char_Draw(&UI_State_sta[4], "ss4", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 150, 550, "lid:");
Char_ReFresh(&referee_recv_info->referee_id, UI_State_sta[4]);
// 底盘功率显示,静态
Char_Draw(&UI_State_sta[5], "ss5", UI_Graph_ADD, 8, UI_Color_Green, 18, 2, 720, 210, "Power:");
Char_ReFresh(&referee_recv_info->referee_id, UI_State_sta[5]);
// 绘制车辆状态标志,动态
// 由于初始化时xxx_last_mode默认为0所以此处对应UI也应该设为0时对应的UI防止模式不变的情况下无法置位flag导致UI无法刷新
Char_Draw(&UI_State_dyn[0], "sd0", UI_Graph_ADD, 8, UI_Color_Main, 15, 2, 270, 750, "zeroforce");
@@ -99,9 +96,18 @@ void My_UI_init()
Char_Draw(&UI_State_dyn[4], "sd4", UI_Graph_ADD, 8, UI_Color_Pink, 15, 2, 270, 550, "open ");
Char_ReFresh(&referee_recv_info->referee_id, UI_State_dyn[4]);
// 底盘功率显示,静态
Char_Draw(&UI_State_sta[5], "ss5", UI_Graph_ADD, 7, UI_Color_Green, 18, 2, 620, 230, "Power:");
Char_ReFresh(&referee_recv_info->referee_id, UI_State_sta[5]);
// 能量条框
Rectangle_Draw(&UI_Energy[0], "ss6", UI_Graph_ADD, 7, UI_Color_Green, 2, 720, 140, 1220, 180);
UI_ReFresh(&referee_recv_info->referee_id, 1, UI_Energy[0]);
// 底盘功率显示,动态
Char_Draw(&UI_State_dyn[5], "sd5", UI_Graph_ADD, 8, UI_Color_Green, 18, 2, 840, 210, "0000");
Char_ReFresh(&referee_recv_info->referee_id, UI_State_dyn[5]);
Float_Draw(&UI_Energy[1], "sd5", UI_Graph_ADD, 8, UI_Color_Green, 18, 2, 2, 750, 230, 24000);
// 能量条初始状态
Line_Draw(&UI_Energy[2], "sd6", UI_Graph_ADD, 8, UI_Color_Pink, 30, 720, 160, 1020, 160);
UI_ReFresh(&referee_recv_info->referee_id, 2, UI_Energy[1], UI_Energy[2]);
}
static uint8_t count = 0;
@@ -123,6 +129,9 @@ static void robot_mode_change(Referee_Interactive_info_t *_Interactive_data) //
_Interactive_data->shoot_mode = SHOOT_ON;
_Interactive_data->friction_mode = FRICTION_ON;
_Interactive_data->lid_mode = LID_OPEN;
_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;
break;
}
case 1:
@@ -225,7 +234,7 @@ static void My_UI_Refresh(referee_info_t *referee_recv_info, Referee_Interactive
Char_ReFresh(&referee_recv_info->referee_id, UI_State_dyn[2]);
_Interactive_data->Referee_Interactive_Flag.shoot_flag = 0;
}
// friction
if (_Interactive_data->Referee_Interactive_Flag.friction_flag == 1)
{
switch (_Interactive_data->friction_mode)
@@ -244,7 +253,7 @@ static void My_UI_Refresh(referee_info_t *referee_recv_info, Referee_Interactive
Char_ReFresh(&referee_recv_info->referee_id, UI_State_dyn[3]);
_Interactive_data->Referee_Interactive_Flag.friction_flag = 0;
}
// lid
if (_Interactive_data->Referee_Interactive_Flag.lid_flag == 1)
{
switch (_Interactive_data->lid_mode)
@@ -263,6 +272,14 @@ static void My_UI_Refresh(referee_info_t *referee_recv_info, Referee_Interactive
Char_ReFresh(&referee_recv_info->referee_id, UI_State_dyn[4]);
_Interactive_data->Referee_Interactive_Flag.lid_flag = 0;
}
// power
if (_Interactive_data->Referee_Interactive_Flag.Power_flag == 1)
{
Float_Draw(&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);
Line_Draw(&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);
UI_ReFresh(&referee_recv_info->referee_id, 2, UI_Energy[1], UI_Energy[2]);
_Interactive_data->Referee_Interactive_Flag.Power_flag = 0;
}
}
/**
@@ -302,4 +319,10 @@ static void Mode_Change_Check(Referee_Interactive_info_t *_Interactive_data)
_Interactive_data->Referee_Interactive_Flag.lid_flag = 1;
_Interactive_data->lid_last_mode = _Interactive_data->lid_mode;
}
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;
}
}