From a5509965b2263968c9fb35837f6d7be8faf82660 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Fri, 9 Sep 2011 00:54:47 -0500 Subject: [PATCH] Input configuration: add reverse checkbox and label for current neutral value --- .../src/plugins/config/configinputwidget.cpp | 7 +++-- .../src/plugins/config/configinputwidget.h | 1 + .../src/plugins/config/inputchannelform.cpp | 26 ++++++++++++++----- .../src/plugins/config/inputchannelform.h | 4 +-- .../src/plugins/config/inputchannelform.ui | 17 ++++++++++++ 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 09ac656de..038c411ed 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -1044,9 +1044,11 @@ void ConfigInputWidget::updateCalibration() manualCommandData=manualCommandObj->getData(); for(uint i=0;imanualCommandData.Channel[i]) + if((!reverse[i] && manualSettingsData.ChannelMin[i]>manualCommandData.Channel[i]) || + (reverse[i] && manualSettingsData.ChannelMin[i]manualCommandData.Channel[i])) manualSettingsData.ChannelMax[i]=manualCommandData.Channel[i]; manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i]; } @@ -1072,6 +1074,7 @@ void ConfigInputWidget::simpleCalibration(bool enable) manualSettingsObj->setData(manualSettingsData); for (unsigned int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++) { + reverse[i] = manualSettingsData.ChannelMax[i] < manualSettingsData.ChannelMin[i]; manualSettingsData.ChannelMin[i] = manualCommandData.Channel[i]; manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i]; manualSettingsData.ChannelMax[i] = manualCommandData.Channel[i]; diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.h b/ground/openpilotgcs/src/plugins/config/configinputwidget.h index 1bc1701e7..fd6b14001 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.h @@ -61,6 +61,7 @@ public slots: private: bool growing; + bool reverse[ManualControlSettings::CHANNELNEUTRAL_NUMELEM]; txMovements currentMovement; int movePos; void setTxMovement(txMovements movement); diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp index 72c2cfd5e..c30de6d31 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp @@ -24,9 +24,10 @@ inputChannelForm::inputChannelForm(QWidget *parent,bool showlegend) : delete ui->legend5; } - connect(ui->channelMin,SIGNAL(valueChanged(int)),this,SLOT(minUpdated(int))); - connect(ui->channelMax,SIGNAL(valueChanged(int)),this,SLOT(maxUpdated(int))); + connect(ui->channelMin,SIGNAL(valueChanged(int)),this,SLOT(minMaxUpdated())); + connect(ui->channelMax,SIGNAL(valueChanged(int)),this,SLOT(minMaxUpdated())); connect(ui->channelGroup,SIGNAL(currentIndexChanged(int)),this,SLOT(groupUpdated())); + connect(ui->channelNeutral,SIGNAL(valueChanged(int)), this, SLOT(neutralUpdated(int))); // 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 @@ -40,14 +41,27 @@ inputChannelForm::~inputChannelForm() delete ui; } -void inputChannelForm::minUpdated(int newval) +/** + * Update the direction of the slider and boundaries + */ +void inputChannelForm::minMaxUpdated() { - ui->channelNeutral->setMinimum(newval); + bool reverse = ui->channelMin->value() > ui->channelMax->value(); + if(reverse) { + ui->channelNeutral->setMinimum(ui->channelMax->value()); + ui->channelNeutral->setMaximum(ui->channelMin->value()); + } else { + ui->channelNeutral->setMinimum(ui->channelMin->value()); + ui->channelNeutral->setMaximum(ui->channelMax->value()); + } + ui->channelRev->setChecked(reverse); + ui->channelNeutral->setInvertedAppearance(reverse); + ui->channelNeutral->setInvertedControls(reverse); } -void inputChannelForm::maxUpdated(int newval) +void inputChannelForm::neutralUpdated(int newval) { - ui->channelNeutral->setMaximum(newval); + ui->neutral->setText(QString::number(newval)); } /** diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.h b/ground/openpilotgcs/src/plugins/config/inputchannelform.h index 2567ba275..eb8ad7d18 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.h +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.h @@ -17,8 +17,8 @@ public: friend class ConfigInputWidget; private slots: - void minUpdated(int); - void maxUpdated(int); + void minMaxUpdated(); + void neutralUpdated(int); 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 1e8b53c7c..4ebaa12eb 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.ui +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.ui @@ -174,6 +174,23 @@ + + + + false + + + Rev + + + + + + + TextLabel + + +