void updateAutotuneState(void) { static bool landedAfterAutoTuning = false; static bool autoTuneWasUsed = false; if (rcOptions[BOXAUTOTUNE]) { if (!f.AUTOTUNE_MODE) { if (f.ARMED) { if (isAutotuneIdle() || landedAfterAutoTuning) { autotuneReset(); landedAfterAutoTuning = false; } autotuneBeginNextPhase(¤tProfile.pidProfile, currentProfile.pidController); f.AUTOTUNE_MODE = 1; autoTuneWasUsed = true; } else { if (havePidsBeenUpdatedByAutotune()) { saveAndReloadCurrentProfileToCurrentProfileSlot(); autotuneReset(); } } } return; } if (f.AUTOTUNE_MODE) { autotuneEndPhase(); f.AUTOTUNE_MODE = 0; } if (!f.ARMED && autoTuneWasUsed) { landedAfterAutoTuning = true; } }
void updateAutotuneState(void) { static bool landedAfterAutoTuning = false; static bool autoTuneWasUsed = false; if (IS_RC_MODE_ACTIVE(BOXAUTOTUNE)) { if (!FLIGHT_MODE(AUTOTUNE_MODE)) { if (ARMING_FLAG(ARMED)) { if (isAutotuneIdle() || landedAfterAutoTuning) { autotuneReset(); landedAfterAutoTuning = false; } autotuneBeginNextPhase(¤tProfile->pidProfile); ENABLE_FLIGHT_MODE(AUTOTUNE_MODE); autoTuneWasUsed = true; } else { if (havePidsBeenUpdatedByAutotune()) { saveConfigAndNotify(); autotuneReset(); } } } return; } if (FLIGHT_MODE(AUTOTUNE_MODE)) { autotuneEndPhase(); DISABLE_FLIGHT_MODE(AUTOTUNE_MODE); } if (!ARMING_FLAG(ARMED) && autoTuneWasUsed) { landedAfterAutoTuning = true; } }