1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

LP-478 Avoid transition values detected as Flightmode

This commit is contained in:
Laurent Lalanne 2017-01-22 00:34:35 +01:00
parent 184ac1e4e7
commit a071de9cc9

View File

@ -1172,6 +1172,7 @@ void ConfigInputWidget::identifyControls()
void ConfigInputWidget::identifyLimits()
{
uint16_t inputValue;
static uint16_t previousInputFMValue;
bool newLimitValue = false;
bool newFlightModeValue = false;
@ -1204,6 +1205,10 @@ void ConfigInputWidget::identifyLimits()
}
// Flightmode channel
if (i == ManualControlSettings::CHANNELGROUPS_FLIGHTMODE) {
int deltaInput = abs(previousInputFMValue - inputValue);
previousInputFMValue = inputValue;
// Expecting two consecutive readings within a close value
if (deltaInput < 5) {
// Avoid duplicate values too close and error due to RcTx drift
int minSpacing = 100; // 100µs
for (int pos = 0; pos < manualSettingsData.FlightModeNumber + 1; ++pos) {
@ -1236,6 +1241,7 @@ void ConfigInputWidget::identifyLimits()
}
}
}
}
// Save only if something changed
if (newLimitValue || newFlightModeValue) {
UAVObjectUpdaterHelper updateHelper;