1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 01:05:27 +03:00

decouple failsafe from the rest of the system.

Note: the pwm_common driver has a dependency on the main failsafe code,
the solution is probably to move some of the code into rx_pwm.
This commit is contained in:
Dominic Clifton 2014-04-21 00:46:16 +01:00
parent aef28c1c08
commit e969d184e6
29 changed files with 224 additions and 119 deletions

View file

@ -37,6 +37,8 @@ uint8_t dynP8[3], dynI8[3], dynD8[3];
int16_t axisPID[3];
extern failsafe_t *failsafe;
// **********************
// GPS
// **********************
@ -412,7 +414,9 @@ void loop(void)
rssi = (uint16_t)((constrain(rssiChannelData - 1000, 0, 1000) / 1000.0f) * 1023.0f);
}
updateFailsafeState();
if (feature(FEATURE_FAILSAFE)) {
failsafe->vTable->updateState();
}
// ------------------ STICKS COMMAND HANDLER --------------------
// checking sticks positions
@ -552,8 +556,7 @@ void loop(void)
for (i = 0; i < CHECKBOX_ITEM_COUNT; i++)
rcOptions[i] = (auxState & cfg.activate[i]) > 0;
// note: if FAILSAFE is disable, hasFailsafeTimerElapsed() is always false
if ((rcOptions[BOXANGLE] || hasFailsafeTimerElapsed()) && (sensors(SENSOR_ACC))) {
if ((rcOptions[BOXANGLE] || (feature(FEATURE_FAILSAFE) && failsafe->vTable->hasTimerElapsed())) && (sensors(SENSOR_ACC))) {
// bumpless transfer to Level mode
if (!f.ANGLE_MODE) {
errorAngleI[ROLL] = 0;
@ -561,7 +564,7 @@ void loop(void)
f.ANGLE_MODE = 1;
}
} else {
f.ANGLE_MODE = 0; // failsave support
f.ANGLE_MODE = 0; // failsafe support
}
if (rcOptions[BOXHORIZON]) {