mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-20 23:05:17 +03:00
Use an STATE() flag instead of an static variable in navigation.c
Also, make the check for setting the STATE() flag clearer. Previous implementation was a bit confusing.
This commit is contained in:
parent
dc6d002bdc
commit
20fac46ee0
4 changed files with 23 additions and 30 deletions
|
@ -375,12 +375,14 @@ void tryArm(void)
|
|||
}
|
||||
|
||||
#if defined(USE_NAV)
|
||||
// Check if we need to make the navigation safety
|
||||
// bypass permanent until power off. See documentation
|
||||
// for these functions.
|
||||
// If nav_extra_arming_safety was bypassed we always
|
||||
// allow bypassing it even without the sticks set
|
||||
// in the correct position to allow re-arming quickly
|
||||
// in case of a mid-air accidental disarm.
|
||||
bool usedBypass = false;
|
||||
if (navigationIsBlockingArming(&usedBypass)) {
|
||||
navigationSetBlockingArmingBypassWithoutSticks(true);
|
||||
navigationIsBlockingArming(&usedBypass);
|
||||
if (usedBypass) {
|
||||
ENABLE_STATE(NAV_EXTRA_ARMING_SAFETY_BYPASSED);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ typedef enum {
|
|||
NAV_CRUISE_BRAKING = (1 << 11),
|
||||
NAV_CRUISE_BRAKING_BOOST = (1 << 12),
|
||||
NAV_CRUISE_BRAKING_LOCKED = (1 << 13),
|
||||
NAV_EXTRA_ARMING_SAFETY_BYPASSED = (1 << 14), // nav_extra_arming_safey was bypassed. Keep it until power cycle.
|
||||
} stateFlags_t;
|
||||
|
||||
#define DISABLE_STATE(mask) (stateFlags &= ~(mask))
|
||||
|
|
|
@ -167,7 +167,6 @@ PG_RESET_TEMPLATE(navConfig_t, navConfig,
|
|||
|
||||
navigationPosControl_t posControl;
|
||||
navSystemStatus_t NAV_Status;
|
||||
static bool blockingArmingBypassWithoutSticks;
|
||||
|
||||
#if defined(NAV_BLACKBOX)
|
||||
int16_t navCurrentState;
|
||||
|
@ -2938,7 +2937,7 @@ navArmingBlocker_e navigationIsBlockingArming(bool *usedBypass)
|
|||
// Apply extra arming safety only if pilot has any of GPS modes configured
|
||||
if ((isUsingNavigationModes() || failsafeMayRequireNavigationMode()) && !((posControl.flags.estPosStatus >= EST_USABLE) && STATE(GPS_FIX_HOME))) {
|
||||
if (navConfig()->general.flags.extra_arming_safety == NAV_EXTRA_ARMING_SAFETY_ALLOW_BYPASS &&
|
||||
(blockingArmingBypassWithoutSticks || rxGetChannelValue(YAW) > 1750)) {
|
||||
(STATE(NAV_EXTRA_ARMING_SAFETY_BYPASSED) || rxGetChannelValue(YAW) > 1750)) {
|
||||
if (usedBypass) {
|
||||
*usedBypass = true;
|
||||
}
|
||||
|
@ -2967,11 +2966,6 @@ navArmingBlocker_e navigationIsBlockingArming(bool *usedBypass)
|
|||
return NAV_ARMING_BLOCKER_NONE;
|
||||
}
|
||||
|
||||
void navigationSetBlockingArmingBypassWithoutSticks(bool allow)
|
||||
{
|
||||
blockingArmingBypassWithoutSticks = allow;
|
||||
}
|
||||
|
||||
bool navigationPositionEstimateIsHealthy(void)
|
||||
{
|
||||
return (posControl.flags.estPosStatus >= EST_USABLE) && STATE(GPS_FIX_HOME);
|
||||
|
|
|
@ -369,10 +369,6 @@ int8_t navigationGetHeadingControlState(void);
|
|||
// If usedBypass is provided, it will indicate wether any checks
|
||||
// were bypassed due to user input.
|
||||
navArmingBlocker_e navigationIsBlockingArming(bool *usedBypass);
|
||||
// If navigation arming block bypass is used for arming, it's kept
|
||||
// until power off. This allows rearming quickly in case of an
|
||||
// accidentatal mid-air disarm.
|
||||
void navigationSetBlockingArmingBypassWithoutSticks(bool allow);
|
||||
bool navigationPositionEstimateIsHealthy(void);
|
||||
bool navIsCalibrationComplete(void);
|
||||
bool navigationTerrainFollowingEnabled(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue