mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Add guard time between dshot beacon and arming/disarming
Tries to prevent DSHOT beacon commands from interfering with commands to set the motor direction. Adds a 2 second delay after disarming before DSHOT beacon commands will be sent. This attempts to prevent the beacon commands from interfering with the motor direction reset that happens after using crash flip mode. During arming if a DSHOT beacon command has been sent within 2 seconds the arming will be delayed until the 2 seconds have passed. This attempts to prevent interference with the motor direction commands sent at arming.
This commit is contained in:
parent
504b1479fb
commit
1e6e9e719f
6 changed files with 62 additions and 1 deletions
|
@ -135,6 +135,8 @@ 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;
|
||||
|
||||
#ifdef USE_RUNAWAY_TAKEOFF
|
||||
static timeUs_t runawayTakeoffDeactivateUs = 0;
|
||||
|
@ -318,6 +320,7 @@ void disarm(void)
|
|||
{
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
DISABLE_ARMING_FLAG(ARMED);
|
||||
lastDisarmTimeUs = micros();
|
||||
|
||||
#ifdef USE_BLACKBOX
|
||||
if (blackboxConfig()->device && blackboxConfig()->mode != BLACKBOX_MODE_ALWAYS_ON) { // Close the log upon disarm except when logging mode is ALWAYS ON
|
||||
|
@ -353,6 +356,10 @@ void tryArm(void)
|
|||
return;
|
||||
}
|
||||
#ifdef USE_DSHOT
|
||||
if (micros() - getLastDshotBeaconCommandTimeUs() < DSHOT_BEACON_GUARD_DELAY_US) {
|
||||
tryingToArm = true;
|
||||
return;
|
||||
}
|
||||
if (isMotorProtocolDshot() && isModeActivationConditionPresent(BOXFLIPOVERAFTERCRASH)) {
|
||||
if (!IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) {
|
||||
flipOverAfterCrashMode = false;
|
||||
|
@ -374,6 +381,8 @@ void tryArm(void)
|
|||
ENABLE_ARMING_FLAG(ARMED);
|
||||
ENABLE_ARMING_FLAG(WAS_EVER_ARMED);
|
||||
|
||||
resetTryingToArm();
|
||||
|
||||
#ifdef USE_ACRO_TRAINER
|
||||
pidAcroTrainerInit();
|
||||
#endif // USE_ACRO_TRAINER
|
||||
|
@ -404,6 +413,7 @@ void tryArm(void)
|
|||
runawayTakeoffTriggerUs = 0;
|
||||
#endif
|
||||
} else {
|
||||
resetTryingToArm();
|
||||
if (!isFirstArmingGyroCalibrationRunning()) {
|
||||
int armingDisabledReason = ffs(getArmingDisableFlags());
|
||||
if (lastArmingDisabledReason != armingDisabledReason) {
|
||||
|
@ -1031,3 +1041,19 @@ bool isFlipOverAfterCrashMode(void)
|
|||
{
|
||||
return flipOverAfterCrashMode;
|
||||
}
|
||||
|
||||
timeUs_t getLastDisarmTimeUs(void)
|
||||
{
|
||||
return lastDisarmTimeUs;
|
||||
}
|
||||
|
||||
bool isTryingToArm()
|
||||
{
|
||||
return tryingToArm;
|
||||
}
|
||||
|
||||
void resetTryingToArm()
|
||||
{
|
||||
tryingToArm = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue