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 + + +