mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
OP-521: Fixed dangerous UI bug that reversed flight mode switch on GCS relative
to flight when flight mode switch input range was reversed. Also switche to using static field method technique for compiler error checking (preferrable when possible)
This commit is contained in:
parent
0b78ae07bb
commit
68d6e7deba
@ -38,6 +38,8 @@
|
|||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "manualcontrolsettings.h"
|
||||||
|
|
||||||
ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||||
{
|
{
|
||||||
m_config = new Ui_InputWidget();
|
m_config = new Ui_InputWidget();
|
||||||
@ -547,7 +549,7 @@ void ConfigInputWidget::updateChannels(UAVObject* controlCommand)
|
|||||||
mdata.flightAccess = UAVObject::ACCESS_READONLY;
|
mdata.flightAccess = UAVObject::ACCESS_READONLY;
|
||||||
obj->setMetadata(mdata);
|
obj->setMetadata(mdata);
|
||||||
UAVObjectField *field = obj->getField("Channel");
|
UAVObjectField *field = obj->getField("Channel");
|
||||||
for (int i=0; i< field->getNumElements(); i++) {
|
for (uint i=0; i< field->getNumElements(); i++) {
|
||||||
field->setValue(0,i);
|
field->setValue(0,i);
|
||||||
}
|
}
|
||||||
obj->updated();
|
obj->updated();
|
||||||
@ -574,17 +576,17 @@ void ConfigInputWidget::updateChannels(UAVObject* controlCommand)
|
|||||||
}
|
}
|
||||||
firstUpdate = true;
|
firstUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the Flight mode channel slider
|
//Update the Flight mode channel slider
|
||||||
UAVObject* obj = getObjectManager()->getObject("ManualControlSettings");
|
ManualControlSettings * manualSettings = ManualControlSettings::GetInstance(getObjectManager());
|
||||||
// Find the channel currently assigned to flightmode
|
ManualControlSettings::DataFields manualSettingsData = manualSettings->getData();
|
||||||
field = obj->getField("FlightMode");
|
uint chIndex = manualSettingsData.FlightMode;
|
||||||
int chIndex = field->getOptions().indexOf(field->getValue().toString());
|
if (chIndex < manualSettings->FLIGHTMODEPOSITION_NUMELEM - 1) {
|
||||||
if (chIndex < field->getOptions().length() - 1) {
|
|
||||||
float valueScaled;
|
float valueScaled;
|
||||||
|
|
||||||
int chMin = inSliders[chIndex]->minimum();
|
int chMin = manualSettingsData.ChannelMin[chIndex];
|
||||||
int chMax = inSliders[chIndex]->maximum();
|
int chMax = manualSettingsData.ChannelMax[chIndex];
|
||||||
int chNeutral = inSliders[chIndex]->value();
|
int chNeutral = manualSettingsData.ChannelNeutral[chIndex];
|
||||||
|
|
||||||
int value = controlCommand->getField("Channel")->getValue(chIndex).toInt();
|
int value = controlCommand->getField("Channel")->getValue(chIndex).toInt();
|
||||||
if ((chMax > chMin && value >= chNeutral) || (chMin > chMax && value <= chNeutral))
|
if ((chMax > chMin && value >= chNeutral) || (chMin > chMax && value <= chNeutral))
|
||||||
|
Loading…
Reference in New Issue
Block a user