diff --git a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp index c2242f1ef..c659180af 100644 --- a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp @@ -45,8 +45,6 @@ ConfigCCAttitudeWidget::ConfigCCAttitudeWidget(QWidget *parent) : setupButtons(ui->applyButton,ui->saveButton); addUAVObject("AttitudeSettings"); - UAVObject * settings = AttitudeSettings::GetInstance(getObjectManager()); - // Connect the help button connect(ui->ccAttitudeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); addUAVObjectToWidgetRelation("AttitudeSettings","ZeroDuringArming",ui->zeroGyroBiasOnArming); diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 4544b4edd..6313c45b1 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -71,7 +71,11 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent) } goWizard=new QPushButton(tr("Start Wizard"),this); m_config->advancedPage->layout()->addWidget(goWizard); - connect(goWizard,SIGNAL(clicked()),this,SLOT(goToWizard())); + connect(goWizard,SIGNAL(clicked()),this,SLOT(goToNormalWizard())); + goSimpleWizard=new QPushButton(tr("Start Simple Wizard"),this); + m_config->advancedPage->layout()->addWidget(goSimpleWizard); + connect(goSimpleWizard,SIGNAL(clicked()),this,SLOT(goToSimpleWizard())); + connect(m_config->wzNext,SIGNAL(clicked()),this,SLOT(wzNext())); connect(m_config->wzCancel,SIGNAL(clicked()),this,SLOT(wzCancel())); connect(m_config->wzBack,SIGNAL(clicked()),this,SLOT(wzBack())); @@ -92,9 +96,10 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent) addUAVObjectToWidgetRelation("ManualControlSettings","Stabilization3Settings",m_config->fmsSsPos3Yaw,"Yaw"); addUAVObjectToWidgetRelation("ManualControlSettings","Arming",m_config->armControl); - addUAVObjectToWidgetRelation("ManualControlSettings","armTimeout",m_config->armTimeout,0,1000); - addUAVObject("ManualControlCommand"); + addUAVObjectToWidgetRelation("ManualControlSettings","ArmedTimeout",m_config->armTimeout,0,1000); + connect( ManualControlCommand::GetInstance(getObjectManager()),SIGNAL(objectUpdated(UAVObject*)),this,SLOT(moveFMSlider())); addWidget(goWizard); + addWidget(goSimpleWizard); enableControls(false); populateWidgets(); @@ -252,7 +257,16 @@ void ConfigInputWidget::openHelp() QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Input+Configuration", QUrl::StrictMode) ); } - +void ConfigInputWidget::goToSimpleWizard() +{ + isSimple=true; + goToWizard(); +} +void ConfigInputWidget::goToNormalWizard() +{ + isSimple=false; + goToWizard(); +} void ConfigInputWidget::goToWizard() { QMessageBox msgBox; @@ -357,7 +371,7 @@ void ConfigInputWidget::setupWizardWidget(int step) m_config->checkBoxesLayout->layout()->addWidget(mode2); wizardStep=wizardChooseMode; } - else if(step==wizardIdentifySticks) + else if(step==wizardIdentifySticks && !isSimple) { usedChannels.clear(); if(wizardStep==wizardChooseMode) @@ -380,8 +394,19 @@ void ConfigInputWidget::setupWizardWidget(int step) connect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls())); m_config->wzNext->setEnabled(false); } - else if(step==wizardIdentifyCenter) + else if(step==wizardIdentifyCenter || (isSimple && step==wizardIdentifySticks)) { + if(wizardStep==wizardChooseMode) + { + QRadioButton * mode=qobject_cast(extraWidgets.at(0)); + if(mode->isChecked()) + transmitterMode=mode1; + else + transmitterMode=mode2; + delete extraWidgets.at(0); + delete extraWidgets.at(1); + extraWidgets.clear(); + } setTxMovement(centerAll); if(wizardStep==wizardIdentifySticks) disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls())); @@ -409,10 +434,17 @@ void ConfigInputWidget::setupWizardWidget(int step) } manualSettingsObj->setData(manualSettingsData); } - foreach (QWidget * wd, extraWidgets) + if(wizardStep==wizardIdentifyInverted) { - if(wd) - delete wd; + foreach(QWidget * wd,extraWidgets) + { + QCheckBox * cb=qobject_cast(wd); + if(cb) + { + disconnect(cb,SIGNAL(toggled(bool)),this,SLOT(invertControls())); + delete cb; + } + } } extraWidgets.clear(); disconnect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks())); @@ -423,7 +455,7 @@ void ConfigInputWidget::setupWizardWidget(int step) mdata.flightTelemetryUpdatePeriod = 150; manualCommandObj->setMetadata(mdata); manualSettingsData=manualSettingsObj->getData(); - for(int i=0;i(wd); if(cb) + { + disconnect(cb,SIGNAL(toggled(bool)),this,SLOT(invertControls())); delete cb; + } } wizardStep=wizardFinish; extraWidgets.clear(); @@ -537,7 +572,7 @@ void ConfigInputWidget::identifyControls() void ConfigInputWidget::identifyLimits() { manualCommandData=manualCommandObj->getData(); - for(int i=0;imanualCommandData.Channel[i]) manualSettingsData.ChannelMin[i]=manualCommandData.Channel[i]; @@ -878,7 +913,10 @@ void ConfigInputWidget::dimOtherControls(bool value) void ConfigInputWidget::enableControls(bool enable) { if(goWizard) + { goWizard->setEnabled(enable); + goSimpleWizard->setEnabled(enable); + } ConfigTaskWidget::enableControls(enable); } @@ -891,9 +929,10 @@ void ConfigInputWidget::invertControls() QCheckBox * cb=qobject_cast(wd); if(cb) { - if(cb->isChecked()) + int index=manualSettingsObj->getFields().at(0)->getElementNames().indexOf(cb->text()); + if((cb->isChecked() && (manualSettingsData.ChannelMax[index]>manualSettingsData.ChannelMin[index])) || + (!cb->isChecked() && (manualSettingsData.ChannelMax[index]getFields().at(0)->getElementNames().indexOf(cb->text()); qint16 aux; aux=manualSettingsData.ChannelMax[index]; manualSettingsData.ChannelMax[index]=manualSettingsData.ChannelMin[index]; @@ -903,20 +942,19 @@ void ConfigInputWidget::invertControls() } manualSettingsObj->setData(manualSettingsData); } -void ConfigInputWidget::refreshWidgetsValues() +void ConfigInputWidget::moveFMSlider() { - ConfigTaskWidget::refreshWidgetsValues(); - manualSettingsData = manualSettingsObj->getData(); - manualCommandData=manualCommandObj->getData(); - uint chIndex = manualSettingsData.ChannelNumber[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE]; + ManualControlSettings::DataFields manualSettingsDataPriv = manualSettingsObj->getData(); + ManualControlCommand::DataFields manualCommandDataPriv=manualCommandObj->getData(); + uint chIndex = manualSettingsDataPriv.ChannelNumber[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE]; if (chIndex < 8) { float valueScaled; - int chMin = manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE]; - int chMax = manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE]; - int chNeutral = manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE]; + int chMin = manualSettingsDataPriv.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE]; + int chMax = manualSettingsDataPriv.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE]; + int chNeutral = manualSettingsDataPriv.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE]; - int value = manualCommandData.Channel[chIndex]; + int value = manualCommandDataPriv.Channel[chIndex]; if ((chMax > chMin && value >= chNeutral) || (chMin > chMax && value <= chNeutral)) { if (chMax != chNeutral) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.h b/ground/openpilotgcs/src/plugins/config/configinputwidget.h index 7c90fef76..2249528cb 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.h @@ -82,7 +82,7 @@ private: QEventLoop * loop; bool skipflag; - int currentCommand; + uint currentCommand; ManualControlCommand * manualCommandObj; ManualControlCommand::DataFields manualCommandData; @@ -117,23 +117,27 @@ private: void resetTxControls(); void setMoveFromCommand(int command); QPushButton * goWizard; + QPushButton * goSimpleWizard; + bool isSimple; + void goToWizard(); private slots: void wzNext(); void wzBack(); void wzCancel(); - void goToWizard(); + void goToNormalWizard(); + void goToSimpleWizard(); void openHelp(); void identifyControls(); void identifyLimits(); void moveTxControls(); void moveSticks(); void dimOtherControls(bool value); + void moveFMSlider(); void invertControls(); protected: void resizeEvent(QResizeEvent *event); virtual void enableControls(bool enable); -protected slots: - virtual void refreshWidgetsValues(); + }; diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp index 03b84804c..eeb6c08aa 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp @@ -28,7 +28,7 @@ #include -ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),smartsave(NULL),dirty(false) +ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false) { pm = ExtensionSystem::PluginManager::instance(); objManager = pm->getObject(); @@ -72,7 +72,7 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel ow->scale=scale; objOfInterest.append(ow); if(obj) - smartsave->addObject(obj); + smartsave->addObject((UAVDataObject*)obj); if(widget==NULL) { // do nothing @@ -148,13 +148,16 @@ double ConfigTaskWidget::listMean(QList list) void ConfigTaskWidget::onAutopilotDisconnect() { - enableControls(false); + isConnected=false; + enableControls(false); } void ConfigTaskWidget::onAutopilotConnect() { - enableControls(true); - refreshWidgetsValues(); + dirty=false; + isConnected=true; + enableControls(true); + refreshWidgetsValues(); } void ConfigTaskWidget::populateWidgets() @@ -262,7 +265,10 @@ void ConfigTaskWidget::setDirty(bool value) } bool ConfigTaskWidget::isDirty() { - return dirty; + if(isConnected) + return dirty; + else + return false; } void ConfigTaskWidget::refreshValues() diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.h b/ground/openpilotgcs/src/plugins/config/configtaskwidget.h index 1db0dde9c..b2a72cbc6 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.h @@ -79,6 +79,7 @@ private slots: virtual void refreshValues(); virtual void updateObjectsFromWidgets(); private: + bool isConnected; QStringList objectsList; QList objOfInterest; ExtensionSystem::PluginManager *pm; diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp index 7335570eb..c74f22691 100644 --- a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp @@ -24,8 +24,11 @@ void smartSaveButton::processClick() bool error=false; ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectUtilManager* utilMngr = pm->getObject(); - foreach(UAVObject * obj,objects) + foreach(UAVDataObject * obj,objects) { + UAVObject::Metadata mdata= obj->getMetadata(); + if(mdata.gcsAccess==UAVObject::ACCESS_READONLY) + continue; up_result=false; current_object=obj; for(int i=0;i<3;++i) @@ -35,9 +38,9 @@ void smartSaveButton::processClick() connect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); obj->updated(); timer.start(1000); - qDebug()<<"begin loop"; + //qDebug()<<"begin loop"; loop.exec(); - qDebug()<<"end loop"; + //qDebug()<<"end loop"; timer.stop(); disconnect(obj,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(transaction_finished(UAVObject*, bool))); disconnect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); @@ -46,30 +49,32 @@ void smartSaveButton::processClick() } if(up_result==false) { + //qDebug()<<"Object upload error:"<getName(); error=true; continue; } sv_result=false; current_objectID=obj->getObjID(); - if(save) + if(save && (obj->isSettings())) { - for(int i=0;i<3;++i) - { - connect(utilMngr,SIGNAL(saveCompleted(int,bool)),this,SLOT(saving_finished(int,bool))); - connect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); - utilMngr->saveObjectToSD(obj); - timer.start(1000); - loop.exec(); - timer.stop(); - disconnect(utilMngr,SIGNAL(saveCompleted(int,bool)),this,SLOT(saving_finished(int,bool))); - disconnect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); - if(sv_result) - break; - } - if(sv_result==false) - { - error=true; - } + for(int i=0;i<3;++i) + { + //qDebug()<<"try to save:"<getName(); + connect(utilMngr,SIGNAL(saveCompleted(int,bool)),this,SLOT(saving_finished(int,bool))); + connect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); + utilMngr->saveObjectToSD(obj); + timer.start(1000); + loop.exec(); + timer.stop(); + disconnect(utilMngr,SIGNAL(saveCompleted(int,bool)),this,SLOT(saving_finished(int,bool))); + disconnect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); + if(sv_result) + break; + } + if(sv_result==false) + { + error=true; + } } } button->setEnabled(true); @@ -85,12 +90,12 @@ void smartSaveButton::processClick() emit endOp(); } -void smartSaveButton::setObjects(QList list) +void smartSaveButton::setObjects(QList list) { objects=list; } -void smartSaveButton::addObject(UAVObject * obj) +void smartSaveButton::addObject(UAVDataObject * obj) { if(!objects.contains(obj)) objects.append(obj); @@ -114,7 +119,7 @@ void smartSaveButton::saving_finished(int id, bool result) if(id==current_objectID) { sv_result=result; - qDebug()<<"saving_finished result="<lblCRCL->setText( QString::number(DFUObject::CRCFromQBArray(loadedFW,m_dfu->devices[deviceID].SizeOfCode))); //myDevice->lblFirmwareSizeL->setText(QString("Firmware size: ")+QVariant(loadedFW.length()).toString()+ QString(" bytes")); if (populateLoadedStructuredDescription(desc)) { diff --git a/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp b/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp index 8a9045233..b1e215f91 100644 --- a/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp @@ -956,7 +956,7 @@ quint32 DFUObject::CRC32WideFast(quint32 Crc, quint32 Size, quint32 *Buffer) */ quint32 DFUObject::CRCFromQBArray(QByteArray array, quint32 Size) { - int pad=Size-array.length(); + quint32 pad=Size-array.length(); array.append(QByteArray(pad,255)); quint32 t[Size/4]; for(int x=0;x