1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

Input configuration: add reverse checkbox and label for current neutral value

This commit is contained in:
James Cotton 2011-09-09 00:54:47 -05:00
parent 1a2750051a
commit a5509965b2
5 changed files with 45 additions and 10 deletions

View File

@ -1044,9 +1044,11 @@ void ConfigInputWidget::updateCalibration()
manualCommandData=manualCommandObj->getData();
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
{
if(manualSettingsData.ChannelMin[i]>manualCommandData.Channel[i])
if((!reverse[i] && manualSettingsData.ChannelMin[i]>manualCommandData.Channel[i]) ||
(reverse[i] && manualSettingsData.ChannelMin[i]<manualCommandData.Channel[i]))
manualSettingsData.ChannelMin[i]=manualCommandData.Channel[i];
if(manualSettingsData.ChannelMax[i]<manualCommandData.Channel[i])
if((!reverse[i] && manualSettingsData.ChannelMax[i]<manualCommandData.Channel[i]) ||
(reverse[i] && manualSettingsData.ChannelMax[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];

View File

@ -61,6 +61,7 @@ public slots:
private:
bool growing;
bool reverse[ManualControlSettings::CHANNELNEUTRAL_NUMELEM];
txMovements currentMovement;
int movePos;
void setTxMovement(txMovements movement);

View File

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

View File

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

View File

@ -174,6 +174,23 @@
</property>
</widget>
</item>
<item row="2" column="8">
<widget class="QCheckBox" name="channelRev">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
<item row="2" column="7">
<widget class="QLabel" name="neutral">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>