From 25dad0957cccf39c168e6964f0990e40964243e8 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 10 Apr 2016 19:27:05 +0200 Subject: [PATCH] LP-285 Set Accessory neutral to middle range --- .../src/plugins/config/configinputwidget.cpp | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ground/gcs/src/plugins/config/configinputwidget.cpp b/ground/gcs/src/plugins/config/configinputwidget.cpp index f050d84fe..f350afcd3 100644 --- a/ground/gcs/src/plugins/config/configinputwidget.cpp +++ b/ground/gcs/src/plugins/config/configinputwidget.cpp @@ -924,7 +924,12 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step) manualCommandData = manualCommandObj->getData(); manualSettingsData = manualSettingsObj->getData(); for (unsigned int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; ++i) { - manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i]; + // Set Accessory neutral to middle range + if (i >= ManualControlSettings::CHANNELNUMBER_ACCESSORY0) { + manualSettingsData.ChannelNeutral[i] = manualSettingsData.ChannelMin[i] + ((manualSettingsData.ChannelMax[i] - manualSettingsData.ChannelMin[i]) / 2); + } else { + manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i]; + } } manualSettingsObj->setData(manualSettingsData); setTxMovement(nothing); @@ -1905,7 +1910,12 @@ void ConfigInputWidget::updateCalibration() if ((i == ManualControlSettings::CHANNELNUMBER_FLIGHTMODE) || (i == ManualControlSettings::CHANNELNUMBER_THROTTLE)) { adjustSpecialNeutrals(); } else { - manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i]; + // Set Accessory neutral to middle range + if (i >= ManualControlSettings::CHANNELNUMBER_ACCESSORY0) { + manualSettingsData.ChannelNeutral[i] = manualSettingsData.ChannelMin[i] + ((manualSettingsData.ChannelMax[i] - manualSettingsData.ChannelMin[i]) / 2); + } else { + manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i]; + } } } @@ -1981,7 +1991,12 @@ void ConfigInputWidget::simpleCalibration(bool enable) adjustSpecialNeutrals(); checkThrottleRange(); } else { - manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i]; + // Set Accessory neutral to middle range + if (i >= ManualControlSettings::CHANNELNUMBER_ACCESSORY0) { + manualSettingsData.ChannelNeutral[i] = manualSettingsData.ChannelMin[i] + ((manualSettingsData.ChannelMax[i] - manualSettingsData.ChannelMin[i]) / 2); + } else { + manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i]; + } } } manualSettingsObj->setData(manualSettingsData); @@ -2074,7 +2089,7 @@ void ConfigInputWidget::resetActuatorSettings() // Clear all output data : Min, max, neutral at same value // 1000 for motors and 1500 for all others (Reversable motor included) - for (unsigned int output = 0; output < 12; output++) { + for (unsigned int output = 0; output < ActuatorSettings::CHANNELMAX_NUMELEM; output++) { QString mixerNumType = QString("Mixer%1Type").arg(output + 1); UAVObjectField *field = mixer->getField(mixerNumType); Q_ASSERT(field);