Capture and use crash flip if set initially when arming is delayed due to beacon
Previously if arming was delayed due to DSHOT beacon then the arming type (normal or crash-flip) would be captured *after* the delay. This change captures the state on entering the delay which more accurately represents the pilot's intent. For example, the pilot may have crash-flip on a momentary switch that's initially set when the arming switch is enabled. Previously if the pilot didn't hold the momentary switch through the entire delay the quad would arm in normal mode. This change uses the state when the arming switch first enables so even if the momentary crash-flip switch is released the quad will still arm in crash-flip mode.
This commit is contained in:
parent
efb340f4c6
commit
3dae764b0e
|
@ -98,6 +98,11 @@ enum {
|
|||
ALIGN_MAG = 2
|
||||
};
|
||||
|
||||
enum {
|
||||
ARMING_DELAYED_DISARMED = 0,
|
||||
ARMING_DELAYED_NORMAL = 1,
|
||||
ARMING_DELAYED_CRASHFLIP = 2
|
||||
};
|
||||
|
||||
#define GYRO_WATCHDOG_DELAY 80 // delay for gyro sync
|
||||
|
||||
|
@ -130,7 +135,7 @@ static uint32_t disarmAt; // Time of automatic disarm when "Don't spin the m
|
|||
bool isRXDataNew;
|
||||
static int lastArmingDisabledReason = 0;
|
||||
static timeUs_t lastDisarmTimeUs;
|
||||
static bool tryingToArm;
|
||||
static int tryingToArm = ARMING_DELAYED_DISARMED;
|
||||
|
||||
#ifdef USE_RUNAWAY_TAKEOFF
|
||||
static timeUs_t runawayTakeoffDeactivateUs = 0;
|
||||
|
@ -335,11 +340,17 @@ void tryArm(void)
|
|||
}
|
||||
#ifdef USE_DSHOT
|
||||
if (micros() - getLastDshotBeaconCommandTimeUs() < DSHOT_BEACON_GUARD_DELAY_US) {
|
||||
tryingToArm = true;
|
||||
if (tryingToArm == ARMING_DELAYED_DISARMED) {
|
||||
if (isModeActivationConditionPresent(BOXFLIPOVERAFTERCRASH) && IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) {
|
||||
tryingToArm = ARMING_DELAYED_CRASHFLIP;
|
||||
} else {
|
||||
tryingToArm = ARMING_DELAYED_NORMAL;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isMotorProtocolDshot() && isModeActivationConditionPresent(BOXFLIPOVERAFTERCRASH)) {
|
||||
if (!IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) {
|
||||
if (!(IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH) || (tryingToArm == ARMING_DELAYED_CRASHFLIP))) {
|
||||
flipOverAfterCrashMode = false;
|
||||
if (!feature(FEATURE_3D)) {
|
||||
pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_SPIN_DIRECTION_NORMAL, false);
|
||||
|
@ -1025,10 +1036,10 @@ timeUs_t getLastDisarmTimeUs(void)
|
|||
|
||||
bool isTryingToArm()
|
||||
{
|
||||
return tryingToArm;
|
||||
return (tryingToArm != ARMING_DELAYED_DISARMED);
|
||||
}
|
||||
|
||||
void resetTryingToArm()
|
||||
{
|
||||
tryingToArm = false;
|
||||
tryingToArm = ARMING_DELAYED_DISARMED;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue