diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index 4b2b44ce8..fd039a906 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -23,7 +23,7 @@ Mixer Settings - + 5 @@ -1138,7 +1138,7 @@ Typical value is 50% for + or X configuration on quads. - Throtle Curve 1 + Curve 1 @@ -1208,7 +1208,7 @@ Typical value is 50% for + or X configuration on quads. - Throtle Curve 2 + Curve 2 @@ -1731,75 +1731,6 @@ Typical value is 50% for + or X configuration on quads. - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 32 - 32 - - - - - - - - :/core/images/helpicon.svg:/core/images/helpicon.svg - - - - 32 - 32 - - - - true - - - - - - - Send to board, but don't save permanently (flash or SD). - - - Apply - - - - - - - Applies and Saves all settings to flash or SD depending on board. - - - Save - - - - - @@ -1808,7 +1739,7 @@ Typical value is 50% for + or X configuration on quads. - + @@ -2082,14 +2013,14 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> <tr> <td style="border: none;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:14pt; font-weight:600; color:#ff0000;">SETTING UP FEED FORWARD IS DANGEROUS</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!</p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.</p></td></tr></table></body></html> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.</span></p></td></tr></table></body></html> @@ -2106,49 +2037,81 @@ p, li { white-space: pre-wrap; } - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Send to board, but don't save permanently (flash or SD). - - - Apply - - - - - - - Applies and Saves all settings to flash or SD depending on board. - - - Save - - - - - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + + + + :/core/images/helpicon.svg:/core/images/helpicon.svg + + + + 32 + 32 + + + + true + + + + + + + Send to board, but don't save permanently (flash or SD). + + + Apply + + + + + + + Applies and Saves all settings to flash or SD depending on board. + + + Save + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui b/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui new file mode 100644 index 000000000..03d49c965 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui @@ -0,0 +1,236 @@ + + + CC_HW_Widget + + + + 0 + 0 + 517 + 487 + + + + Form + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + :/configgadget/images/coptercontrol.svg + + + true + + + + + + + + + + + + + MainPort + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + + + + + + + FlexiPort + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Receiver type + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + 11 + 75 + true + + + + Telemetry speed: + + + + + + + Select the speed here. + + + + + + + + + + 75 + true + + + + + + + Qt::AutoText + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 75 + true + + + + Changes on this page require an Hw reboot to be applied + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Send to OpenPilot but don't write in SD. +Beware of not locking yourself out! + + + true + + + + + + Apply + + + false + + + + + + + Applies and Saves all settings to SD. +Beware of not locking yourself out! + + + false + + + + + + Save + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro index 4918feb53..79ddea046 100644 --- a/ground/openpilotgcs/src/plugins/config/config.pro +++ b/ground/openpilotgcs/src/plugins/config/config.pro @@ -24,7 +24,8 @@ HEADERS += configplugin.h \ configoutputwidget.h \ configtaskwidget.h \ configairframewidget.h \ - configtelemetrywidget.h \ + config_pro_hw_widget.h \ + config_cc_hw_widget.h \ configahrswidget.h \ configccattitudewidget.h \ mixercurvewidget.h \ @@ -34,7 +35,9 @@ HEADERS += configplugin.h \ configstabilizationwidget.h \ assertions.h \ calibration.h \ - defaultattitudewidget.h + defaultattitudewidget.h \ + smartsavebutton.h \ + defaulthwsettingswidget.h SOURCES += configplugin.cpp \ configgadgetconfiguration.cpp \ @@ -47,7 +50,8 @@ SOURCES += configplugin.cpp \ configinputwidget.cpp \ configoutputwidget.cpp \ configairframewidget.cpp \ - configtelemetrywidget.cpp \ + config_pro_hw_widget.cpp \ + config_cc_hw_widget.cpp \ configahrswidget.cpp \ configccattitudewidget.cpp \ mixercurvewidget.cpp \ @@ -59,17 +63,21 @@ SOURCES += configplugin.cpp \ legacy-calibration.cpp \ gyro-calibration.cpp \ alignment-calibration.cpp \ - defaultattitudewidget.cpp + defaultattitudewidget.cpp \ + smartsavebutton.cpp \ + defaulthwsettingswidget.cpp FORMS += \ airframe.ui \ - telemetry.ui \ + cc_hw_settings.ui \ + pro_hw_settings.ui \ ahrs.ui \ ccpm.ui \ stabilization.ui \ input.ui \ output.ui \ ccattitude.ui \ - defaultattitude.ui + defaultattitude.ui \ + defaulthwsettings.ui RESOURCES += configgadget.qrc diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp new file mode 100644 index 000000000..03296210b --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp @@ -0,0 +1,90 @@ +/** + ****************************************************************************** + * + * @file configtelemetrywidget.h + * @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief The Configuration Gadget used to update settings in the firmware + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "config_cc_hw_widget.h" + +#include +#include +#include +#include +#include +#include + + +ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent) +{ + m_telemetry = new Ui_CC_HW_Widget(); + m_telemetry->setupUi(this); + setupButtons(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); + addUAVObjectToWidgetRelation("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); + addUAVObjectToWidgetRelation("HwSettings","CC_FlexiPort",m_telemetry->cbFlexi); + addUAVObjectToWidgetRelation("HwSettings","CC_MainPort",m_telemetry->cbTele); + addUAVObjectToWidgetRelation("ManualControlSettings","InputMode",m_telemetry->receiverType); + enableControls(false); + populateWidgets(); + refreshWidgetsValues(); +} + +ConfigCCHWWidget::~ConfigCCHWWidget() +{ + // Do nothing +} + +void ConfigCCHWWidget::refreshValues() +{ +} + +void ConfigCCHWWidget::widgetsContentsChanged() +{ + ConfigTaskWidget::widgetsContentsChanged(); + enableControls(false); + if((m_telemetry->cbFlexi->currentText()==m_telemetry->cbTele->currentText()) && m_telemetry->cbTele->currentText()!="Disabled") + { + m_telemetry->problems->setText("Warning: you have configured the MainPort and the FlexiPort for the same function, this is currently not suported"); + } + else if((m_telemetry->cbTele->currentText()=="Spektrum" ||m_telemetry->cbFlexi->currentText()=="Spektrum") && m_telemetry->receiverType->currentText()!="Spektrum") + { + m_telemetry->problems->setText("Warning: you have at least one port configured as 'Spektrum' however that is not your selected input type"); + } + else if(m_telemetry->cbTele->currentText()=="S.Bus" && m_telemetry->receiverType->currentText()!="S.Bus") + { + m_telemetry->problems->setText("Warning: you have at least one port configured as 'S.Bus' however that is not your selected input type"); + } + else if(m_telemetry->cbTele->currentText()!="S.Bus" && m_telemetry->receiverType->currentText()=="S.Bus") + { + m_telemetry->problems->setText("Warning: you have selected 'S.Bus' as your input type however you have no port configured for that protocol"); + } + else if((m_telemetry->cbTele->currentText()!="Spektrum" && m_telemetry->cbFlexi->currentText()!="Spektrum") && m_telemetry->receiverType->currentText()=="Spektrum") + { + m_telemetry->problems->setText("Warning: you have at selected 'Spektrum' as your input type however you have no port configured for that protocol"); + } + else + { + m_telemetry->problems->setText(""); + enableControls(true); + } +} + diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h new file mode 100644 index 000000000..32c8a6988 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h @@ -0,0 +1,54 @@ +/** + ****************************************************************************** + * + * @file configtelemetrytwidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief Telemetry configuration panel + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef CONFIGCCHWWIDGET_H +#define CONFIGCCHWWIDGET_H + +#include "ui_cc_hw_settings.h" +#include "configtaskwidget.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include +#include +#include "smartsavebutton.h" + +class ConfigCCHWWidget: public ConfigTaskWidget +{ + Q_OBJECT + +public: + ConfigCCHWWidget(QWidget *parent = 0); + ~ConfigCCHWWidget(); +private slots: + void refreshValues(); + void widgetsContentsChanged(); + +private: + Ui_CC_HW_Widget *m_telemetry; +}; + +#endif // CONFIGCCHWWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp new file mode 100644 index 000000000..b3f562acd --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp @@ -0,0 +1,60 @@ +/** + ****************************************************************************** + * + * @file configtelemetrywidget.h + * @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief The Configuration Gadget used to update settings in the firmware + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "config_pro_hw_widget.h" + +#include +#include +#include +#include +#include +#include + + +ConfigProHWWidget::ConfigProHWWidget(QWidget *parent) : ConfigTaskWidget(parent) +{ + m_telemetry = new Ui_PRO_HW_Widget(); + m_telemetry->setupUi(this); + + setupButtons(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); + addUAVObjectToWidgetRelation("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); + enableControls(false); + populateWidgets(); + refreshWidgetsValues(); +} + +ConfigProHWWidget::~ConfigProHWWidget() +{ + // Do nothing +} + + +/** + Request telemetry settings from the board + */ +void ConfigProHWWidget::refreshValues() +{ +} diff --git a/ground/openpilotgcs/src/plugins/config/configtelemetrywidget.h b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.h similarity index 77% rename from ground/openpilotgcs/src/plugins/config/configtelemetrywidget.h rename to ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.h index f36ba1a4e..fbf35b9bd 100644 --- a/ground/openpilotgcs/src/plugins/config/configtelemetrywidget.h +++ b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.h @@ -24,10 +24,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef CONFIGTELEMETRYWIDGET_H -#define CONFIGTELEMETRYWIDGET_H +#ifndef CONFIGPROHWWIDGET_H +#define CONFIGPROHWWIDGET_H -#include "ui_telemetry.h" +#include "ui_pro_hw_settings.h" #include "configtaskwidget.h" #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" @@ -36,23 +36,20 @@ #include -class ConfigTelemetryWidget: public ConfigTaskWidget +class ConfigProHWWidget: public ConfigTaskWidget { Q_OBJECT public: - ConfigTelemetryWidget(QWidget *parent = 0); - ~ConfigTelemetryWidget(); + ConfigProHWWidget(QWidget *parent = 0); + ~ConfigProHWWidget(); private: - Ui_TelemetryWidget *m_telemetry; - void enableControls(bool enable); + Ui_PRO_HW_Widget *m_telemetry; private slots: virtual void refreshValues(); - void sendTelemetryUpdate(); - void saveTelemetryUpdate(); }; -#endif // ConfigTelemetryWidget_H +#endif // CONFIGPROHWWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp b/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp index 0044afa62..dcf743915 100644 --- a/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp @@ -91,6 +91,32 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p m_aircraft = new Ui_AircraftWidget(); m_aircraft->setupUi(this); + setupButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD); + addWidget(m_aircraft->customMixerTable); + addWidget(m_aircraft->customThrottle2Curve); + addWidget(m_aircraft->customThrottle1Curve); + addWidget(m_aircraft->multiThrottleCurve); + addWidget(m_aircraft->fixedWingThrottle); + addWidget(m_aircraft->fixedWingType); + addWidget(m_aircraft->feedForwardSlider); + addWidget(m_aircraft->accelTime); + addWidget(m_aircraft->decelTime); + addWidget(m_aircraft->maxAccelSlider); + addWidget(m_aircraft->multirotorFrameType); + addWidget(m_aircraft->multiMotor1); + addWidget(m_aircraft->multiMotor2); + addWidget(m_aircraft->multiMotor3); + addWidget(m_aircraft->multiMotor4); + addWidget(m_aircraft->multiMotor5); + addWidget(m_aircraft->multiMotor6); + addWidget(m_aircraft->multiMotor7); + addWidget(m_aircraft->multiMotor8); + addWidget(m_aircraft->triYawChannel); + addUAVObject("SystemSettings"); + addUAVObject("MixerSettings"); + addUAVObject("ActuatorSettings"); + + ffTuningInProgress = false; ffTuningPhase = false; @@ -164,11 +190,6 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); } - connect(m_aircraft->saveAircraftToSD, SIGNAL(clicked()), this, SLOT(saveAircraftUpdate())); - connect(m_aircraft->saveAircraftToRAM, SIGNAL(clicked()), this, SLOT(sendAircraftUpdate())); - - connect(m_aircraft->ffSave, SIGNAL(clicked()), this, SLOT(saveAircraftUpdate())); - connect(m_aircraft->ffApply, SIGNAL(clicked()), this, SLOT(sendAircraftUpdate())); connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int))); @@ -191,17 +212,8 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p connect(m_aircraft->ffTestBox3, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); enableControls(false); - refreshValues(); - connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); - connect(parent, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect())); + refreshWidgetsValues(); - // Register for ManualControlSettings changes: - obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); - connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues())); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues())); - obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues())); // Connect the help button connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); @@ -213,18 +225,6 @@ ConfigAirframeWidget::~ConfigAirframeWidget() // Do nothing } -/** - Enable or disable controls depending on whether we're ronnected or not - */ -void ConfigAirframeWidget::enableControls(bool enable) -{ - //m_aircraft->saveAircraftToRAM->setEnabled(enable); - m_aircraft->saveAircraftToSD->setEnabled(enable); - //m_aircraft->ffApply->setEnabled(enable); - m_aircraft->ffSave->setEnabled(enable); -} - - /** Slot for switching the airframe type. We do it explicitely rather than a signal in the UI, because we want to force a fitInView of the quad shapes. @@ -460,7 +460,7 @@ void ConfigAirframeWidget::updateCustomThrottle2CurveValue(QList list, d /** Refreshes the current value of the SystemSettings which holds the aircraft type */ -void ConfigAirframeWidget::refreshValues() +void ConfigAirframeWidget::refreshWidgetsValues() { // Get the Airframe type from the system settings: UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); @@ -665,10 +665,13 @@ void ConfigAirframeWidget::refreshValues() val = floor(-field->getDouble(i)/1.27); m_aircraft->mrYawMixLevel->setValue(val); eng = m_aircraft->multiMotor2->currentIndex()-1; - field = obj->getField(mixerVectors.at(eng)); - i = field->getElementNames().indexOf("Roll"); - val = floor(1-field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); + if(eng>-1) + { + field = obj->getField(mixerVectors.at(eng)); + i = field->getElementNames().indexOf("Roll"); + val = floor(1-field->getDouble(i)/1.27); + m_aircraft->mrRollMixLevel->setValue(val); + } } } else if (frameType == "HexaX") { // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW @@ -1817,8 +1820,9 @@ void ConfigAirframeWidget::updateCustomAirframeUI() we call additional methods for specific frames, so that we do not have a code that is too heavy. */ -void ConfigAirframeWidget::sendAircraftUpdate() +void ConfigAirframeWidget::updateObjectsFromWidgets() { + qDebug()<<"updateObjectsFromWidgets"; QString airframeType = "Custom"; if (m_aircraft->aircraftType->currentText() == "Fixed Wing") { // Save the curve (common to all Fixed wing frames) @@ -2123,31 +2127,9 @@ void ConfigAirframeWidget::sendAircraftUpdate() } } - - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - obj->updated(); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - obj->updated(); - obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); UAVObjectField* field = obj->getField(QString("AirframeType")); field->setValue(airframeType); - obj->updated(); -} - -/** - Send airframe type to the board and request saving to SD card - */ -void ConfigAirframeWidget::saveAircraftUpdate() -{ - // Send update so that the latest value is saved - sendAircraftUpdate(); - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); - Q_ASSERT(obj); - saveObjectToSD(obj); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - saveObjectToSD(obj); - obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - saveObjectToSD(obj); } diff --git a/ground/openpilotgcs/src/plugins/config/configairframewidget.h b/ground/openpilotgcs/src/plugins/config/configairframewidget.h index 5d9bfecc8..234a114c1 100644 --- a/ground/openpilotgcs/src/plugins/config/configairframewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configairframewidget.h @@ -58,7 +58,6 @@ private: void updateCustomAirframeUI(); bool setupMixer(double mixerFactors[8][3]); void setupMotors(QList motorList); - virtual void enableControls(bool enable); void resetField(UAVObjectField * field); void resetMixer (MixerCurveWidget *mixer, int numElements, double maxvalue); @@ -74,9 +73,9 @@ private: UAVObject::Metadata accInitialData; private slots: - virtual void refreshValues(); - void sendAircraftUpdate(); - void saveAircraftUpdate(); + virtual void refreshWidgetsValues(); + void updateObjectsFromWidgets(); + // void saveAircraftUpdate(); void setupAirframeUI(QString type); void toggleAileron2(int index); void toggleElevator2(int index); diff --git a/ground/openpilotgcs/src/plugins/config/configgadget.qrc b/ground/openpilotgcs/src/plugins/config/configgadget.qrc index 30f9431e3..f53d5811f 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadget.qrc +++ b/ground/openpilotgcs/src/plugins/config/configgadget.qrc @@ -1,18 +1,20 @@ - - images/help2.png - images/XBee.svg - images/Airframe.png - images/Servo.png - images/ahrs-calib.svg - images/AHRS-v1.3.png - images/paper-plane.svg - images/curve-bg.svg - images/quad-shapes.svg - images/ccpm_setup.svg - images/PipXtreme.png - images/gyroscope.svg - images/Transmitter.png - images/help.png - + + images/help2.png + images/XBee.svg + images/Airframe.png + images/Servo.png + images/ahrs-calib.svg + images/AHRS-v1.3.png + images/paper-plane.svg + images/curve-bg.svg + images/quad-shapes.svg + images/ccpm_setup.svg + images/PipXtreme.png + images/gyroscope.svg + images/Transmitter.png + images/help.png + images/coptercontrol.svg + images/hw_config.svg + diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp index f19b414c4..f1f93c9d7 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp @@ -33,9 +33,10 @@ #include "configinputwidget.h" #include "configoutputwidget.h" #include "configstabilizationwidget.h" -#include "configtelemetrywidget.h" +#include "config_pro_hw_widget.h" +#include "config_cc_hw_widget.h" #include "defaultattitudewidget.h" - +#include "defaulthwsettingswidget.h" #include "uavobjectutilmanager.h" #include @@ -62,23 +63,24 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent) // ********************* QWidget *qwd; + qwd = new DefaultHwSettingsWidget(this); + ftw->insertTab(ConfigGadgetWidget::hardware, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); + qwd = new ConfigAirframeWidget(this); - ftw->insertTab(0, qwd, QIcon(":/configgadget/images/Airframe.png"), QString("Aircraft")); + ftw->insertTab(ConfigGadgetWidget::aircraft, qwd, QIcon(":/configgadget/images/Airframe.png"), QString("Aircraft")); qwd = new ConfigInputWidget(this); - ftw->insertTab(1, qwd, QIcon(":/configgadget/images/Transmitter.png"), QString("Input")); + ftw->insertTab(ConfigGadgetWidget::input, qwd, QIcon(":/configgadget/images/Transmitter.png"), QString("Input")); qwd = new ConfigOutputWidget(this); - ftw->insertTab(2, qwd, QIcon(":/configgadget/images/Servo.png"), QString("Output")); + ftw->insertTab(ConfigGadgetWidget::output, qwd, QIcon(":/configgadget/images/Servo.png"), QString("Output")); qwd = new DefaultAttitudeWidget(this); - ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); + ftw->insertTab(ConfigGadgetWidget::ins, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); qwd = new ConfigStabilizationWidget(this); - ftw->insertTab(4, qwd, QIcon(":/configgadget/images/gyroscope.svg"), QString("Stabilization")); + ftw->insertTab(ConfigGadgetWidget::stabilization, qwd, QIcon(":/configgadget/images/gyroscope.svg"), QString("Stabilization")); - qwd = new ConfigTelemetryWidget(this); - ftw->insertTab(5, qwd, QIcon(":/configgadget/images/XBee.svg"), QString("Telemetry")); // qwd = new ConfigPipXtremeWidget(this); @@ -128,16 +130,24 @@ void ConfigGadgetWidget::onAutopilotConnect() { if ((board & 0xff00) == 1024) { // CopterControl family // Delete the INS panel, replace with CC Panel: - ftw->setCurrentIndex(0); - ftw->removeTab(3); + ftw->setCurrentIndex(ConfigGadgetWidget::hardware); + ftw->removeTab(ConfigGadgetWidget::ins); QWidget *qwd = new ConfigCCAttitudeWidget(this); - ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("Attitude")); + ftw->insertTab(ConfigGadgetWidget::ins, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("Attitude")); + ftw->removeTab(ConfigGadgetWidget::hardware); + qwd = new ConfigCCHWWidget(this); + ftw->insertTab(ConfigGadgetWidget::hardware, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); + ftw->setCurrentIndex(ConfigGadgetWidget::hardware); } else if ((board & 0xff00) == 256 ) { // Mainboard family - ftw->setCurrentIndex(0); - ftw->removeTab(3); + ftw->setCurrentIndex(ConfigGadgetWidget::hardware); + ftw->removeTab(ConfigGadgetWidget::ins); QWidget *qwd = new ConfigAHRSWidget(this); - ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); + ftw->insertTab(ConfigGadgetWidget::ins, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); + ftw->removeTab(ConfigGadgetWidget::hardware); + qwd = new ConfigProHWWidget(this); + ftw->insertTab(ConfigGadgetWidget::hardware, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); + ftw->setCurrentIndex(ConfigGadgetWidget::hardware); } } emit autopilotConnected(); diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h index 43db58429..84d65b383 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h @@ -49,6 +49,7 @@ class ConfigGadgetWidget: public QWidget public: ConfigGadgetWidget(QWidget *parent = 0); ~ConfigGadgetWidget(); + enum widgetTabs {hardware=0, aircraft, input, output, ins, stabilization}; public slots: void onAutopilotConnect(); diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 5fb4b5b73..2ca678eae 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -110,10 +110,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent) // Get the receiver types supported by OpenPilot and fill the corresponding // dropdown menu: obj = dynamic_cast(objManager->getObject(QString("ManualControlSettings"))); - QString fieldName = QString("InputMode"); - UAVObjectField *field = obj->getField(fieldName); - m_config->receiverType->addItems(field->getOptions()); - + UAVObjectField * field; // Fill in the dropdown menus for the channel RC Input assignement. QStringList channelsList; channelsList << "None"; @@ -263,7 +260,7 @@ void ConfigInputWidget::refreshValues() // Update receiver type field = obj->getField(QString("InputMode")); - m_config->receiverType->setCurrentIndex(m_config->receiverType->findText(field->getValue().toString())); + m_config->receiverType->setText(field->getValue().toString()); // Reset all channel assignement dropdowns: foreach (QComboBox *combo, inChannelAssign) { @@ -331,11 +328,6 @@ void ConfigInputWidget::sendRCInputUpdate() for (int i = 0; i < 8; i++) field->setValue(inSliders[i]->value(), i); - // Set RC Receiver type: - fieldName = QString("InputMode"); - field = obj->getField(fieldName); - field->setValue(m_config->receiverType->currentText()); - // Set Roll/Pitch/Yaw/Etc assignement: // Rule: if two channels have the same setting (which is wrong!) the higher channel // will get the setting. diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp index bb598cba0..8fd35c596 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp @@ -28,13 +28,72 @@ #include -ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent) +ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),smartsave(NULL),dirty(false) { + pm = ExtensionSystem::PluginManager::instance(); + objManager = pm->getObject(); + connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); + connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect())); } +void ConfigTaskWidget::addWidget(QWidget * widget) +{ + addUAVObjectToWidgetRelation("","",widget); +} +void ConfigTaskWidget::addUAVObject(QString objectName) +{ + addUAVObjectToWidgetRelation(objectName,"",NULL); +} +void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString field, QWidget * widget) +{ + UAVObject *obj=NULL; + UAVObjectField *_field=NULL; + if(!object.isEmpty()) + obj = objManager->getObject(QString(object)); + connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); + //smartsave->addObject(obj); + if(!field.isEmpty() && obj) + _field = obj->getField(QString(field)); + objectToWidget * ow=new objectToWidget(); + ow->field=_field; + ow->object=obj; + ow->widget=widget; + objOfInterest.append(ow); + if(obj) + smartsave->addObject(obj); + if(widget==NULL) + { + // do nothing + } + else if(QComboBox * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(currentIndexChanged(int)),this,SLOT(widgetsContentsChanged())); + } + else if(QSlider * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(sliderMoved(int)),this,SLOT(widgetsContentsChanged())); + } + else if(MixerCurveWidget * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(curveUpdated(QList,double)),this,SLOT(widgetsContentsChanged())); + } + else if(QTableWidget * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(cellChanged(int,int)),this,SLOT(widgetsContentsChanged())); + } + else if(QSpinBox * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(valueChanged(int)),this,SLOT(widgetsContentsChanged())); + } + else if(QDoubleSpinBox * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(valueChanged(double)),this,SLOT(widgetsContentsChanged())); + } +} + ConfigTaskWidget::~ConfigTaskWidget() { - // Do nothing + delete smartsave; } void ConfigTaskWidget::saveObjectToSD(UAVObject *obj) @@ -73,9 +132,125 @@ void ConfigTaskWidget::onAutopilotDisconnect() void ConfigTaskWidget::onAutopilotConnect() { enableControls(true); - refreshValues(); + refreshWidgetsValues(); } +void ConfigTaskWidget::populateWidgets() +{ + foreach(objectToWidget * ow,objOfInterest) + { + if(ow->object==NULL || ow->field==NULL) + { + // do nothing + } + else if(QComboBox * cb=qobject_cast(ow->widget)) + { + cb->addItems(ow->field->getOptions()); + cb->setCurrentIndex(cb->findText(ow->field->getValue().toString())); + } + else if(QLabel * cb=qobject_cast(ow->widget)) + { + cb->setText(ow->field->getValue().toString()); + } + } + dirty=false; +} + +void ConfigTaskWidget::refreshWidgetsValues() +{ + foreach(objectToWidget * ow,objOfInterest) + { + if(ow->object==NULL || ow->field==NULL) + { + //do nothing + } + else if(QComboBox * cb=qobject_cast(ow->widget)) + { + cb->setCurrentIndex(cb->findText(ow->field->getValue().toString())); + } + else if(QLabel * cb=qobject_cast(ow->widget)) + { + cb->setText(ow->field->getValue().toString()); + } + } +} + +void ConfigTaskWidget::updateObjectsFromWidgets() +{ + foreach(objectToWidget * ow,objOfInterest) + { + if(ow->object==NULL || ow->field==NULL) + { + //do nothing + } + else if(QComboBox * cb=qobject_cast(ow->widget)) + { + ow->field->setValue(cb->currentText()); + } + else if(QLabel * cb=qobject_cast(ow->widget)) + { + ow->field->setValue(cb->text()); + } + } +} + +void ConfigTaskWidget::setupButtons(QPushButton *update, QPushButton *save) +{ + smartsave=new smartSaveButton(update,save); + connect(smartsave, SIGNAL(preProcessOperations()), this, SLOT(updateObjectsFromWidgets())); + connect(smartsave,SIGNAL(saveSuccessfull()),this,SLOT(clearDirty())); + connect(smartsave,SIGNAL(beginOp()),this,SLOT(disableObjUpdates())); + connect(smartsave,SIGNAL(endOp()),this,SLOT(enableObjUpdates())); +} + +void ConfigTaskWidget::enableControls(bool enable) +{ + if(smartsave) + smartsave->enableControls(enable); +} + +void ConfigTaskWidget::widgetsContentsChanged() +{ + dirty=true; +} + +void ConfigTaskWidget::clearDirty() +{ + dirty=false; +} + +bool ConfigTaskWidget::isDirty() +{ + return dirty; +} + +void ConfigTaskWidget::refreshValues() +{ +} + +void ConfigTaskWidget::disableObjUpdates() +{ + foreach(objectToWidget * obj,objOfInterest) + { + if(obj->object) + disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); + } +} + +void ConfigTaskWidget::enableObjUpdates() +{ + foreach(objectToWidget * obj,objOfInterest) + { + if(obj->object) + connect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); + } +} + + + + + + /** diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.h b/ground/openpilotgcs/src/plugins/config/configtaskwidget.h index 6ffe15b70..bd293ce5f 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.h @@ -35,28 +35,56 @@ #include #include #include - - +#include +#include "smartsavebutton.h" +#include "mixercurvewidget.h" +#include +#include +#include class ConfigTaskWidget: public QWidget { Q_OBJECT public: + struct objectToWidget + { + UAVObject * object; + UAVObjectField * field; + QWidget * widget; + }; + ConfigTaskWidget(QWidget *parent = 0); ~ConfigTaskWidget(); void saveObjectToSD(UAVObject *obj); UAVObjectManager* getObjectManager(); static double listMean(QList list); - + void addUAVObject(QString objectName); + void addWidget(QWidget * widget); + void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget); + void setupButtons(QPushButton * update,QPushButton * save); + bool isDirty(); public slots: void onAutopilotDisconnect(); void onAutopilotConnect(); private slots: - virtual void refreshValues() = 0; - + virtual void refreshValues(); + virtual void updateObjectsFromWidgets(); private: - virtual void enableControls(bool enable) = 0; + QList objOfInterest; + ExtensionSystem::PluginManager *pm; + UAVObjectManager *objManager; + smartSaveButton *smartsave; + bool dirty; +protected slots: + virtual void disableObjUpdates(); + virtual void enableObjUpdates(); + virtual void clearDirty(); + virtual void widgetsContentsChanged(); + virtual void populateWidgets(); + virtual void refreshWidgetsValues(); +protected: + virtual void enableControls(bool enable); }; diff --git a/ground/openpilotgcs/src/plugins/config/configtelemetrywidget.cpp b/ground/openpilotgcs/src/plugins/config/configtelemetrywidget.cpp deleted file mode 100644 index 2b1a8e873..000000000 --- a/ground/openpilotgcs/src/plugins/config/configtelemetrywidget.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/** - ****************************************************************************** - * - * @file configtelemetrywidget.h - * @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup ConfigPlugin Config Plugin - * @{ - * @brief The Configuration Gadget used to update settings in the firmware - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "configtelemetrywidget.h" - -#include -#include -#include -#include -#include -#include - - -ConfigTelemetryWidget::ConfigTelemetryWidget(QWidget *parent) : ConfigTaskWidget(parent) -{ - m_telemetry = new Ui_TelemetryWidget(); - m_telemetry->setupUi(this); - - // Now connect the widget to the ManualControlCommand / Channel UAVObject - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); - - UAVObject *obj = objManager->getObject(QString("TelemetrySettings")); - UAVObjectField *field = obj->getField(QString("Speed")); - m_telemetry->telemetrySpeed->addItems(field->getOptions()); - - connect(m_telemetry->saveTelemetryToSD, SIGNAL(clicked()), this, SLOT(saveTelemetryUpdate())); - connect(m_telemetry->saveTelemetryToRAM, SIGNAL(clicked()), this, SLOT(sendTelemetryUpdate())); - connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshValues())); - - enableControls(false); - refreshValues(); - connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); - connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect())); -} - -ConfigTelemetryWidget::~ConfigTelemetryWidget() -{ - // Do nothing -} - - -/******************************* - * Telemetry Settings - *****************************/ - -void ConfigTelemetryWidget::enableControls(bool enable) -{ - m_telemetry->saveTelemetryToSD->setEnabled(enable); - //m_telemetry->saveTelemetryToRAM->setEnabled(enable); -} - -/** - Request telemetry settings from the board - */ -void ConfigTelemetryWidget::refreshValues() -{ - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); - UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("TelemetrySettings"))); - Q_ASSERT(obj); - UAVObjectField *field = obj->getField(QString("Speed")); - m_telemetry->telemetrySpeed->setCurrentIndex(m_telemetry->telemetrySpeed->findText(field->getValue().toString())); -} - -/** - Send telemetry settings to the board - */ -void ConfigTelemetryWidget::sendTelemetryUpdate() -{ - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("TelemetrySettings"))); - Q_ASSERT(obj); - UAVObjectField* field = obj->getField(QString("Speed")); - field->setValue(m_telemetry->telemetrySpeed->currentText()); - obj->updated(); -} - -/** - Send telemetry settings to the board and request saving to SD card - */ -void ConfigTelemetryWidget::saveTelemetryUpdate() -{ - // Send update so that the latest value is saved - sendTelemetryUpdate(); - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("TelemetrySettings"))); - Q_ASSERT(obj); - saveObjectToSD(obj); -} diff --git a/ground/openpilotgcs/src/plugins/config/defaulthwsettings.ui b/ground/openpilotgcs/src/plugins/config/defaulthwsettings.ui new file mode 100644 index 000000000..d1ef7d913 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/defaulthwsettings.ui @@ -0,0 +1,77 @@ + + + defaulthwsettings + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt; font-weight:600;">Hardware Configuration</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt; font-weight:600;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">This panel will be updated to provide the relevant controls to let you configure your hardware once telemetry is connected and running.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"></p></body></html> + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp b/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp new file mode 100644 index 000000000..69eef9117 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp @@ -0,0 +1,44 @@ +/** + ****************************************************************************** + * + * @file DefaultHwSettingsWidget.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief Placeholder for attitude panel until board is connected. + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "defaulthwsettingswidget.h" +#include "ui_defaultattitude.h" +#include +#include +#include + +DefaultHwSettingsWidget::DefaultHwSettingsWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui_defaulthwsettings) +{ + ui->setupUi(this); +} + +DefaultHwSettingsWidget::~DefaultHwSettingsWidget() +{ + delete ui; +} + diff --git a/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.h b/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.h new file mode 100644 index 000000000..e94435f8d --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.h @@ -0,0 +1,55 @@ +/** + ****************************************************************************** + * + * @file defaultccattitudewidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief Placeholder for attitude settings widget until board connected. + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef DEFAULTHWSETTINGSt_H +#define DEFAULTHWSETTINGSt_H + +#include "ui_defaulthwsettings.h" +#include "configtaskwidget.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include +#include +#include + +class Ui_Widget; + +class DefaultHwSettingsWidget : public QWidget +{ + Q_OBJECT + +public: + explicit DefaultHwSettingsWidget(QWidget *parent = 0); + ~DefaultHwSettingsWidget(); + +private slots: + +private: + Ui_defaulthwsettings *ui; +}; + +#endif // DEFAULTHWSETTINGSt_H diff --git a/ground/openpilotgcs/src/plugins/config/images/coptercontrol.svg b/ground/openpilotgcs/src/plugins/config/images/coptercontrol.svg new file mode 100644 index 000000000..669199ef6 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/images/coptercontrol.svg @@ -0,0 +1,2647 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/config/images/hw_config.svg b/ground/openpilotgcs/src/plugins/config/images/hw_config.svg new file mode 100644 index 000000000..a40c3c3f3 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/images/hw_config.svg @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/input.ui b/ground/openpilotgcs/src/plugins/config/input.ui index 320aa2db8..8d22b281b 100644 --- a/ground/openpilotgcs/src/plugins/config/input.ui +++ b/ground/openpilotgcs/src/plugins/config/input.ui @@ -6,8 +6,8 @@ 0 0 - 655 - 554 + 626 + 532 @@ -24,34 +24,12 @@ RC Input - - - - - 50 - 0 - - - - - 16777215 - 16777215 - - - - You must restart your board after changing receiver type. Also your hardware setings must support it. - - - true - - - - + - 50 - false + 75 + true @@ -62,17 +40,7 @@ - - - - Select the receiver type here: -- PWM is the most usual type -- PPM is connected to input XXX -- Spektrum is used with Spektrum 'satellite' receivers - - - - + @@ -102,14 +70,14 @@ - + Rev. - + @@ -122,7 +90,7 @@ - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -136,7 +104,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -154,7 +122,7 @@ p, li { white-space: pre-wrap; } - + true @@ -173,7 +141,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -188,7 +156,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -200,10 +168,10 @@ reversal capabilities). - + - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -217,7 +185,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -235,7 +203,7 @@ p, li { white-space: pre-wrap; } - + true @@ -254,7 +222,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -269,7 +237,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -281,10 +249,10 @@ reversal capabilities). - + - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -298,7 +266,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -316,7 +284,7 @@ p, li { white-space: pre-wrap; } - + true @@ -335,7 +303,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -350,7 +318,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -362,10 +330,10 @@ reversal capabilities). - + - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -379,7 +347,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -397,7 +365,7 @@ p, li { white-space: pre-wrap; } - + true @@ -416,7 +384,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -431,7 +399,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -443,10 +411,10 @@ reversal capabilities). - + - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -460,7 +428,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -478,7 +446,7 @@ p, li { white-space: pre-wrap; } - + true @@ -497,7 +465,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -512,7 +480,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -524,10 +492,10 @@ reversal capabilities). - + - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -541,7 +509,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -559,7 +527,7 @@ p, li { white-space: pre-wrap; } - + true @@ -578,7 +546,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -593,7 +561,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -605,10 +573,10 @@ reversal capabilities). - + - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -622,7 +590,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -640,7 +608,7 @@ p, li { white-space: pre-wrap; } - + true @@ -659,7 +627,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -674,7 +642,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -686,10 +654,10 @@ reversal capabilities). - + - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -703,7 +671,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -721,7 +689,7 @@ p, li { white-space: pre-wrap; } - + true @@ -740,7 +708,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -755,7 +723,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -767,7 +735,34 @@ reversal capabilities). - + + + + + 75 + true + + + + BEWARE: make sure your engines are not connected when running calibration! + + + + + + + + + 75 + true + + + + + + + + @@ -787,33 +782,13 @@ Neutral should be put at the bottom of the slider for the throttle. - - - - - 75 - true - - + + - - - - - 75 - true - - - - BEWARE: make sure your engines are not connected when running calibration! - - - - @@ -1192,19 +1167,6 @@ if you have not done so already. - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -1287,7 +1249,6 @@ Applies and Saves all settings to SD ch5Assign ch6Assign ch7Assign - receiverType fmsSlider fmsModePos3 fmsSsPos3Roll diff --git a/ground/openpilotgcs/src/plugins/config/telemetry.ui b/ground/openpilotgcs/src/plugins/config/pro_hw_settings.ui similarity index 98% rename from ground/openpilotgcs/src/plugins/config/telemetry.ui rename to ground/openpilotgcs/src/plugins/config/pro_hw_settings.ui index 0db9c9299..6e6751b87 100644 --- a/ground/openpilotgcs/src/plugins/config/telemetry.ui +++ b/ground/openpilotgcs/src/plugins/config/pro_hw_settings.ui @@ -1,7 +1,7 @@ - TelemetryWidget - + PRO_HW_Widget + 0 diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp new file mode 100644 index 000000000..720e06c15 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp @@ -0,0 +1,123 @@ +#include "smartsavebutton.h" + +smartSaveButton::smartSaveButton(QPushButton * update, QPushButton * save):bupdate(update),bsave(save) +{ + connect(bsave,SIGNAL(clicked()),this,SLOT(processClick())); + connect(bupdate,SIGNAL(clicked()),this,SLOT(processClick())); + +} +void smartSaveButton::processClick() +{ + emit beginOp(); + bool save=false; + QPushButton *button=bupdate; + if(sender()==bsave) + { + save=true; + button=bsave; + } + emit preProcessOperations(); + button->setEnabled(false); + button->setIcon(QIcon(":/uploader/images/system-run.svg")); + QTimer timer; + timer.setSingleShot(true); + bool error=false; + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectUtilManager* utilMngr = pm->getObject(); + qDebug()<<"smartbutton:save"; + foreach(UAVObject * obj,objects) + { + up_result=false; + current_object=obj; + for(int i=0;i<3;++i) + { + + connect(obj,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(transaction_finished(UAVObject*, bool))); + connect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); + obj->updated(); + timer.start(1000); + loop.exec(); + timer.stop(); + disconnect(obj,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(transaction_finished(UAVObject*, bool))); + disconnect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); + if(up_result) + break; + } + if(up_result==false) + { + error=true; + continue; + } + sv_result=false; + current_objectID=obj->getObjID(); + if(save) + { + 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; + } + } + } + button->setEnabled(true); + if(!error) + { + button->setIcon(QIcon(":/uploader/images/dialog-apply.svg")); + emit saveSuccessfull(); + } + else + { + button->setIcon(QIcon(":/uploader/images/process-stop.svg")); + } + emit endOp(); +} + +void smartSaveButton::setObjects(QList list) +{ + objects=list; +} + +void smartSaveButton::addObject(UAVObject * obj) +{ + objects.append(obj); +} + +void smartSaveButton::clearObjects() +{ + objects.clear(); +} +void smartSaveButton::transaction_finished(UAVObject* obj, bool result) +{ + if(current_object==obj) + { + up_result=result; + loop.quit(); + } +} + +void smartSaveButton::saving_finished(int id, bool result) +{ + if(id==current_objectID) + { + sv_result=result; + loop.quit(); + } +} + +void smartSaveButton::enableControls(bool value) +{ + bupdate->setEnabled(value); + bsave->setEnabled(value); +} diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.h b/ground/openpilotgcs/src/plugins/config/smartsavebutton.h new file mode 100644 index 000000000..d0238d034 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.h @@ -0,0 +1,49 @@ +#ifndef SMARTSAVEBUTTON_H +#define SMARTSAVEBUTTON_H + +#include "uavtalk/telemetrymanager.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include +#include +#include +#include "uavobjectutilmanager.h" +#include +#include +class smartSaveButton:public QObject +{ +public: + Q_OBJECT +public: + smartSaveButton(QPushButton * update,QPushButton * save); + void setObjects(QList); + void addObject(UAVObject *); + void clearObjects(); +signals: + void preProcessOperations(); + void saveSuccessfull(); + void beginOp(); + void endOp(); +private slots: + void processClick(); + void transaction_finished(UAVObject* obj, bool result); + void saving_finished(int,bool); + +private: + QPushButton *bupdate; + QPushButton *bsave; + quint32 current_objectID; + UAVObject * current_object; + bool up_result; + bool sv_result; + QEventLoop loop; + QList objects; +protected: +public slots: + void enableControls(bool value); + +}; + + +#endif // SMARTSAVEBUTTON_H