1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 21:35:44 +03:00

Added switching off of beeper in all cases when crash recovery is disabled.

This commit is contained in:
mikeller 2017-10-20 11:58:31 +13:00
parent b7fe3e203e
commit 46624d28ca

View file

@ -517,22 +517,21 @@ void pidController(const pidProfile_t *pidProfile, const rollAndPitchTrims_t *an
// if crash recovery is on and accelerometer enabled then check for a crash // if crash recovery is on and accelerometer enabled then check for a crash
if (pidProfile->crash_recovery) { if (pidProfile->crash_recovery) {
if (ARMING_FLAG(ARMED)) { if (ARMING_FLAG(ARMED)) {
if (motorMixRange >= 1.0f && inCrashRecoveryMode == false if (motorMixRange >= 1.0f && !inCrashRecoveryMode
&& ABS(delta) > crashDtermThreshold && ABS(delta) > crashDtermThreshold
&& ABS(errorRate) > crashGyroThreshold && ABS(errorRate) > crashGyroThreshold
&& ABS(getSetpointRate(axis)) < crashSetpointThreshold) { && ABS(getSetpointRate(axis)) < crashSetpointThreshold) {
inCrashRecoveryMode = true; inCrashRecoveryMode = true;
crashDetectedAtUs = currentTimeUs; crashDetectedAtUs = currentTimeUs;
} }
if (cmpTimeUs(currentTimeUs, crashDetectedAtUs) < crashTimeDelayUs && (ABS(errorRate) < crashGyroThreshold if (inCrashRecoveryMode && cmpTimeUs(currentTimeUs, crashDetectedAtUs) < crashTimeDelayUs && (ABS(errorRate) < crashGyroThreshold
|| ABS(getSetpointRate(axis)) > crashSetpointThreshold)) { || ABS(getSetpointRate(axis)) > crashSetpointThreshold)) {
inCrashRecoveryMode = false; inCrashRecoveryMode = false;
}
} else {
if (inCrashRecoveryMode) {
BEEP_OFF; BEEP_OFF;
} }
} else if (inCrashRecoveryMode) {
inCrashRecoveryMode = false; inCrashRecoveryMode = false;
BEEP_OFF;
} }
} }
axisPID_D[axis] = Kd[axis] * delta * tpaFactor; axisPID_D[axis] = Kd[axis] * delta * tpaFactor;