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)
|
#if defined(USE_NAV)
|
||||||
// Check if we need to make the navigation safety
|
// If nav_extra_arming_safety was bypassed we always
|
||||||
// bypass permanent until power off. See documentation
|
// allow bypassing it even without the sticks set
|
||||||
// for these functions.
|
// in the correct position to allow re-arming quickly
|
||||||
|
// in case of a mid-air accidental disarm.
|
||||||
bool usedBypass = false;
|
bool usedBypass = false;
|
||||||
if (navigationIsBlockingArming(&usedBypass)) {
|
navigationIsBlockingArming(&usedBypass);
|
||||||
navigationSetBlockingArmingBypassWithoutSticks(true);
|
if (usedBypass) {
|
||||||
|
ENABLE_STATE(NAV_EXTRA_ARMING_SAFETY_BYPASSED);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -89,20 +89,21 @@ extern uint32_t flightModeFlags;
|
||||||
#define FLIGHT_MODE(mask) (flightModeFlags & (mask))
|
#define FLIGHT_MODE(mask) (flightModeFlags & (mask))
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GPS_FIX_HOME = (1 << 0),
|
GPS_FIX_HOME = (1 << 0),
|
||||||
GPS_FIX = (1 << 1),
|
GPS_FIX = (1 << 1),
|
||||||
CALIBRATE_MAG = (1 << 2),
|
CALIBRATE_MAG = (1 << 2),
|
||||||
SMALL_ANGLE = (1 << 3),
|
SMALL_ANGLE = (1 << 3),
|
||||||
FIXED_WING = (1 << 4), // set when in flying_wing or airplane mode. currently used by althold selection code
|
FIXED_WING = (1 << 4), // set when in flying_wing or airplane mode. currently used by althold selection code
|
||||||
ANTI_WINDUP = (1 << 5),
|
ANTI_WINDUP = (1 << 5),
|
||||||
FLAPERON_AVAILABLE = (1 << 6),
|
FLAPERON_AVAILABLE = (1 << 6),
|
||||||
NAV_MOTOR_STOP_OR_IDLE = (1 << 7), // navigation requests MOTOR_STOP or motor idle regardless of throttle stick, will only activate if MOTOR_STOP feature is available
|
NAV_MOTOR_STOP_OR_IDLE = (1 << 7), // navigation requests MOTOR_STOP or motor idle regardless of throttle stick, will only activate if MOTOR_STOP feature is available
|
||||||
COMPASS_CALIBRATED = (1 << 8),
|
COMPASS_CALIBRATED = (1 << 8),
|
||||||
ACCELEROMETER_CALIBRATED = (1 << 9),
|
ACCELEROMETER_CALIBRATED = (1 << 9),
|
||||||
PWM_DRIVER_AVAILABLE = (1 << 10),
|
PWM_DRIVER_AVAILABLE = (1 << 10),
|
||||||
NAV_CRUISE_BRAKING = (1 << 11),
|
NAV_CRUISE_BRAKING = (1 << 11),
|
||||||
NAV_CRUISE_BRAKING_BOOST = (1 << 12),
|
NAV_CRUISE_BRAKING_BOOST = (1 << 12),
|
||||||
NAV_CRUISE_BRAKING_LOCKED = (1 << 13),
|
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;
|
} stateFlags_t;
|
||||||
|
|
||||||
#define DISABLE_STATE(mask) (stateFlags &= ~(mask))
|
#define DISABLE_STATE(mask) (stateFlags &= ~(mask))
|
||||||
|
|
|
@ -167,7 +167,6 @@ PG_RESET_TEMPLATE(navConfig_t, navConfig,
|
||||||
|
|
||||||
navigationPosControl_t posControl;
|
navigationPosControl_t posControl;
|
||||||
navSystemStatus_t NAV_Status;
|
navSystemStatus_t NAV_Status;
|
||||||
static bool blockingArmingBypassWithoutSticks;
|
|
||||||
|
|
||||||
#if defined(NAV_BLACKBOX)
|
#if defined(NAV_BLACKBOX)
|
||||||
int16_t navCurrentState;
|
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
|
// 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 ((isUsingNavigationModes() || failsafeMayRequireNavigationMode()) && !((posControl.flags.estPosStatus >= EST_USABLE) && STATE(GPS_FIX_HOME))) {
|
||||||
if (navConfig()->general.flags.extra_arming_safety == NAV_EXTRA_ARMING_SAFETY_ALLOW_BYPASS &&
|
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) {
|
if (usedBypass) {
|
||||||
*usedBypass = true;
|
*usedBypass = true;
|
||||||
}
|
}
|
||||||
|
@ -2967,11 +2966,6 @@ navArmingBlocker_e navigationIsBlockingArming(bool *usedBypass)
|
||||||
return NAV_ARMING_BLOCKER_NONE;
|
return NAV_ARMING_BLOCKER_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void navigationSetBlockingArmingBypassWithoutSticks(bool allow)
|
|
||||||
{
|
|
||||||
blockingArmingBypassWithoutSticks = allow;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool navigationPositionEstimateIsHealthy(void)
|
bool navigationPositionEstimateIsHealthy(void)
|
||||||
{
|
{
|
||||||
return (posControl.flags.estPosStatus >= EST_USABLE) && STATE(GPS_FIX_HOME);
|
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
|
// If usedBypass is provided, it will indicate wether any checks
|
||||||
// were bypassed due to user input.
|
// were bypassed due to user input.
|
||||||
navArmingBlocker_e navigationIsBlockingArming(bool *usedBypass);
|
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 navigationPositionEstimateIsHealthy(void);
|
||||||
bool navIsCalibrationComplete(void);
|
bool navIsCalibrationComplete(void);
|
||||||
bool navigationTerrainFollowingEnabled(void);
|
bool navigationTerrainFollowingEnabled(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue