diff --git a/ground/src/plugins/config/configgadgetwidget.cpp b/ground/src/plugins/config/configgadgetwidget.cpp index 9a0d3f1da..de6970c72 100644 --- a/ground/src/plugins/config/configgadgetwidget.cpp +++ b/ground/src/plugins/config/configgadgetwidget.cpp @@ -40,6 +40,18 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent) m_config->setupUi(this); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + // Fill in the dropdown menus for the channel RC Input assignement. + QStringList channelsList; + channelsList << "None" << "Roll" << "Pitch" << "Yaw" << "Throttle" << "FlightMode"; + m_config->ch0Assign->addItems(channelsList); + m_config->ch1Assign->addItems(channelsList); + m_config->ch2Assign->addItems(channelsList); + m_config->ch3Assign->addItems(channelsList); + m_config->ch4Assign->addItems(channelsList); + m_config->ch5Assign->addItems(channelsList); + m_config->ch6Assign->addItems(channelsList); + m_config->ch7Assign->addItems(channelsList); + // Now connect the widget to the ManualControlCommand / Channel UAVObject ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject(); @@ -47,11 +59,20 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent) UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("ManualControlCommand"))); connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateChannels(UAVObject*))); + // Get the receiver types supported by OpenPilot and fill the corresponding + // dropdown menu: + obj = dynamic_cast(objManager->getObject(QString("ManualControlSettings"))); + // Now update all the slider values: + QString fieldName = QString("InputMode"); + UAVObjectField *field = obj->getField(fieldName); + m_config->receiverType->addItems(field->getOptions()); + + requestRCInputUpdate(); + connect(m_config->saveRCInputToSD, SIGNAL(clicked()), this, SLOT(saveRCInputObject())); connect(m_config->saveRCInputToRAM, SIGNAL(clicked()), this, SLOT(sendRCInputUpdate())); connect(m_config->getRCInputCurrent, SIGNAL(clicked()), this, SLOT(requestRCInputUpdate())); - firstUpdate = true; } @@ -129,13 +150,34 @@ void ConfigGadgetWidget::requestRCInputUpdate() m_config->ch6Slider->setValue(field->getValue(6).toInt()); m_config->ch7Slider->setValue(field->getValue(7).toInt()); + // Update receiver type + fieldName = QString("InputMode"); + field = obj->getField(fieldName); + m_config->receiverType->setCurrentIndex(m_config->receiverType->findText(field->getValue().toString())); + + // Reset all channel assignement dropdowns: + m_config->ch0Assign->setCurrentIndex(0); + m_config->ch1Assign->setCurrentIndex(0); + m_config->ch2Assign->setCurrentIndex(0); + m_config->ch3Assign->setCurrentIndex(0); + m_config->ch4Assign->setCurrentIndex(0); + m_config->ch5Assign->setCurrentIndex(0); + m_config->ch6Assign->setCurrentIndex(0); + m_config->ch7Assign->setCurrentIndex(0); + + // Update all channels assignements + assignChannel(obj, field, QString("Roll")); + assignChannel(obj, field, QString("Pitch")); + assignChannel(obj, field, QString("Yaw")); + assignChannel(obj, field, QString("Throttle")); + assignChannel(obj, field, QString("FlightMode")); + } /** * Sends the config to the board, without saving to the SD card */ - void ConfigGadgetWidget::sendRCInputUpdate() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); @@ -176,6 +218,47 @@ void ConfigGadgetWidget::sendRCInputUpdate() field->setValue(m_config->ch6Slider->value(),6); field->setValue(m_config->ch7Slider->value(),7); + // 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. + if (m_config->ch0Assign->currentIndex() != 0) { + field = obj->getField(m_config->ch0Assign->currentText()); + field->setValue(field->getOptions().at(0)); // -> This way we don't depend on channel naming convention + } + if (m_config->ch1Assign->currentIndex() != 0) { + field = obj->getField(m_config->ch1Assign->currentText()); + field->setValue(field->getOptions().at(1)); + } + if (m_config->ch2Assign->currentIndex() != 0) { + field = obj->getField(m_config->ch2Assign->currentText()); + field->setValue(field->getOptions().at(2)); + } + if (m_config->ch3Assign->currentIndex() != 0) { + field = obj->getField(m_config->ch3Assign->currentText()); + field->setValue(field->getOptions().at(3)); + } + if (m_config->ch4Assign->currentIndex() != 0) { + field = obj->getField(m_config->ch4Assign->currentText()); + field->setValue(field->getOptions().at(4)); + } + if (m_config->ch5Assign->currentIndex() != 0) { + field = obj->getField(m_config->ch5Assign->currentText()); + field->setValue(field->getOptions().at(5)); + } + if (m_config->ch6Assign->currentIndex() != 0) { + field = obj->getField(m_config->ch6Assign->currentText()); + field->setValue(field->getOptions().at(6)); + } + if (m_config->ch7Assign->currentIndex() != 0) { + field = obj->getField(m_config->ch7Assign->currentText()); + field->setValue(field->getOptions().at(7)); + } + // ... and send to the OP Board obj->updated(); @@ -185,7 +268,6 @@ void ConfigGadgetWidget::sendRCInputUpdate() /** Sends the config to the board and request saving into the SD card */ - void ConfigGadgetWidget::saveRCInputObject() { // Send update so that the latest value is saved @@ -195,7 +277,6 @@ void ConfigGadgetWidget::saveRCInputObject() UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("ManualControlSettings"))); Q_ASSERT(obj); updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj); - } @@ -217,6 +298,42 @@ void ConfigGadgetWidget::updateObjectPersistance(ObjectPersistence::OperationOpt } +/** + * Set the dropdown option for a channel assignement + */ +void ConfigGadgetWidget::assignChannel(UAVDataObject *obj, UAVObjectField *field, QString str) +{ + field = obj->getField(str); + QStringList options = field->getOptions(); + switch (options.indexOf(field->getValue().toString())) { + case 0: + m_config->ch0Assign->setCurrentIndex(m_config->ch0Assign->findText(str)); + break; + case 1: + m_config->ch1Assign->setCurrentIndex(m_config->ch0Assign->findText(str)); + break; + case 2: + m_config->ch2Assign->setCurrentIndex(m_config->ch0Assign->findText(str)); + break; + case 3: + m_config->ch3Assign->setCurrentIndex(m_config->ch0Assign->findText(str)); + break; + case 4: + m_config->ch4Assign->setCurrentIndex(m_config->ch0Assign->findText(str)); + break; + case 5: + m_config->ch5Assign->setCurrentIndex(m_config->ch0Assign->findText(str)); + break; + case 6: + m_config->ch6Assign->setCurrentIndex(m_config->ch0Assign->findText(str)); + break; + case 7: + m_config->ch7Assign->setCurrentIndex(m_config->ch0Assign->findText(str)); + break; + } +} + + /** * Updates the slider positions and min/max values * @@ -277,6 +394,8 @@ void ConfigGadgetWidget::updateChannels(UAVObject* controlCommand) void ConfigGadgetWidget::updateChannelSlider(QSlider* slider, QLabel* min, QLabel* max, QCheckBox* rev, int value) { if (firstUpdate) { + // Reset all the min/max values of the sliders since we are + // starting the calibration. slider->setMaximum(value); slider->setMinimum(value); slider->setValue(value); diff --git a/ground/src/plugins/config/configgadgetwidget.h b/ground/src/plugins/config/configgadgetwidget.h index 62e270620..796019d51 100644 --- a/ground/src/plugins/config/configgadgetwidget.h +++ b/ground/src/plugins/config/configgadgetwidget.h @@ -53,6 +53,7 @@ private: QList sliders; void updateChannelSlider(QSlider* slider, QLabel* min, QLabel* Max, QCheckBox* rev, int value); void updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj); + void assignChannel(UAVDataObject *obj, UAVObjectField *field, QString str); bool firstUpdate; diff --git a/ground/src/plugins/config/settingswidget.ui b/ground/src/plugins/config/settingswidget.ui index 1b2495a16..2b029d04f 100644 --- a/ground/src/plugins/config/settingswidget.ui +++ b/ground/src/plugins/config/settingswidget.ui @@ -6,7 +6,7 @@ 0 0 - 544 + 617 346 @@ -18,10 +18,13 @@ 10 20 - 521 + 601 311 + + 0 + RC Input @@ -41,6 +44,13 @@ 8 + + <!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:'FreeSans'; font-size:8pt; 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;">Maximum channel value</p></body></html> + 2000 @@ -48,7 +58,7 @@ - 140 + 160 140 21 22 @@ -60,6 +70,13 @@ 8 + + <!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:'FreeSans'; font-size:8pt; 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;">Check to invert the channel.</p></body></html> + @@ -67,12 +84,18 @@ - 260 + 300 30 18 101 + + 1000 + + + 2000 + Qt::Vertical @@ -89,17 +112,24 @@ FreeSans - 9 + 10 + + <!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:'FreeSans'; font-size:9pt; 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;">Current channel value.</p></body></html> + - 1500 + 1000 - 80 + 90 130 31 17 @@ -112,13 +142,13 @@ - 2000 + 1000 - 440 + 530 140 21 22 @@ -130,6 +160,13 @@ 8 + + <!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:'FreeSans'; font-size:8pt; 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;">Check to invert the channel.</p></body></html> + @@ -137,7 +174,7 @@ - 380 + 460 130 31 17 @@ -150,13 +187,13 @@ - 2000 + 1000 - 440 + 520 160 31 17 @@ -165,17 +202,17 @@ FreeSans - 9 + 10 - 1500 + 1000 - 260 + 300 10 31 17 @@ -194,7 +231,7 @@ - 440 + 540 130 31 17 @@ -207,13 +244,13 @@ - 2000 + 1000 - 190 + 270 240 93 27 @@ -229,12 +266,18 @@ - 200 + 230 30 18 101 + + 1000 + + + 2000 + Qt::Vertical @@ -242,7 +285,7 @@ - 140 + 160 130 31 17 @@ -255,13 +298,13 @@ - 2000 + 1000 - 380 + 460 10 31 17 @@ -292,6 +335,13 @@ 8 + + <!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:'FreeSans'; font-size:8pt; 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;">Check to invert the channel.</p></body></html> + @@ -299,7 +349,7 @@ - 320 + 370 10 31 17 @@ -318,7 +368,7 @@ - 200 + 230 10 31 17 @@ -337,7 +387,7 @@ - 80 + 90 140 21 22 @@ -349,6 +399,13 @@ 8 + + <!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:'FreeSans'; font-size:8pt; 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;">Check to invert the channel.</p></body></html> + @@ -356,7 +413,7 @@ - 410 + 490 240 93 27 @@ -373,7 +430,7 @@ Applies and Saves all settings to SD - 260 + 300 160 31 17 @@ -382,17 +439,17 @@ Applies and Saves all settings to SD FreeSans - 9 + 10 - 1500 + 1000 - 260 + 300 130 31 17 @@ -405,18 +462,24 @@ Applies and Saves all settings to SD - 2000 + 1000 - 440 + 540 30 18 101 + + 1000 + + + 2000 + Qt::Vertical @@ -424,7 +487,7 @@ Applies and Saves all settings to SD - 300 + 380 240 93 27 @@ -443,15 +506,30 @@ Be sure to set the Neutral position on all sliders before sending! 10 180 - 51 + 61 21 + + + DejaVu Sans + 7 + + + + + 16 + 16 + + + + true + - 320 + 370 140 21 22 @@ -463,6 +541,13 @@ Be sure to set the Neutral position on all sliders before sending! 8 + + <!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:'FreeSans'; font-size:8pt; 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;">Check to invert the channel.</p></body></html> + @@ -470,12 +555,18 @@ Be sure to set the Neutral position on all sliders before sending! - 80 + 90 30 18 101 + + 1000 + + + 2000 + Qt::Vertical @@ -483,7 +574,7 @@ Be sure to set the Neutral position on all sliders before sending! - 380 + 450 140 21 22 @@ -495,6 +586,13 @@ Be sure to set the Neutral position on all sliders before sending! 8 + + <!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:'FreeSans'; font-size:8pt; 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;">Check to invert the channel.</p></body></html> + @@ -502,7 +600,7 @@ Be sure to set the Neutral position on all sliders before sending! - 200 + 230 130 31 17 @@ -515,13 +613,13 @@ Be sure to set the Neutral position on all sliders before sending! - 2000 + 1000 - 440 + 540 10 31 17 @@ -540,7 +638,7 @@ Be sure to set the Neutral position on all sliders before sending! - 140 + 160 160 31 17 @@ -549,17 +647,17 @@ Be sure to set the Neutral position on all sliders before sending! FreeSans - 9 + 10 - 1500 + 1000 - 320 + 370 160 31 17 @@ -568,22 +666,28 @@ Be sure to set the Neutral position on all sliders before sending! FreeSans - 9 + 10 - 1500 + 1000 - 140 + 160 30 18 101 + + 1000 + + + 2000 + Qt::Vertical @@ -591,7 +695,7 @@ Be sure to set the Neutral position on all sliders before sending! - 320 + 370 130 31 17 @@ -604,13 +708,13 @@ Be sure to set the Neutral position on all sliders before sending! - 2000 + 1000 - 80 + 90 160 31 17 @@ -619,17 +723,17 @@ Be sure to set the Neutral position on all sliders before sending! FreeSans - 9 + 10 - 1500 + 1000 - 380 + 450 160 31 17 @@ -638,17 +742,17 @@ Be sure to set the Neutral position on all sliders before sending! FreeSans - 9 + 10 - 1500 + 1000 - 200 + 230 160 31 17 @@ -657,17 +761,17 @@ Be sure to set the Neutral position on all sliders before sending! FreeSans - 9 + 10 - 1500 + 1000 - 140 + 160 10 31 17 @@ -692,8 +796,11 @@ Be sure to set the Neutral position on all sliders before sending! 101 + + 1000 + - 99 + 2000 Qt::Vertical @@ -702,7 +809,7 @@ Be sure to set the Neutral position on all sliders before sending! - 80 + 90 10 31 17 @@ -721,7 +828,7 @@ Be sure to set the Neutral position on all sliders before sending! - 260 + 300 140 21 22 @@ -733,6 +840,13 @@ Be sure to set the Neutral position on all sliders before sending! 8 + + <!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:'FreeSans'; font-size:8pt; 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;">Check to invert the channel.</p></body></html> + @@ -752,19 +866,32 @@ Be sure to set the Neutral position on all sliders before sending! 8 + + <!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:'FreeSans'; font-size:8pt; 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;">Minimum channel value.</p></body></html> + - 2000 + 1000 - 320 + 370 30 18 101 + + 1000 + + + 2000 + Qt::Vertical @@ -772,12 +899,18 @@ Be sure to set the Neutral position on all sliders before sending! - 380 + 460 30 18 101 + + 1000 + + + 2000 + Qt::Vertical @@ -785,7 +918,7 @@ Be sure to set the Neutral position on all sliders before sending! - 200 + 230 140 21 22 @@ -797,85 +930,134 @@ Be sure to set the Neutral position on all sliders before sending! 8 + + <!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:'FreeSans'; font-size:8pt; 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;">Check to invert the channel.</p></body></html> + - + - 70 + 80 180 - 51 + 61 21 + + + DejaVu Sans + 7 + + - + - 130 + 150 180 - 51 + 61 21 + + + DejaVu Sans + 7 + + - + - 190 + 220 180 - 51 + 61 21 + + + DejaVu Sans + 7 + + - + - 250 + 290 180 - 51 + 61 21 + + + DejaVu Sans + 7 + + - + - 310 + 360 180 - 51 + 61 21 - - - - - 370 - 180 - 51 - 21 - + + + DejaVu Sans + 7 + - + 430 180 - 51 + 61 21 + + + DejaVu Sans + 7 + + + + + + + 500 + 180 + 61 + 21 + + + + + DejaVu Sans + 7 + + - 10 - 210 + 20 + 250 131 22 @@ -897,15 +1079,83 @@ Uncheck/Check to restart calibration. 20 + + Indicates whether OpenPilot is getting a signal from the RC receiver. + RC Receiver Not Connected + + + + 130 + 210 + 89 + 21 + + + + Select the receiver type here: +- PWM is the most usual type +- PPM is connected to input XXX +- Spektrum is used with Spektrum 'satellite' receivers + + + + + + 10 + 210 + 131 + 17 + + + + RC Receiver Type: + + - Tab 2 + Servo Output + + + + 80 + 10 + 89 + 31 + + + + Select aircraft type here + + + + + + 10 + 20 + 62 + 17 + + + + Aircraft: + + + + + + 130 + 60 + 256 + 192 + + +