1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 06:15:16 +03:00

Replace global flags with stateFlags, flightModeFlags and armingFlags.

Each flag was previously a whole byte, now all of the flags only take up
4 bytes as they are represented by bit masks.

This is cleaner because the different kind of flags are now separated.

Additionally this changes the behaviour of arming slightly.  When using
a switch to arm the aircraft will not arm unless the switch has been in
the off state once.  This prevents arming if you power the aircraft with
a low throttle and the switch in the on position.
This commit is contained in:
Dominic Clifton 2014-08-24 12:11:30 +01:00
parent 1ea014ae25
commit 3f0754d295
18 changed files with 220 additions and 164 deletions

View file

@ -105,7 +105,7 @@ void failsafeAvoidRearm(void)
{
// 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
f.PREVENT_ARMING = 1;
ENABLE_ARMING_FLAG(PREVENT_ARMING);
}
void onValidDataReceived(void)
@ -129,7 +129,7 @@ void updateState(void)
return;
}
if (shouldForceLanding(f.ARMED)) { // Stabilize, and set Throttle to specified level
if (shouldForceLanding(ARMING_FLAG(ARMED))) { // Stabilize, and set Throttle to specified level
failsafeAvoidRearm();
for (i = 0; i < 3; i++) {
@ -139,7 +139,7 @@ void updateState(void)
failsafe.events++;
}
if (shouldHaveCausedLandingByNow() || !f.ARMED) {
if (shouldHaveCausedLandingByNow() || !ARMING_FLAG(ARMED)) {
mwDisarm();
}
}