mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 05:45:31 +03:00
Update the failsafe so that an extra cycle is not required between some
phase changes.
This commit is contained in:
parent
eb74735ee8
commit
a34e8f0bdb
2 changed files with 54 additions and 40 deletions
|
@ -145,42 +145,59 @@ void failsafeUpdateState(void)
|
|||
failsafeState.active = false;
|
||||
}
|
||||
|
||||
switch (failsafeState.phase) {
|
||||
case FAILSAFE_IDLE:
|
||||
if (!receivingRxData && armed) {
|
||||
failsafeState.phase = FAILSAFE_RX_LOSS_DETECTED;
|
||||
}
|
||||
break;
|
||||
|
||||
case FAILSAFE_RX_LOSS_DETECTED:
|
||||
if (failsafeShouldForceLanding(armed)) {
|
||||
// Stabilize, and set Throttle to specified level
|
||||
failsafeActivate();
|
||||
}
|
||||
break;
|
||||
bool reprocessState;
|
||||
|
||||
case FAILSAFE_LANDING:
|
||||
if (armed) {
|
||||
failsafeApplyControlInput();
|
||||
}
|
||||
do {
|
||||
reprocessState = false;
|
||||
|
||||
if (failsafeShouldHaveCausedLandingByNow() || !armed) {
|
||||
switch (failsafeState.phase) {
|
||||
case FAILSAFE_IDLE:
|
||||
if (!receivingRxData && armed) {
|
||||
failsafeState.phase = FAILSAFE_RX_LOSS_DETECTED;
|
||||
|
||||
reprocessState = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case FAILSAFE_RX_LOSS_DETECTED:
|
||||
if (failsafeShouldForceLanding(armed)) {
|
||||
// Stabilize, and set Throttle to specified level
|
||||
failsafeActivate();
|
||||
|
||||
reprocessState = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case FAILSAFE_LANDING:
|
||||
if (armed) {
|
||||
failsafeApplyControlInput();
|
||||
}
|
||||
|
||||
if (failsafeShouldHaveCausedLandingByNow() || !armed) {
|
||||
|
||||
failsafeState.phase = FAILSAFE_LANDED;
|
||||
|
||||
reprocessState = true;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case FAILSAFE_LANDED:
|
||||
|
||||
// This will prevent the automatic rearm if failsafe shuts it down and prevents
|
||||
// to restart accidently by just reconnect to the tx - you will have to switch off first to rearm
|
||||
ENABLE_ARMING_FLAG(PREVENT_ARMING);
|
||||
|
||||
failsafeState.phase = FAILSAFE_LANDED;
|
||||
failsafeState.active = false;
|
||||
mwDisarm();
|
||||
}
|
||||
break;
|
||||
|
||||
case FAILSAFE_LANDED:
|
||||
// This will prevent the automatic rearm if failsafe shuts it down and prevents
|
||||
// to restart accidently by just reconnect to the tx - you will have to switch off first to rearm
|
||||
ENABLE_ARMING_FLAG(PREVENT_ARMING);
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} while (reprocessState);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue