From 4cac7d18ac1e8b422bed3e3e48ca6f2ba4078128 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 21 Jan 2014 00:06:20 +0100 Subject: [PATCH 1/2] OP-1166 Fixes the maxed out bug and beautifies some gui. --- .../src/plugins/config/configinputwidget.cpp | 10 +- .../openpilotgcs/src/plugins/config/input.ui | 27 +- .../src/plugins/config/inputchannelform.cpp | 22 +- .../src/plugins/config/inputchannelform.h | 10 +- .../src/plugins/config/inputchannelform.ui | 527 +++++++++++------- .../uavobjectutil/uavobjectutilmanager.cpp | 3 + 6 files changed, 353 insertions(+), 246 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 6b6ff816b..f6173fbfb 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -79,16 +79,20 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : unsigned int indexRT = 0; foreach(QString name, manualSettingsObj->getField("ChannelNumber")->getElementNames()) { Q_ASSERT(index < ManualControlSettings::CHANNELGROUPS_NUMELEM); - inputChannelForm *inpForm = new inputChannelForm(this, index == 0); + InputChannelForm *inpForm = new InputChannelForm(this, index == 0); ui->channelSettings->layout()->addWidget(inpForm); // Add the row to the UI inpForm->setName(name); addWidgetBinding("ManualControlSettings", "ChannelGroups", inpForm->ui->channelGroup, index); addWidgetBinding("ManualControlSettings", "ChannelNumber", inpForm->ui->channelNumber, index); - addWidgetBinding("ManualControlSettings", "ChannelMin", inpForm->ui->channelMin, index); + + // The order of the following three binding calls is important. Since the values will be populated + // in reverse order of the binding order otherwise the 'Reversed' logic will floor the neutral value + // to the max value ( which is smaller than the neutral value when reversed ) addWidgetBinding("ManualControlSettings", "ChannelNeutral", inpForm->ui->channelNeutral, index); + addWidgetBinding("ManualControlSettings", "ChannelMin", inpForm->ui->channelMin, index); addWidgetBinding("ManualControlSettings", "ChannelMax", inpForm->ui->channelMax, index); + addWidget(inpForm->ui->channelNumberDropdown); - addWidget(inpForm->ui->channelRev); addWidget(inpForm->ui->channelResponseTime); // Input filter response time fields supported for some channels only diff --git a/ground/openpilotgcs/src/plugins/config/input.ui b/ground/openpilotgcs/src/plugins/config/input.ui index 2fdf932e3..5e867e15a 100644 --- a/ground/openpilotgcs/src/plugins/config/input.ui +++ b/ground/openpilotgcs/src/plugins/config/input.ui @@ -128,8 +128,8 @@ 0 0 - 768 - 742 + 766 + 745 @@ -151,7 +151,7 @@ - + Input Channel Configuration @@ -277,13 +277,6 @@ - - - - Qt::Horizontal - - - @@ -388,6 +381,12 @@ + + + 210 + 0 + + Start Configuration Wizard @@ -559,8 +558,8 @@ 0 0 - 768 - 742 + 766 + 745 @@ -2183,8 +2182,8 @@ Setup the flight mode channel on the RC Input tab if you have not done so alread 0 0 - 504 - 156 + 766 + 745 diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp index 0a573adce..e45dabb15 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp @@ -4,9 +4,9 @@ #include "manualcontrolsettings.h" #include "gcsreceiver.h" -inputChannelForm::inputChannelForm(QWidget *parent, bool showlegend) : +InputChannelForm::InputChannelForm(QWidget *parent, bool showlegend) : ConfigTaskWidget(parent), - ui(new Ui::inputChannelForm) + ui(new Ui::InputChannelForm) { ui->setupUi(this); @@ -19,6 +19,7 @@ inputChannelForm::inputChannelForm(QWidget *parent, bool showlegend) : layout()->removeWidget(ui->legend4); layout()->removeWidget(ui->legend5); layout()->removeWidget(ui->legend6); + layout()->removeWidget(ui->legend7); delete ui->legend0; delete ui->legend1; delete ui->legend2; @@ -26,6 +27,7 @@ inputChannelForm::inputChannelForm(QWidget *parent, bool showlegend) : delete ui->legend4; delete ui->legend5; delete ui->legend6; + delete ui->legend7; } connect(ui->channelMin, SIGNAL(valueChanged(int)), this, SLOT(minMaxUpdated())); @@ -43,17 +45,17 @@ inputChannelForm::inputChannelForm(QWidget *parent, bool showlegend) : } -inputChannelForm::~inputChannelForm() +InputChannelForm::~InputChannelForm() { delete ui; } -void inputChannelForm::setName(QString &name) +void InputChannelForm::setName(QString &name) { ui->channelName->setText(name); QFontMetrics metrics(ui->channelName->font()); int width = metrics.width(name) + 5; - foreach(inputChannelForm * form, parent()->findChildren()) { + foreach(InputChannelForm * form, parent()->findChildren()) { if (form == this) { continue; } @@ -69,7 +71,7 @@ void inputChannelForm::setName(QString &name) /** * Update the direction of the slider and boundaries */ -void inputChannelForm::minMaxUpdated() +void InputChannelForm::minMaxUpdated() { bool reverse = ui->channelMin->value() > ui->channelMax->value(); @@ -85,7 +87,7 @@ void inputChannelForm::minMaxUpdated() ui->channelNeutral->setInvertedControls(reverse); } -void inputChannelForm::neutralUpdated(int newval) +void InputChannelForm::neutralUpdated(int newval) { ui->neutral->setText(QString::number(newval)); } @@ -96,7 +98,7 @@ void inputChannelForm::neutralUpdated(int newval) * I fully admit this is terrible practice to embed data within UI * like this. Open to suggestions. JC 2011-09-07 */ -void inputChannelForm::groupUpdated() +void InputChannelForm::groupUpdated() { ui->channelNumberDropdown->clear(); ui->channelNumberDropdown->addItem("Disabled"); @@ -140,7 +142,7 @@ void inputChannelForm::groupUpdated() /** * Update the dropdown from the hidden control */ -void inputChannelForm::channelDropdownUpdated(int newval) +void InputChannelForm::channelDropdownUpdated(int newval) { ui->channelNumber->setValue(newval); } @@ -148,7 +150,7 @@ void inputChannelForm::channelDropdownUpdated(int newval) /** * Update the hidden control from the dropdown */ -void inputChannelForm::channelNumberUpdated(int newval) +void InputChannelForm::channelNumberUpdated(int newval) { ui->channelNumberDropdown->setCurrentIndex(newval); } diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.h b/ground/openpilotgcs/src/plugins/config/inputchannelform.h index ffdb9898b..b275da9f9 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.h +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.h @@ -4,15 +4,15 @@ #include #include "configinputwidget.h" namespace Ui { -class inputChannelForm; +class InputChannelForm; } -class inputChannelForm : public ConfigTaskWidget { +class InputChannelForm : public ConfigTaskWidget { Q_OBJECT public: - explicit inputChannelForm(QWidget *parent = 0, bool showlegend = false); - ~inputChannelForm(); + explicit InputChannelForm(QWidget *parent = 0, bool showlegend = false); + ~InputChannelForm(); friend class ConfigInputWidget; void setName(QString &name); private slots: @@ -23,7 +23,7 @@ private slots: void channelNumberUpdated(int); private: - Ui::inputChannelForm *ui; + Ui::InputChannelForm *ui; }; #endif // INPUTCHANNELFORM_H diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.ui b/ground/openpilotgcs/src/plugins/config/inputchannelform.ui index 7a111d080..22b3beb24 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.ui +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.ui @@ -1,13 +1,13 @@ - inputChannelForm - + InputChannelForm + 0 0 828 - 69 + 93 @@ -26,6 +26,169 @@ 6 + + + + true + + + + 0 + 0 + + + + + 0 + 20 + + + + + 75 + false + true + + + + Channel neutral + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +margin:1px; +font:bold; + + + QFrame::StyledPanel + + + Neutral + + + Qt::AlignCenter + + + + + + + + 0 + 25 + + + + Qt::StrongFocus + + + QAbstractSpinBox::UpDownArrows + + + 9999 + + + 1000 + + + + + + + true + + + + 0 + 0 + + + + + 30 + 20 + + + + + 75 + false + true + + + + Response time + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +margin:1px; +font:bold; + + + QFrame::StyledPanel + + + 1 + + + RT + + + Qt::AlignCenter + + + + + + + true + + + + 0 + 0 + + + + + 75 + 20 + + + + + 75 + false + true + + + + Channel values are inverted + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +margin:1px; +font:bold; + + + QFrame::StyledPanel + + + 1 + + + Reversed + + + Qt::AlignCenter + + + @@ -50,6 +213,9 @@ true + + Channel function + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -92,6 +258,9 @@ font:bold; true + + Channel type + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -134,6 +303,9 @@ font:bold; true + + Channel number + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -176,6 +348,9 @@ font:bold; true + + Channel min + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -194,48 +369,6 @@ font:bold; - - - - true - - - - 0 - 0 - - - - - 0 - 20 - - - - - 75 - false - true - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -margin:1px; -font:bold; - - - QFrame::StyledPanel - - - Neutral - - - Qt::AlignCenter - - - @@ -255,31 +388,6 @@ font:bold; - - - - - 6 - 0 - - - - - 0 - 25 - - - - - 100 - 16777215 - - - - Qt::StrongFocus - - - @@ -308,6 +416,31 @@ font:bold; + + + + + 6 + 0 + + + + + 0 + 25 + + + + + 100 + 16777215 + + + + Qt::StrongFocus + + + @@ -320,7 +453,7 @@ font:bold; Qt::StrongFocus - QAbstractSpinBox::NoButtons + QAbstractSpinBox::UpDownArrows 9999 @@ -346,6 +479,70 @@ font:bold; + + + + true + + + + 0 + 0 + + + + + 0 + 20 + + + + + 75 + false + true + + + + Channel max + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +margin:1px; +font:bold; + + + QFrame::StyledPanel + + + 1 + + + Max + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + @@ -368,112 +565,29 @@ font:bold; - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - + + - 0 - 25 + 30 + 0 - - Qt::StrongFocus - - - QAbstractSpinBox::NoButtons - - - 9999 - - - 1000 - - - - - - - true - - - - 0 - 0 - - - - - 0 - 20 - - - - - 75 - false - true - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -margin:1px; -font:bold; - - - QFrame::StyledPanel - - - 1 - - Max + Qt::AlignCenter - - - - false - - - - 0 - 20 - - - - Rev - - - - + true - + 0 0 @@ -501,72 +615,57 @@ even lead to crash. Use with caution. true - QAbstractSpinBox::NoButtons + QAbstractSpinBox::UpDownArrows 999 - - - - - 0 - 0 - - + + - 30 - 26 - - - - - 75 - false - true - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -margin:5px; -font:bold; - - - RT - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 48 + 75 0 - - - 45 - 16777215 - + + QFrame::NoFrame - - + + QFrame::Raised + + + 0 + + + 0 + + + 0 + + + 0 + + + + + false + + + + 0 + 20 + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp index 5b3b402fe..66cdf495d 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp @@ -467,6 +467,8 @@ bool UAVObjectUtilManager::descriptionToStructure(QByteArray desc, deviceDescrip struc.fwHash = desc.mid(40, 20); struc.uavoHash.clear(); struc.uavoHash = desc.mid(60, 20); + + /* qDebug() << __FUNCTION__ << ":description from board:"; foreach(char x, desc) { qDebug() << QString::number(x, 16); @@ -477,6 +479,7 @@ bool UAVObjectUtilManager::descriptionToStructure(QByteArray desc, deviceDescrip foreach(char x, array2) { qDebug() << QString::number(x, 16); } + */ return true; } return false; From 1537dc41870b4b9f05705b4507b79354a8bbb0f9 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 21 Jan 2014 00:49:46 +0100 Subject: [PATCH 2/2] OP-1166 Adde some more nice to have functionality to the channel configuration gui. --- .../src/plugins/config/configinputwidget.cpp | 2 + .../src/plugins/config/inputchannelform.cpp | 41 +++++++++++++++++-- .../src/plugins/config/inputchannelform.h | 3 +- .../src/plugins/config/inputchannelform.ui | 34 +++++++-------- 4 files changed, 59 insertions(+), 21 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index f6173fbfb..002b81fff 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -89,11 +89,13 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : // in reverse order of the binding order otherwise the 'Reversed' logic will floor the neutral value // to the max value ( which is smaller than the neutral value when reversed ) addWidgetBinding("ManualControlSettings", "ChannelNeutral", inpForm->ui->channelNeutral, index); + addWidgetBinding("ManualControlSettings", "ChannelNeutral", inpForm->ui->neutralValue, index); addWidgetBinding("ManualControlSettings", "ChannelMin", inpForm->ui->channelMin, index); addWidgetBinding("ManualControlSettings", "ChannelMax", inpForm->ui->channelMax, index); addWidget(inpForm->ui->channelNumberDropdown); addWidget(inpForm->ui->channelResponseTime); + addWidget(inpForm->ui->channelRev); // Input filter response time fields supported for some channels only switch (index) { diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp index e45dabb15..0d77b4f15 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp @@ -32,8 +32,9 @@ InputChannelForm::InputChannelForm(QWidget *parent, bool showlegend) : connect(ui->channelMin, SIGNAL(valueChanged(int)), this, SLOT(minMaxUpdated())); connect(ui->channelMax, SIGNAL(valueChanged(int)), this, SLOT(minMaxUpdated())); + connect(ui->neutralValue, SIGNAL(valueChanged(int)), this, SLOT(neutralUpdated())); connect(ui->channelGroup, SIGNAL(currentIndexChanged(int)), this, SLOT(groupUpdated())); - connect(ui->channelNeutral, SIGNAL(valueChanged(int)), this, SLOT(neutralUpdated(int))); + connect(ui->channelRev, SIGNAL(toggled(bool)), this, SLOT(reversedUpdated())); // This is awkward but since we want the UI to be a dropdown but the field is not an enum // it breaks the UAUVObject widget relation of the task gadget. Running the data through @@ -87,9 +88,43 @@ void InputChannelForm::minMaxUpdated() ui->channelNeutral->setInvertedControls(reverse); } -void InputChannelForm::neutralUpdated(int newval) +void InputChannelForm::neutralUpdated() { - ui->neutral->setText(QString::number(newval)); + int neutralValue = ui->neutralValue->value(); + if(ui->channelRev->isChecked()) { + if(neutralValue > ui->channelMin->value()) { + ui->channelMin->setValue(neutralValue); + } else if(neutralValue < ui->channelMax->value()) { + ui->channelMax->setValue(neutralValue); + } + } else { + if(neutralValue < ui->channelMin->value()) { + ui->channelMin->setValue(neutralValue); + } else if(neutralValue > ui->channelMax->value()) { + ui->channelMax->setValue(neutralValue); + } + } +} + +void InputChannelForm::reversedUpdated() +{ + int value = ui->channelNeutral->value(); + int min = ui->channelMin->value(); + int max = ui->channelMax->value(); + + if(ui->channelRev->isChecked()) { + if(min < max) { + ui->channelMax->setValue(min); + ui->channelMin->setValue(max); + ui->channelNeutral->setValue(value); + } + } else { + if(min > max) { + ui->channelMax->setValue(min); + ui->channelMin->setValue(max); + ui->channelNeutral->setValue(value); + } + } } /** diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.h b/ground/openpilotgcs/src/plugins/config/inputchannelform.h index b275da9f9..91d665b40 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.h +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.h @@ -17,7 +17,8 @@ public: void setName(QString &name); private slots: void minMaxUpdated(); - void neutralUpdated(int); + void neutralUpdated(); + void reversedUpdated(); void groupUpdated(); void channelDropdownUpdated(int); void channelNumberUpdated(int); diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.ui b/ground/openpilotgcs/src/plugins/config/inputchannelform.ui index 22b3beb24..d07f2ae3b 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.ui +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.ui @@ -565,22 +565,6 @@ font:bold; - - - - - 30 - 0 - - - - - - - Qt::AlignCenter - - - @@ -652,7 +636,7 @@ even lead to crash. Use with caution. - false + true @@ -668,6 +652,22 @@ even lead to crash. Use with caution. + + + + + 0 + 25 + + + + 9999 + + + 1000 + + +