1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

OP-1166 Adde some more nice to have functionality to the channel configuration gui.

This commit is contained in:
Fredrik Arvidsson 2014-01-21 00:49:46 +01:00
parent 4cac7d18ac
commit 1537dc4187
4 changed files with 59 additions and 21 deletions

View File

@ -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) {

View File

@ -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);
}
}
}
/**

View File

@ -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);

View File

@ -565,22 +565,6 @@ font:bold;</string>
</property>
</widget>
</item>
<item row="1" column="6" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="neutral">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="12">
<widget class="QSpinBox" name="channelResponseTime">
<property name="enabled">
@ -652,7 +636,7 @@ even lead to crash. Use with caution.</string>
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QCheckBox" name="channelRev">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
@ -668,6 +652,22 @@ even lead to crash. Use with caution.</string>
</layout>
</widget>
</item>
<item row="1" column="6">
<widget class="QSpinBox" name="neutralValue">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
</layout>
<widget class="QSpinBox" name="channelNumber">
<property name="enabled">