mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +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:
parent
aef28c1c08
commit
e969d184e6
29 changed files with 224 additions and 119 deletions
15
src/buzzer.c
15
src/buzzer.c
|
@ -26,6 +26,13 @@ typedef enum {
|
|||
FAILSAFE_FIND_ME
|
||||
} failsafeBuzzerWarnings_e;
|
||||
|
||||
failsafe_t* failsafe;
|
||||
|
||||
void buzzerInit(failsafe_t *initialFailsafe)
|
||||
{
|
||||
failsafe = initialFailsafe;
|
||||
}
|
||||
|
||||
void buzzer(bool warn_vbat)
|
||||
{
|
||||
static uint8_t beeperOnBox;
|
||||
|
@ -41,19 +48,19 @@ void buzzer(bool warn_vbat)
|
|||
}
|
||||
//===================== Beeps for failsafe =====================
|
||||
if (feature(FEATURE_FAILSAFE)) {
|
||||
if (shouldFailsafeForceLanding(f.ARMED)) {
|
||||
if (failsafe->vTable->shouldForceLanding(f.ARMED)) {
|
||||
warn_failsafe = FAILSAFE_LANDING;
|
||||
|
||||
if (shouldFailsafeHaveCausedLandingByNow()) {
|
||||
if (failsafe->vTable->shouldHaveCausedLandingByNow()) {
|
||||
warn_failsafe = FAILSAFE_FIND_ME;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasFailsafeTimerElapsed() && !f.ARMED) {
|
||||
if (failsafe->vTable->hasTimerElapsed() && !f.ARMED) {
|
||||
warn_failsafe = FAILSAFE_FIND_ME;
|
||||
}
|
||||
|
||||
if (isFailsafeIdle()) {
|
||||
if (failsafe->vTable->isIdle()) {
|
||||
warn_failsafe = FAILSAFE_IDLE; // turn off alarm if TX is okay
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue