Commit 879e1f6a authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #412 from thomasgubler/airspeed_calibration

differential pressure/airspeed calibration ui
parents 74ee8c7c c086bcbb
......@@ -17,6 +17,7 @@ QGCPX4SensorCalibration::QGCPX4SensorCalibration(QWidget *parent) :
connect(ui->gyroButton, SIGNAL(clicked()), this, SLOT(gyroButtonClicked()));
connect(ui->magButton, SIGNAL(clicked()), this, SLOT(magButtonClicked()));
connect(ui->accelButton, SIGNAL(clicked()), this, SLOT(accelButtonClicked()));
connect(ui->diffPressureButton, SIGNAL(clicked()), this, SLOT(diffPressureButtonClicked()));
ui->gyroButton->setEnabled(false);
ui->magButton->setEnabled(false);
......@@ -168,6 +169,17 @@ void QGCPX4SensorCalibration::parameterChanged(int uas, int component, QString p
setAccelCalibrated(true);
}
}
// Check differential pressure calibration naively
if (parameterName.contains("SENS_DPRES_OFF")) {
float offset = value.toFloat();
if (offset < 0.000001f && offset > -0.000001f) {
// Must be zero, not good
setDiffPressureCalibrated(false);
} else {
setDiffPressureCalibrated(true);
}
}
}
void QGCPX4SensorCalibration::setMagCalibrated(bool calibrated)
......@@ -215,6 +227,21 @@ void QGCPX4SensorCalibration::setAccelCalibrated(bool calibrated)
}
}
void QGCPX4SensorCalibration::setDiffPressureCalibrated(bool calibrated)
{
if (calibrated) {
ui->diffPressureLabel->setText(tr("DIFF. PRESSURE CALIBRATED"));
ui->diffPressureLabel->setStyleSheet("QLabel { color: #FFFFFF;"
"background-color: #20AA20;"
"}");
} else {
ui->diffPressureLabel->setText(tr("DIFF. PRESSURE UNCALIBRATED"));
ui->diffPressureLabel->setStyleSheet("QLabel { color: #FFFFFF;"
"background-color: #FF0037;"
"}");
}
}
void QGCPX4SensorCalibration::setInstructionImage(const QString &path)
{
instructionIcon.load(path);
......@@ -384,6 +411,11 @@ void QGCPX4SensorCalibration::handleTextMessage(int uasid, int compId, int sever
activeUAS->requestParameter(0, "SENS_MAG_ZSCALE");
activeUAS->requestParameter(0, "SENS_EXT_MAG_ROT");
}
if (text.startsWith("dpress ")) {
activeUAS->requestParameter(0, "SENS_DPRES_OFF");
activeUAS->requestParameter(0, "SENS_DPRES_ANA");
}
}
}
......@@ -427,6 +459,13 @@ void QGCPX4SensorCalibration::accelButtonClicked()
ui->progressBar->setValue(0);
}
void QGCPX4SensorCalibration::diffPressureButtonClicked()
{
setInstructionImage(":/files/images/px4/calibration/accel_z-.png");
activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0);
ui->progressBar->setValue(0);
}
void QGCPX4SensorCalibration::contextMenuEvent(QContextMenuEvent* event)
{
QMenu menu(this);
......
......@@ -35,6 +35,7 @@ public slots:
void gyroButtonClicked();
void magButtonClicked();
void accelButtonClicked();
void diffPressureButtonClicked();
/**
* @brief Hand context menu event
......@@ -70,6 +71,7 @@ protected:
void setMagCalibrated(bool calibrated);
void setGyroCalibrated(bool calibrated);
void setAccelCalibrated(bool calibrated);
void setDiffPressureCalibrated(bool calibrated);
void updateIcons();
......
......@@ -25,7 +25,7 @@
border: 2px solid #465158;
}
QPushButton#gyroButton, QPushButton#accelButton {
QPushButton#gyroButton, QPushButton#accelButton, QPushButton#diffPressureButton {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D3795D, stop: 1 #A81154);
border-radius: 8px;
min-height: 25px;
......@@ -121,6 +121,27 @@ QPushButton#gyroButton, QPushButton#accelButton {
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="diffPressureButton">
<property name="text">
<string>Diff. pressure</string>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/px4/calibration/arrows.png</normaloff>:/files/images/px4/calibration/arrows.png</iconset>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="diffPressureLabel">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="magLabel">
<property name="text">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment