chassis_mode动态刷新完成测试
This commit is contained in:
parent
68f7e64c2a
commit
846a8b1caf
|
@ -13,25 +13,25 @@
|
|||
#include "rm_referee.h"
|
||||
#include "referee_UI.h"
|
||||
|
||||
static Referee_Interactive_info_t *Interactive_data;// 非裁判系统数据
|
||||
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);
|
||||
static void robot_mode_change(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);
|
||||
|
||||
robot_mode_change(&Interactive_data); // 测试用函数,实现模式自动变化
|
||||
My_UI_Refresh(referee_data, &Interactive_data);
|
||||
}
|
||||
|
||||
static Graph_Data_t UI_shoot_line[10]; // 射击准线
|
||||
|
@ -75,6 +75,7 @@ static void My_UI_init(referee_info_t *_referee_info)
|
|||
Char_ReFresh(&_referee_info->referee_id, UI_State_sta[4]);
|
||||
|
||||
// 绘制车辆状态标志,动态
|
||||
//syhtodo 由于初始化时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);
|
||||
Char_Write(&UI_State_dyn[0], "0000");
|
||||
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[0]);
|
||||
|
@ -97,45 +98,110 @@ static void My_UI_init(referee_info_t *_referee_info)
|
|||
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[4]);
|
||||
}
|
||||
|
||||
static uint8_t count = 0;
|
||||
static uint16_t count1 = 0;
|
||||
static void robot_mode_change(Referee_Interactive_info_t *_Interactive_data) // 测试用函数,实现模式自动变化
|
||||
{
|
||||
count++;
|
||||
if (count >= 50)
|
||||
{
|
||||
count = 0;
|
||||
count1++;
|
||||
}
|
||||
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;
|
||||
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:
|
||||
{
|
||||
_Interactive_data->chassis_mode =CHASSIS_NO_FOLLOW;
|
||||
_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;
|
||||
}
|
||||
}
|
||||
|
||||
static void My_UI_Refresh(referee_info_t *_referee_info, Referee_Interactive_info_t *_Interactive_data)
|
||||
{
|
||||
// syhtodo 按键刷新
|
||||
// syhtodo与上次不一样才要进入刷新,避免重复发送
|
||||
// syhtodo与上次不一样才要进入刷新,避免重复发送,使用新结构体flag
|
||||
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;
|
||||
}
|
||||
|
||||
if (_Interactive_data->Referee_Interactive_Flag.chassis_flag==1)
|
||||
{
|
||||
switch(_Interactive_data->chassis_mode)
|
||||
{
|
||||
case CHASSIS_ZERO_FORCE:
|
||||
{
|
||||
Char_Draw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750);
|
||||
Char_Write(&UI_State_dyn[0], "zeroforce");
|
||||
break;
|
||||
}
|
||||
case CHASSIS_ROTATE:
|
||||
{
|
||||
Char_Draw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750);
|
||||
Char_Write(&UI_State_dyn[0], "rotate "); //此处注意字数对齐问题,字数相同才能覆盖掉
|
||||
break;
|
||||
}
|
||||
case CHASSIS_NO_FOLLOW:
|
||||
{
|
||||
Char_Draw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750);
|
||||
Char_Write(&UI_State_dyn[0], "nofollow ");
|
||||
break;
|
||||
}
|
||||
case CHASSIS_FOLLOW_GIMBAL_YAW:
|
||||
{
|
||||
Char_Draw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750);
|
||||
Char_Write(&UI_State_dyn[0], "follow ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Char_ReFresh(&_referee_info->referee_id, UI_State_dyn[0]);
|
||||
_Interactive_data->Referee_Interactive_Flag.chassis_flag=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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)
|
||||
// {
|
||||
|
@ -204,14 +270,8 @@ static void My_UI_Refresh(referee_info_t *_referee_info,Referee_Interactive_info
|
|||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 判断各种ID,选择客户端ID
|
||||
* @param void
|
||||
|
@ -226,10 +286,3 @@ static void determine_ID(referee_info_t *_referee_info)
|
|||
_referee_info->referee_id.Cilent_ID = 0x0100 + _referee_info->referee_id.Robot_ID; // 计算客户端ID
|
||||
_referee_info->referee_id.Receiver_Robot_ID = 0x00; // 机器人车间通信时接收者的ID暂时为0
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "robot_def.h"
|
||||
#pragma pack(1)
|
||||
|
||||
//模式是否切换标志位,0为未切换,1为切换,static定义默认为0
|
||||
typedef struct
|
||||
{
|
||||
uint32_t chassis_flag : 1;
|
||||
|
@ -13,7 +14,6 @@ typedef struct
|
|||
uint32_t friction_flag : 1;
|
||||
uint32_t Power_flag : 1;
|
||||
uint32_t end_angle_flag : 1;
|
||||
|
||||
} Referee_Interactive_Flag_t;
|
||||
|
||||
|
||||
|
@ -32,11 +32,16 @@ typedef struct
|
|||
loader_mode_e loader_mode;//单发...连发
|
||||
Chassis_Power_Data_s Chassis_Power_Data;// 功率控制
|
||||
|
||||
chassis_mode_e chassis_last_mode;//底盘模式
|
||||
gimbal_mode_e gimbal_last_mode;//云台模式
|
||||
shoot_mode_e shoot_last_mode;//发射模式设置
|
||||
friction_mode_e friction_last_mode;//摩擦轮关闭
|
||||
lid_mode_e lid_last_mode;//弹舱盖打开
|
||||
|
||||
} Referee_Interactive_info_t;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
void Referee_Interactive_init(void);
|
||||
void Referee_Interactive_task(void);
|
||||
#endif // REFEREE_H
|
||||
|
|
|
@ -127,7 +127,6 @@ typedef enum
|
|||
// 功率限制,从裁判系统获取
|
||||
typedef struct
|
||||
{ // 功率控制
|
||||
|
||||
} Chassis_Power_Data_s;
|
||||
|
||||
/* ----------------CMD应用发布的控制数据,应当由gimbal/chassis/shoot订阅---------------- */
|
||||
|
|
Loading…
Reference in New Issue