From 06fc5a1110e0e2a3e2031457db79a73c9023523e Mon Sep 17 00:00:00 2001 From: James Cotton Date: Mon, 12 Sep 2011 22:27:11 -0500 Subject: [PATCH] Input Configuration: Fix flight mode slider detection (looking at wrong channel number). --- .../src/plugins/config/configinputwidget.cpp | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 6982ef91d..9e7cfdd04 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -1317,37 +1317,34 @@ void ConfigInputWidget::moveFMSlider() { ManualControlSettings::DataFields manualSettingsDataPriv = manualSettingsObj->getData(); ManualControlCommand::DataFields manualCommandDataPriv=manualCommandObj->getData(); - uint chIndex = manualSettingsDataPriv.ChannelNumber[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE]; - if (chIndex < 8) { - float valueScaled; - int chMin = manualSettingsDataPriv.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE]; - int chMax = manualSettingsDataPriv.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE]; - int chNeutral = manualSettingsDataPriv.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE]; + float valueScaled; + int chMin = manualSettingsDataPriv.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE]; + int chMax = manualSettingsDataPriv.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE]; + int chNeutral = manualSettingsDataPriv.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE]; - int value = manualCommandDataPriv.Channel[chIndex]; - if ((chMax > chMin && value >= chNeutral) || (chMin > chMax && value <= chNeutral)) - { - if (chMax != chNeutral) - valueScaled = (float)(value - chNeutral) / (float)(chMax - chNeutral); - else - valueScaled = 0; - } + int value = manualCommandDataPriv.Channel[ManualControlSettings::CHANNELMIN_FLIGHTMODE]; + if ((chMax > chMin && value >= chNeutral) || (chMin > chMax && value <= chNeutral)) + { + if (chMax != chNeutral) + valueScaled = (float)(value - chNeutral) / (float)(chMax - chNeutral); else - { - if (chMin != chNeutral) - valueScaled = (float)(value - chNeutral) / (float)(chNeutral - chMin); - else - valueScaled = 0; - } - - if(valueScaled < -(1.0 / 3.0)) - m_config->fmsSlider->setValue(-100); - else if (valueScaled > (1.0/3.0)) - m_config->fmsSlider->setValue(100); - else - m_config->fmsSlider->setValue(0); + valueScaled = 0; } + else + { + if (chMin != chNeutral) + valueScaled = (float)(value - chNeutral) / (float)(chNeutral - chMin); + else + valueScaled = 0; + } + + if(valueScaled < -(1.0 / 3.0)) + m_config->fmsSlider->setValue(-100); + else if (valueScaled > (1.0/3.0)) + m_config->fmsSlider->setValue(100); + else + m_config->fmsSlider->setValue(0); } void ConfigInputWidget::updateCalibration()