diff --git a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp index ae9eeeaf0..c2242f1ef 100644 --- a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp @@ -163,3 +163,10 @@ void ConfigCCAttitudeWidget::openHelp() QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/CopterControl+Attitude+Configuration", QUrl::StrictMode) ); } +void ConfigCCAttitudeWidget::enableControls(bool enable) +{ + if(ui->zeroBias) + ui->zeroBias->setEnabled(enable); + ConfigTaskWidget::enableControls(enable); + +} diff --git a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.h b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.h index aa3b6cad7..09dfdb222 100644 --- a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.h @@ -66,6 +66,8 @@ private: static const int NUM_ACCEL_UPDATES = 60; static const float ACCEL_SCALE = 0.004f * 9.81f; +protected: + virtual void enableControls(bool enable); }; diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp index 0078a1bf2..af8368c1f 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp @@ -117,6 +117,15 @@ void ConfigGadgetWidget::resizeEvent(QResizeEvent *event) } void ConfigGadgetWidget::onAutopilotDisconnect() { + ftw->setCurrentIndex(ConfigGadgetWidget::hardware); + ftw->removeTab(ConfigGadgetWidget::ins); + QWidget *qwd = new DefaultAttitudeWidget(this); + ftw->insertTab(ConfigGadgetWidget::ins, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); + ftw->removeTab(ConfigGadgetWidget::hardware); + qwd = new DefaultHwSettingsWidget(this); + ftw->insertTab(ConfigGadgetWidget::hardware, qwd, QIcon(":/configgadget/images/hw_config.png"), QString("HW Settings")); + ftw->setCurrentIndex(ConfigGadgetWidget::hardware); + emit autopilotDisconnected(); } diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index d18976086..3fc4e8378 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -45,7 +45,7 @@ #define STICK_MIN_MOVE -8 #define STICK_MAX_MOVE 8 -ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent),wizardStep(wizardWelcome),loop(NULL),skipflag(false) +ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent),wizardStep(wizardWelcome),loop(NULL),skipflag(false),goWizard(NULL) { manualCommandObj = ManualControlCommand::GetInstance(getObjectManager()); manualSettingsObj = ManualControlSettings::GetInstance(getObjectManager()); @@ -68,7 +68,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent) addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMax",inp->ui->channelMax,index); ++index; } - QPushButton * goWizard=new QPushButton(tr("Start Wizard"),this); + goWizard=new QPushButton(tr("Start Wizard"),this); m_config->advancedPage->layout()->addWidget(goWizard); connect(goWizard,SIGNAL(clicked()),this,SLOT(goToWizard())); connect(m_config->wzNext,SIGNAL(clicked()),this,SLOT(wzNext())); @@ -92,6 +92,8 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent) addUAVObjectToWidgetRelation("ManualControlSettings","Arming",m_config->armControl); addUAVObjectToWidgetRelation("ManualControlSettings","armTimeout",m_config->armTimeout,0,1000); + + addWidget(goWizard); enableControls(false); populateWidgets(); @@ -258,6 +260,7 @@ void ConfigInputWidget::goToWizard() void ConfigInputWidget::wzCancel() { + dimOtherControls(false); manualCommandObj->setMetadata(manualCommandObj->getDefaultMetadata()); m_config->stackedWidget->setCurrentIndex(0); foreach (QWidget * wd, extraWidgets) @@ -305,6 +308,7 @@ void ConfigInputWidget::setupWizardWidget(int step) { if(step==wizardWelcome) { + m_config->graphicsView->setVisible(false); setTxMovement(nothing); if(wizardStep==wizardChooseMode) { @@ -317,7 +321,8 @@ void ConfigInputWidget::setupWizardWidget(int step) manualSettingsObj->setData(manualSettingsData); m_config->wzText->setText(tr("Welcome to the inputs configuration wizard.\n" "Please follow the instruction on the screen and only move your controls when asked to.\n" - "At any time you can press 'back' to return to the previous screeen or 'Cancel' to cancel the wizard" + "Make sure you already configured your hardware settings on the proper tab and restarted your board.\n" + "At any time you can press 'back' to return to the previous screeen or 'Cancel' to cancel the wizard \n" "For your safety your arming setting is now 'Always Disarmed' please reenable it after this wizard.")); m_config->stackedWidget->setCurrentIndex(1); m_config->wzBack->setEnabled(false); @@ -325,6 +330,7 @@ void ConfigInputWidget::setupWizardWidget(int step) } else if(step==wizardChooseMode) { + m_config->graphicsView->setVisible(true); setTxMovement(nothing); if(wizardStep==wizardIdentifySticks) { @@ -384,6 +390,7 @@ void ConfigInputWidget::setupWizardWidget(int step) } else if(step==wizardIdentifyLimits) { + dimOtherControls(false); setTxMovement(moveAll); if(wizardStep==wizardIdentifyCenter) { @@ -396,6 +403,13 @@ void ConfigInputWidget::setupWizardWidget(int step) } manualSettingsObj->setData(manualSettingsData); } + foreach (QWidget * wd, extraWidgets) + { + if(wd) + delete wd; + } + extraWidgets.clear(); + disconnect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks())); wizardStep=wizardIdentifyLimits; m_config->wzText->setText(QString(tr("Please move all controls to their maximum extends on both directions and press next when ready"))); UAVObject::Metadata mdata= manualCommandObj->getMetadata(); @@ -412,6 +426,7 @@ void ConfigInputWidget::setupWizardWidget(int step) } else if(step==wizardIdentifyInverted) { + dimOtherControls(true); setTxMovement(nothing); if(wizardStep==wizardIdentifyLimits) { @@ -644,6 +659,7 @@ void ConfigInputWidget::setTxMovement(txMovements movement) animate->start(50); break; case nothing: + movePos=0; animate->stop(); break; default: @@ -840,14 +856,34 @@ void ConfigInputWidget::moveSticks() trans=m_txLeftStickOrig; m_txLeftStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false); trans=m_txRightStickOrig; - m_txRightStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,-manualCommandData.Pitch*STICK_MAX_MOVE*10),false); + m_txRightStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false); } else { trans=m_txRightStickOrig; m_txRightStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false); trans=m_txLeftStickOrig; - m_txLeftStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,-manualCommandData.Pitch*STICK_MAX_MOVE*10),false); + m_txLeftStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false); } } +void ConfigInputWidget::dimOtherControls(bool value) +{ + qreal opac; + if(value) + opac=0.1; + else + opac=1; + m_txAccess0->setOpacity(opac); + m_txAccess1->setOpacity(opac); + m_txAccess2->setOpacity(opac); + m_txFlightMode->setOpacity(opac); +} + +void ConfigInputWidget::enableControls(bool enable) +{ + if(goWizard) + goWizard->setEnabled(enable); + ConfigTaskWidget::enableControls(enable); + +} diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.h b/ground/openpilotgcs/src/plugins/config/configinputwidget.h index b1769026b..e3917bb85 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.h @@ -116,6 +116,7 @@ private: QTimer * animate; void resetTxControls(); void setMoveFromCommand(int command); + QPushButton * goWizard; private slots: void wzNext(); void wzBack(); @@ -125,9 +126,11 @@ private slots: void identifyControls(); void identifyLimits(); void moveTxControls(); - void moveSticks(); + void moveSticks(); + void dimOtherControls(bool value); protected: void resizeEvent(QResizeEvent *event); + virtual void enableControls(bool enable); }; diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp index 8aa6a3f33..03b84804c 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp @@ -238,6 +238,7 @@ void ConfigTaskWidget::setupButtons(QPushButton *update, QPushButton *save) connect(smartsave,SIGNAL(saveSuccessfull()),this,SLOT(clearDirty())); connect(smartsave,SIGNAL(beginOp()),this,SLOT(disableObjUpdates())); connect(smartsave,SIGNAL(endOp()),this,SLOT(enableObjUpdates())); + enableControls(false); } void ConfigTaskWidget::enableControls(bool enable) diff --git a/ground/openpilotgcs/src/plugins/config/input.ui b/ground/openpilotgcs/src/plugins/config/input.ui index 9849183d5..0ec15f063 100644 --- a/ground/openpilotgcs/src/plugins/config/input.ui +++ b/ground/openpilotgcs/src/plugins/config/input.ui @@ -36,6 +36,18 @@ + + + 0 + 0 + + + + + 0 + 70 + + 10 diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp index dff4e409e..7335570eb 100644 --- a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp @@ -92,7 +92,8 @@ void smartSaveButton::setObjects(QList list) void smartSaveButton::addObject(UAVObject * obj) { - objects.append(obj); + if(!objects.contains(obj)) + objects.append(obj); } void smartSaveButton::clearObjects()