mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
Make the input wizard detect already inverted channels and preserve them.
This commit is contained in:
parent
fae611a01f
commit
d3cc67f5c4
@ -455,8 +455,15 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
|
||||
manualSettingsData=manualSettingsObj->getData();
|
||||
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
||||
{
|
||||
// Preserve the inverted status
|
||||
if(manualSettingsData.ChannelMin[i] <= manualSettingsData.ChannelMax[i]) {
|
||||
manualSettingsData.ChannelMin[i]=manualSettingsData.ChannelNeutral[i];
|
||||
manualSettingsData.ChannelMax[i]=manualSettingsData.ChannelNeutral[i];
|
||||
} else {
|
||||
// Make this detect as still inverted
|
||||
manualSettingsData.ChannelMin[i]=manualSettingsData.ChannelNeutral[i] + 1;
|
||||
manualSettingsData.ChannelMax[i]=manualSettingsData.ChannelNeutral[i];
|
||||
}
|
||||
}
|
||||
connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyLimits()));
|
||||
connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
||||
@ -466,13 +473,19 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
|
||||
dimOtherControls(true);
|
||||
setTxMovement(nothing);
|
||||
extraWidgets.clear();
|
||||
foreach(QString name,manualSettingsObj->getFields().at(0)->getElementNames())
|
||||
|
||||
for (int index = 0; index < manualSettingsObj->getField("ChannelMax")->getElementNames().length(); index++)
|
||||
{
|
||||
QString name = manualSettingsObj->getField("ChannelMax")->getElementNames().at(index);
|
||||
if(!name.contains("Access") && !name.contains("Flight"))
|
||||
{
|
||||
QCheckBox * cb=new QCheckBox(name,this);
|
||||
// Make sure checked status matches current one
|
||||
cb->setChecked(manualSettingsData.ChannelMax[index] < manualSettingsData.ChannelMin[index]);
|
||||
|
||||
extraWidgets.append(cb);
|
||||
m_config->checkBoxesLayout->layout()->addWidget(cb);
|
||||
|
||||
connect(cb,SIGNAL(toggled(bool)),this,SLOT(invertControls()));
|
||||
}
|
||||
}
|
||||
@ -711,10 +724,19 @@ void ConfigInputWidget::identifyLimits()
|
||||
manualCommandData=manualCommandObj->getData();
|
||||
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
||||
{
|
||||
if(manualSettingsData.ChannelMin[i] <= manualSettingsData.ChannelMax[i]) {
|
||||
// Non inverted channel
|
||||
if(manualSettingsData.ChannelMin[i]>manualCommandData.Channel[i])
|
||||
manualSettingsData.ChannelMin[i]=manualCommandData.Channel[i];
|
||||
if(manualSettingsData.ChannelMax[i]<manualCommandData.Channel[i])
|
||||
manualSettingsData.ChannelMax[i]=manualCommandData.Channel[i];
|
||||
} else {
|
||||
// Inverted channel
|
||||
if(manualSettingsData.ChannelMax[i]>manualCommandData.Channel[i])
|
||||
manualSettingsData.ChannelMax[i]=manualCommandData.Channel[i];
|
||||
if(manualSettingsData.ChannelMin[i]<manualCommandData.Channel[i])
|
||||
manualSettingsData.ChannelMin[i]=manualCommandData.Channel[i];
|
||||
}
|
||||
}
|
||||
manualSettingsObj->setData(manualSettingsData);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user