diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 8b796850b09843f01b8ce3af91bc9fe7d660529e..31f08c1fba067585fe3d2b87fffed2a0949e2e93 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -256,7 +256,8 @@ FORMS += src/ui/MainWindow.ui \ src/ui/configuration/GeoFenceConfig.ui \ src/ui/configuration/FailSafeConfig.ui \ src/ui/configuration/AdvancedParamConfig.ui \ - src/ui/configuration/ArduCopterPidConfig.ui + src/ui/configuration/ArduCopterPidConfig.ui \ + src/ui/configuration/ApmPlaneLevel.ui INCLUDEPATH += src \ src/ui \ src/ui/linechart \ @@ -437,7 +438,8 @@ HEADERS += src/MG.h \ src/ui/configuration/GeoFenceConfig.h \ src/ui/configuration/FailSafeConfig.h \ src/ui/configuration/AdvancedParamConfig.h \ - src/ui/configuration/ArduCopterPidConfig.h + src/ui/configuration/ArduCopterPidConfig.h \ + src/ui/configuration/ApmPlaneLevel.h # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h @@ -636,7 +638,8 @@ SOURCES += src/main.cc \ src/ui/configuration/GeoFenceConfig.cc \ src/ui/configuration/FailSafeConfig.cc \ src/ui/configuration/AdvancedParamConfig.cc \ - src/ui/configuration/ArduCopterPidConfig.cc + src/ui/configuration/ArduCopterPidConfig.cc \ + src/ui/configuration/ApmPlaneLevel.cc # Enable Google Earth only on Mac OS and Windows with Visual Studio compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc diff --git a/src/ui/configuration/ApmPlaneLevel.cc b/src/ui/configuration/ApmPlaneLevel.cc new file mode 100644 index 0000000000000000000000000000000000000000..7b00374834ebdadee6eaac9418b0310f09bc66ae --- /dev/null +++ b/src/ui/configuration/ApmPlaneLevel.cc @@ -0,0 +1,59 @@ +#include "ApmPlaneLevel.h" +#include + +ApmPlaneLevel::ApmPlaneLevel(QWidget *parent) : AP2ConfigWidget(parent) +{ + ui.setupUi(this); + connect(ui.levelPushButton,SIGNAL(clicked()),this,SLOT(levelClicked())); + connect(ui.manualLevelCheckBox,SIGNAL(toggled(bool)),this,SLOT(manualCheckBoxToggled(bool))); +} + +ApmPlaneLevel::~ApmPlaneLevel() +{ +} +void ApmPlaneLevel::levelClicked() +{ + QMessageBox::information(0,"Warning","Be sure the plane is completly level, then click ok"); + MAV_CMD command = MAV_CMD_PREFLIGHT_CALIBRATION; + int confirm = 0; + float param1 = 1; + float param2 = 0; + float param3 = 1; + float param4 = 0; + float param5 = 0; + float param6 = 0; + float param7 = 0; + int component = 1; + m_uas->executeCommand(command, confirm, param1, param2, param3, param4, param5, param6, param7, component); + QMessageBox::information(0,"Warning","Leveling completed"); +} + +void ApmPlaneLevel::manualCheckBoxToggled(bool checked) +{ + if (!m_uas) + { + return; + } + if (checked) + { + m_uas->getParamManager()->setParameter(1,"MANUAL_LEVEL",1); + } + else + { + m_uas->getParamManager()->setParameter(1,"MANUAL_LEVEL",0); + } +} +void ApmPlaneLevel::parameterChanged(int uas, int component, QString parameterName, QVariant value) +{ + if (parameterName == "MANUAL_LEVEL") + { + if (value.toInt() == 1) + { + ui.manualLevelCheckBox->setChecked(true); + } + else + { + ui.manualLevelCheckBox->setChecked(false); + } + } +} diff --git a/src/ui/configuration/ApmPlaneLevel.h b/src/ui/configuration/ApmPlaneLevel.h new file mode 100644 index 0000000000000000000000000000000000000000..a6a38078f3704b10a283126fc84a6aebfe8738bd --- /dev/null +++ b/src/ui/configuration/ApmPlaneLevel.h @@ -0,0 +1,23 @@ +#ifndef APMPLANELEVEL_H +#define APMPLANELEVEL_H + +#include +#include "ui_ApmPlaneLevel.h" +#include "AP2ConfigWidget.h" + +class ApmPlaneLevel : public AP2ConfigWidget +{ + Q_OBJECT + +public: + explicit ApmPlaneLevel(QWidget *parent = 0); + ~ApmPlaneLevel(); +private slots: + void parameterChanged(int uas, int component, QString parameterName, QVariant value); + void levelClicked(); + void manualCheckBoxToggled(bool checked); +private: + Ui::ApmPlaneLevel ui; +}; + +#endif // APMPLANELEVEL_H diff --git a/src/ui/configuration/ApmPlaneLevel.ui b/src/ui/configuration/ApmPlaneLevel.ui new file mode 100644 index 0000000000000000000000000000000000000000..ef22b19992f262acf776e84fbfca097e2074c997 --- /dev/null +++ b/src/ui/configuration/ApmPlaneLevel.ui @@ -0,0 +1,99 @@ + + + ApmPlaneLevel + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + 10 + 10 + 141 + 31 + + + + <h2>ArduPlane Level</h2> + + + + + + 50 + 70 + 271 + 41 + + + + By Default your plane will autolevel on every boot. +To disable this action you need to turn on manual +level and perform a level to calibrate the accel offsets. + + + + + + 50 + 150 + 291 + 16 + + + + Level your plane and click Level to set default accel offsets + + + + + + 160 + 180 + 75 + 23 + + + + Level + + + + + + 120 + 230 + 151 + 51 + + + + For advanced users ONLY + + + + + 30 + 20 + 91 + 17 + + + + Manual Level + + + + + + +