diff --git a/src/mw.c b/src/mw.c index 3d87f7c382..85b5beaef1 100755 --- a/src/mw.c +++ b/src/mw.c @@ -81,14 +81,19 @@ uint16_t InflightcalibratingA = 0; void updateAutotuneState(void) { + static bool landedAfterAutoTuning = false; + static bool autoTuneWasUsed = false; + if (rcOptions[BOXAUTOTUNE]) { if (!f.AUTOTUNE_MODE) { if (f.ARMED) { - if (isAutotuneIdle()) { + if (isAutotuneIdle() || landedAfterAutoTuning) { autotuneReset(); + landedAfterAutoTuning = false; } autotuneBeginNextPhase(¤tProfile.pidProfile, currentProfile.pidController); f.AUTOTUNE_MODE = 1; + autoTuneWasUsed = true; } else { if (havePidsBeenUpdatedByAutotune()) { //writeEEPROM(); @@ -104,6 +109,10 @@ void updateAutotuneState(void) autotuneEndPhase(); f.AUTOTUNE_MODE = 0; } + + if (!f.ARMED && autoTuneWasUsed) { + landedAfterAutoTuning = true; + } } bool isCalibrating()