This commit is contained in:
hm
2021-06-16 17:27:38 +08:00
parent 2d8c76229d
commit 2c8d32374a
7 changed files with 41 additions and 54 deletions
+1 -16
View File
@@ -4,7 +4,7 @@
Config::Config(QObject *parent) :
QObject(parent)
{
qDebug() << "Config Operation";
qInfo() << "Config Operation";
QDir *Dir = new QDir;
if(!Dir->exists("./Config"))
@@ -50,21 +50,6 @@ void Config::loadJson(const QString& jsonFilename)
}
ConfigJson = doc.object();
/*
QJsonObject json = doc.object();
QJsonValue jsonValue = json.value("config");
if(jsonValue.isObject())
{
ConfigJson = jsonValue.toObject();
}
*/
//qDebug() << ConfigJson;
}
+1
View File
@@ -29,6 +29,7 @@ HealthUI::HealthUI(QWidget *parent) :
Install("记录打开",7,state::inital);
Install("外置记录",8,state::inital);//1,绿,2,黄
Install("正在写入",9,state::inital);//3
Install("动检完成",10,state::inital);//3
+11 -13
View File
@@ -7,6 +7,11 @@
//从0开始
bool getBit(uint32_t d,int32_t pos)
{
if(pos > 31)
{
return false;
}
bool bit = false;
bit = (d >> pos) & 0x00000001;
@@ -1022,8 +1027,8 @@ void MainWindow::update_servo_output_raw(mavlink_servo_output_raw_t servo)
if(servo.port == 0)
{
//12-16
statusui->setValue(2,0,QString::number(((int16_t)servo.servo1_raw) * 19.0 / 32767.0,'f',2) + '|'
+ QString::number(((int16_t)servo.servo13_raw) * 19.0 / 32767.0,'f',2));//8000H~7FFFH -38°~38° 1LSB=38/32767
statusui->setValue(2,0,QString::number(((int16_t)servo.servo1_raw) * 38.0 / 32767.0,'f',2) + '|'
+ QString::number(((int16_t)servo.servo13_raw) * 38.0 / 32767.0,'f',2));//8000H~7FFFH -38°~38° 1LSB=38/32767
/*
statusui->setValue(2,1,QString::number(((int16_t)servo.servo2_raw) * 88.0 / 32767.0,'f',2) + '|'
+ QString::number(((int16_t)servo.servo14_raw) * 88.0 / 32767.0,'f',2));//88/32767
@@ -1037,7 +1042,7 @@ void MainWindow::update_servo_output_raw(mavlink_servo_output_raw_t servo)
ch1 = QString::number(((int16_t)servo.servo5_raw) * 19.0 / 32767.0,'f',2);
ch1 = QString::number(((int16_t)servo.servo5_raw) * 38.0 / 32767.0,'f',2);
//ch2 = QString::number(((int16_t)servo.servo6_raw) * 88.0 / 32767.0,'f',2);
ch3 = QString::number(((int16_t)servo.servo7_raw) * 22.5 / 32767.0,'f',2);
ch4 = QString::number(((int16_t)servo.servo8_raw) * 22.5 / 32767.0,'f',2);
@@ -1047,7 +1052,7 @@ void MainWindow::update_servo_output_raw(mavlink_servo_output_raw_t servo)
else if(servo.port == 1)
{
//17-19
statusui->setValue(2,1,ch1 + '|' + QString::number(((int16_t)servo.servo1_raw) * 19.0 / 32767.0,'f',2));
statusui->setValue(2,1,ch1 + '|' + QString::number(((int16_t)servo.servo1_raw) * 38.0 / 32767.0,'f',2));
//statusui->setValue(2,5,ch2 + '|' + QString::number(((int16_t)servo.servo2_raw) * 88.0 / 32767.0,'f',2));
statusui->setValue(2,3,ch3 + '|' + QString::number(((int16_t)servo.servo3_raw) * 22.5 / 32767.0,'f',2));
statusui->setValue(2,5,ch4 + '|' + QString::number(((int16_t)servo.servo4_raw) * 22.5 / 32767.0,'f',2));
@@ -1214,7 +1219,6 @@ void MainWindow::updateUI()//事件驱动式更新数据
case MAV_MODE_FLAG_SAFETY_ARMED:
arm_str.append(tr("ARM"));
menuBarUI->setFlightTime(QTime::fromMSecsSinceStartOfDay(FlightTime->time().msecsTo(QDateTime::currentDateTime().time())));//飞行时长
//toolsui->diagram->setTime(4,QTime::fromMSecsSinceStartOfDay(FlightTime->time().msecsTo(QDateTime::currentDateTime().time())));//飞行时长
break;
case 0:
arm_str.append(tr("DISARM"));
@@ -1394,19 +1398,13 @@ void MainWindow::updateUI()//事件驱动式更新数据
healthui->setColor(8,getBit(enabled,1)?(getBit(enabled,0)?(HealthUI::state::success):(HealthUI::state::warning)):(HealthUI::state::failure));//record
healthui->setColor(9,getBit(enabled,2)?(HealthUI::state::success):(HealthUI::state::inital));//正在记录,未记录
healthui->setValue(9,getBit(enabled,2)?(tr("正在写入")):(tr("停止写入")));//sel
//healthui->setColor(10,getBit(health,8)?(getBit(health,2)?(HealthUI::state::success):(HealthUI::state::warning)):(HealthUI::state::failure));//大气机
healthui->setColor(10,getBit(health,9)?(HealthUI::state::success):(HealthUI::state::inital));//动检完成
healthui->setColor(11,getBit(health,15)?(HealthUI::state::failure):(HealthUI::state::inital));//气囊盖
healthui->setColor(12,getBit(health,16)?(HealthUI::state::failure):(HealthUI::state::inital));//充气
healthui->setColor(13,getBit(health,17)?(HealthUI::state::failure):(HealthUI::state::inital));//开伞
healthui->setColor(14,getBit(health,18)?(HealthUI::state::failure):(HealthUI::state::inital));//切伞
healthui->setColor(15,getBit(health,20)?(HealthUI::state::failure):(HealthUI::state::inital));//点火1
//healthui->setColor(13,getBit(health,21)?(HealthUI::state::failure):(HealthUI::state::inital));//点火2
healthui->setColor(15,((getBit(health,20) == true)&&(getBit(health,21) == true))?(HealthUI::state::failure):(((getBit(health,20) == false)&&(getBit(health,21) == false))?(HealthUI::state::inital):(HealthUI::state::warning)));//大气机
healthui->setColor(15,((getBit(health,20) == true)&&(getBit(health,21) == true))?(HealthUI::state::failure):(((getBit(health,20) == false)&&(getBit(health,21) == false))?(HealthUI::state::inital):(HealthUI::state::warning)));//点火
healthui->setColor(16,getBit(health,8)?(getBit(health,2)?(HealthUI::state::success):(HealthUI::state::warning)):(HealthUI::state::failure));//大气机
healthui->setColor(18,getBit(health,22)?(HealthUI::state::success):(HealthUI::state::failure));//静压
+1 -6
View File
@@ -72,15 +72,10 @@ void ThreadTemplet::process()//线程函数
count ++;
QThread::msleep(1000/running_frq);
function();
}
}
void ThreadTemplet::function()//在这个地方写入功能
{
}
+1 -1
View File
@@ -46,7 +46,7 @@ public slots:
//缓存对外接口
virtual void function();
private slots:
//线程私有接口
+25 -17
View File
@@ -3,6 +3,8 @@
rtkprocess::rtkprocess(QObject *parent) : ThreadTemplet(parent)
{
//初始化buff
initbuff();
}
@@ -28,28 +30,34 @@ void rtkprocess::Send(mavlink_message_t msg)
//这里一直在解码,一直检查双缓冲里面是否有数据,有就解码,没有就休息
void rtkprocess::function()//线程函数
void rtkprocess::process()//线程函数
{
uint64_t lastTime = 0;
QByteArray datagram = nullptr;
static uint64_t lastTime = 0;
static QByteArray datagram = nullptr;
uint8_t count = 0;
while (running_flag)
{
count ++;
QThread::msleep(1000/running_frq);
//解码从串口来的
datagram.clear();
datagram = readbuff(SourceType::s_port);//每次全部读取
if(datagram.size() > 0)
{
parse(SourceType::s_port,datagram);
}
//解码从串口来的
datagram.clear();
datagram = readbuff(SourceType::s_port);//每次全部读取
if(datagram.size() > 0)
{
parse(SourceType::s_port,datagram);
}
quint64 currentTimestamp = (quint64)QDateTime::currentMSecsSinceEpoch();
if((currentTimestamp - lastTime) > 66)
{
lastTime = currentTimestamp;
update15Hz();
}
quint64 currentTimestamp = (quint64)QDateTime::currentMSecsSinceEpoch();
if((currentTimestamp - lastTime) > 66)
{
lastTime = currentTimestamp;
update15Hz();
}
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ private slots:
//解析
void parse(quint32 src,QByteArray datagram);
void function();
void process();
protected: