From 81524eeb43e4ae71245fded1a581a7a14d2e597e Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 2 Sep 2013 09:01:06 +0200 Subject: [PATCH] Added DSM binding support, improved mag and board rotation UI support --- src/ui/QGCPX4VehicleConfig.cc | 23 +++ src/ui/QGCPX4VehicleConfig.h | 2 + src/ui/QGCPX4VehicleConfig.ui | 134 +++++++++++------- .../QGCPX4SensorCalibration.cc | 20 ++- .../QGCPX4SensorCalibration.ui | 6 + 5 files changed, 128 insertions(+), 57 deletions(-) diff --git a/src/ui/QGCPX4VehicleConfig.cc b/src/ui/QGCPX4VehicleConfig.cc index 9ab20d324..04bd330d0 100644 --- a/src/ui/QGCPX4VehicleConfig.cc +++ b/src/ui/QGCPX4VehicleConfig.cc @@ -154,7 +154,11 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : ui->graphicsView->hide(); ui->rcCalibrationButton->setCheckable(true); + ui->rcCalibrationButton->setEnabled(false); connect(ui->rcCalibrationButton, SIGNAL(clicked(bool)), this, SLOT(toggleCalibrationRC(bool))); + ui->spektrumPairButton->setCheckable(true); + ui->spektrumPairButton->setEnabled(false); + connect(ui->spektrumPairButton, SIGNAL(clicked(bool)), this, SLOT(toggleSpektrumPairing(bool))); //TODO connect buttons here to save/clear actions? UASInterface* tmpMav = UASManager::instance()->getActiveUAS(); @@ -329,6 +333,22 @@ void QGCPX4VehicleConfig::toggleCalibrationRC(bool enabled) } } +void QGCPX4VehicleConfig::toggleSpektrumPairing(bool enabled) +{ + if (enabled) + { + mav->getParamManager()->setPendingParam(0, "RC_DSM_BIND", (int)1); + // Do not save this parameter, just set in RAM + mav->getParamManager()->sendPendingParameters(); + } + else + { + mav->getParamManager()->setPendingParam(0, "RC_DSM_BIND", (int)0); + // Do not save this parameter, just set in RAM + mav->getParamManager()->sendPendingParameters(); + } +} + void QGCPX4VehicleConfig::setTrimPositions() { int rollMap = rcMapping[0]; @@ -1140,6 +1160,9 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) ui->airframeMenuButton->setEnabled(true); ui->sensorMenuButton->setEnabled(true); ui->rcMenuButton->setEnabled(true); + + ui->rcCalibrationButton->setEnabled(true); + ui->spektrumPairButton->setEnabled(true); } void QGCPX4VehicleConfig::resetCalibrationRC() diff --git a/src/ui/QGCPX4VehicleConfig.h b/src/ui/QGCPX4VehicleConfig.h index 62d11c014..55778bc3a 100644 --- a/src/ui/QGCPX4VehicleConfig.h +++ b/src/ui/QGCPX4VehicleConfig.h @@ -60,6 +60,8 @@ public slots: void stopCalibrationRC(); /** Start/stop the RC calibration routine */ void toggleCalibrationRC(bool enabled); + /** Start/stop the Spektrum pair routine */ + void toggleSpektrumPairing(bool enabled); /** Set trim positions */ void setTrimPositions(); /** Detect which channels need to be inverted */ diff --git a/src/ui/QGCPX4VehicleConfig.ui b/src/ui/QGCPX4VehicleConfig.ui index 858e40936..db6fbd9f2 100644 --- a/src/ui/QGCPX4VehicleConfig.ui +++ b/src/ui/QGCPX4VehicleConfig.ui @@ -7,7 +7,7 @@ 0 0 1256 - 985 + 1009 @@ -50,9 +50,25 @@ - - - + + + + + + 50 + 200 + + + + + 50 + 200 + + + + + + 250 @@ -67,6 +83,28 @@ + + + + + 1 + 0 + + + + + 50 + 200 + + + + + 50 + 200 + + + + @@ -135,30 +173,8 @@ - - - - - 1 - 0 - - - - - 50 - 200 - - - - - 50 - 200 - - - - - - + + 250 @@ -173,28 +189,36 @@ - - - - - 50 - 200 - - - - - 50 - 200 - - - - - - - Start Calibration - - + + + + + Start Calibration + + + + + + + Spektrum RC Pairing + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -829,8 +853,8 @@ 0 0 - 98 - 28 + 16 + 16 @@ -866,8 +890,8 @@ 0 0 - 98 - 28 + 16 + 16 @@ -917,8 +941,8 @@ 0 0 - 98 - 28 + 16 + 16 diff --git a/src/ui/px4_configuration/QGCPX4SensorCalibration.cc b/src/ui/px4_configuration/QGCPX4SensorCalibration.cc index e5eb3501f..6ba8f4c4e 100644 --- a/src/ui/px4_configuration/QGCPX4SensorCalibration.cc +++ b/src/ui/px4_configuration/QGCPX4SensorCalibration.cc @@ -67,6 +67,18 @@ QGCPX4SensorCalibration::QGCPX4SensorCalibration(QWidget *parent) : ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270_YAW_135"), 23); ui->autopilotComboBox->addItem(tr("ROTATION_PITCH_90"), 24); ui->autopilotComboBox->addItem(tr("ROTATION_PITCH_270"), 25); + ui->autopilotComboBox->addItem(tr("ROTATION_PITCH_180_YAW_90"), 26); + ui->autopilotComboBox->addItem(tr("ROTATION_PITCH_180_YAW_270"), 27); + ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_PITCH_90"), 28); + ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180_PITCH_90"), 29); + ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270_PITCH_90"), 30); + ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_PITCH_180"), 31); + ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270_PITCH_180"), 32); + ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_PITCH_270"), 33); + ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180_PITCH_270"), 34); + ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270_PITCH_270"), 35); + ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_PITCH_180_YAW_90"), 36); + ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_YAW_270"), 37); ui->magComboBox->addItem(tr("Default Orientation"), 0); ui->magComboBox->addItem(tr("ROTATION_YAW_45"), 1); @@ -381,8 +393,10 @@ void QGCPX4SensorCalibration::handleTextMessage(int uasid, int compId, int sever accelStarted = false; // XXX use a confirmation image or something setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); - if (activeUAS) + if (activeUAS) { activeUAS->requestParameter(0, "SENS_ACC_XOFF"); + activeUAS->requestParameter(0, "SENS_BOARD_ROT"); + } } if (text.contains("gyro calibration done")) { @@ -398,8 +412,10 @@ void QGCPX4SensorCalibration::handleTextMessage(int uasid, int compId, int sever magStarted = false; // XXX use a confirmation image or something setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); - if (activeUAS) + if (activeUAS) { activeUAS->requestParameter(0, "SENS_MAG_XOFF"); + activeUAS->requestParameter(0, "SENS_EXT_MAG_ROT"); + } } if (text.contains("accel calibration started")) { diff --git a/src/ui/px4_configuration/QGCPX4SensorCalibration.ui b/src/ui/px4_configuration/QGCPX4SensorCalibration.ui index 0533f386b..411796a59 100644 --- a/src/ui/px4_configuration/QGCPX4SensorCalibration.ui +++ b/src/ui/px4_configuration/QGCPX4SensorCalibration.ui @@ -179,6 +179,12 @@ QPushButton#gyroButton, QPushButton#accelButton { + + + 150 + 150 + + -- 2.22.0