画了一个简单的qml界面用于测试指令

This commit is contained in:
2020-04-08 18:05:00 +08:00
parent b051a1e969
commit 2594deaa06
8 changed files with 231 additions and 67 deletions
+77 -1
View File
@@ -85,6 +85,49 @@ void commandprocess::SendMessage(mavlink_message_t msg)
emit SendMessageTo(0,buff, len);//使用信号和槽
}
//发送函数
void commandprocess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,
float param1,
float param2,
float param3,
float param4,
int32_t x,
int32_t y,
float z, uint16_t command, uint8_t frame, uint8_t current, uint8_t autocontinue)
{
sysid = m_sysid;
compid = m_compid;
//给指令赋值
cmd_int.param1 = param1;
cmd_int.param2 = param2;
cmd_int.param3 = param3;
cmd_int.param4 = param4;
cmd_int.x = x;
cmd_int.y = y;
cmd_int.z = z;
cmd_int.command = command;
cmd_int.frame = frame;
cmd_int.current = current;
cmd_int.autocontinue = autocontinue;
//开启线程开始传输
status.m_Mode = TransmitMode;//发送模式
start();//开启线程
}
//这个函数类似中断,专门处理接收到的状态
void commandprocess::Parse(mavlink_message_t msg)
{
@@ -106,6 +149,10 @@ void commandprocess::Parse(mavlink_message_t msg)
{
status.transmit.isWaitingforACK = false;
}
else
{
//拒绝该指令
}
break;
}
}
@@ -142,7 +189,9 @@ void commandprocess::WriteStateMachine(void)
{
status.transmit.isWaitingforACK = true;
//set("id",0,1);//发送一个指令
_int(cmd_int.param1,cmd_int.param2,cmd_int.param3,cmd_int.param4,
cmd_int.x,cmd_int.y,cmd_int.z,
cmd_int.command,cmd_int.frame,cmd_int.current,cmd_int.autocontinue);//发送一个指令
time = QTime::currentTime().msecsSinceStartOfDay();
step++;//下一个阶段
}
@@ -159,6 +208,20 @@ void commandprocess::WriteStateMachine(void)
status.m_Mode = Nop_Mode;
status.transmit.isWaitingforACK = false;
timeout_count = 0;
//清除指令
cmd_int.param1 = 0;
cmd_int.param2 = 0;
cmd_int.param3 = 0;
cmd_int.param4 = 0;
cmd_int.x = 0;
cmd_int.y = 0;
cmd_int.z = 0;
cmd_int.command = 0;
cmd_int.frame = 0;
cmd_int.current = 0;
cmd_int.autocontinue = 0;
}
}
else
@@ -170,6 +233,19 @@ void commandprocess::WriteStateMachine(void)
status.m_Mode = Nop_Mode;
status.transmit.isWaitingforACK = false;
timeout_count = 0;
//清除指令
cmd_int.param1 = 0;
cmd_int.param2 = 0;
cmd_int.param3 = 0;
cmd_int.param4 = 0;
cmd_int.x = 0;
cmd_int.y = 0;
cmd_int.z = 0;
cmd_int.command = 0;
cmd_int.frame = 0;
cmd_int.current = 0;
cmd_int.autocontinue = 0;
}
}
}