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

Allow linking of modes

This allows modes to be linked, for example to link vtx pit mode to paralyze. Whenever paralyze is activated, vtx pit mode is activated as well. Also the logic to prevent mode changes when enabling paralyze can be removed in favor of making paralyze sticky.

Modes can be linked in CLI by providing the mode id as the last parameter of the aux command. For example in order to link vtx pit mode to paralyze, replace the last 0 of the pit mode aux (39) with the mode id of paralyze (45):

```
aux 2 39 2 1700 2100 0 0
```

becomes

```
aux 2 39 2 1700 2100 0 45
```

_Legal disclaimer: I am making my contributions/submissions to this project solely in my personal capacity and am not conveying any rights to any intellectual property of any third parties._
This commit is contained in:
Robert Lacroix 2018-07-11 12:04:11 +02:00
parent ac2f39a10c
commit aa18ab4afa
7 changed files with 130 additions and 58 deletions

View file

@ -612,6 +612,50 @@ TEST(ArmingPreventionTest, WhenUsingSwitched3DModeThenNormalThrottleArmingCondit
EXPECT_EQ(0, getArmingDisableFlags());
}
TEST(ArmingPreventionTest, ParalyzeOnAtBoot)
{
// given
simulationFeatureFlags = 0;
simulationTime = 30e6; // 30 seconds after boot
gyroCalibDone = true;
// and
modeActivationConditionsMutable(0)->auxChannelIndex = 0;
modeActivationConditionsMutable(0)->modeId = BOXARM;
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
modeActivationConditionsMutable(1)->auxChannelIndex = 1;
modeActivationConditionsMutable(1)->modeId = BOXPARALYZE;
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
// and
rxConfigMutable()->mincheck = 1050;
// given
rcData[THROTTLE] = 1000;
rcData[AUX1] = 1000;
rcData[AUX2] = 1800; // Paralyze on at boot
ENABLE_STATE(SMALL_ANGLE);
// when
updateActivatedModes();
updateArmingStatus();
// expect
EXPECT_FALSE(ARMING_FLAG(ARMED));
EXPECT_FALSE(isArmingDisabled());
EXPECT_EQ(0, getArmingDisableFlags());
EXPECT_FALSE(IS_RC_MODE_ACTIVE(BOXPARALYZE));
// when
updateActivatedModes();
// expect
EXPECT_FALSE(IS_RC_MODE_ACTIVE(BOXPARALYZE));
}
TEST(ArmingPreventionTest, Paralyze)
{
// given
@ -632,10 +676,8 @@ TEST(ArmingPreventionTest, Paralyze)
modeActivationConditionsMutable(2)->modeId = BOXBEEPERON;
modeActivationConditionsMutable(2)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(2)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
modeActivationConditionsMutable(3)->auxChannelIndex = 3;
modeActivationConditionsMutable(3)->modeId = BOXVTXPITMODE;
modeActivationConditionsMutable(3)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(3)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
modeActivationConditionsMutable(3)->linkedTo = BOXPARALYZE;
useRcControlsConfig(NULL);
// and
@ -646,7 +688,6 @@ TEST(ArmingPreventionTest, Paralyze)
rcData[AUX1] = 1000;
rcData[AUX2] = 1000;
rcData[AUX3] = 1000;
rcData[AUX4] = 1000;
ENABLE_STATE(SMALL_ANGLE);
// when
@ -687,9 +728,8 @@ TEST(ArmingPreventionTest, Paralyze)
EXPECT_EQ(0, getArmingDisableFlags());
// given
// paraylze and enter pit mode
// paralyze (and activate linked vtx pit mode)
rcData[AUX2] = 1800;
rcData[AUX4] = 1800;
// when
updateActivatedModes();
@ -701,12 +741,8 @@ TEST(ArmingPreventionTest, Paralyze)
EXPECT_TRUE(IS_RC_MODE_ACTIVE(BOXVTXPITMODE));
EXPECT_FALSE(IS_RC_MODE_ACTIVE(BOXBEEPERON));
// and
preventModeChanges();
// given
// Try exiting pit mode and enable beeper
rcData[AUX4] = 1000;
// enable beeper
rcData[AUX3] = 1800;
// when
@ -717,7 +753,7 @@ TEST(ArmingPreventionTest, Paralyze)
EXPECT_TRUE(IS_RC_MODE_ACTIVE(BOXBEEPERON));
// given
// exit paralyze mode and ensure arming is still disabled
// try exiting paralyze mode and ensure arming and pit mode are still disabled
rcData[AUX2] = 1000;
// when
@ -727,6 +763,8 @@ TEST(ArmingPreventionTest, Paralyze)
// expect
EXPECT_TRUE(isArmingDisabled());
EXPECT_EQ(ARMING_DISABLED_PARALYZE, getArmingDisableFlags());
EXPECT_TRUE(IS_RC_MODE_ACTIVE(BOXPARALYZE));
EXPECT_TRUE(IS_RC_MODE_ACTIVE(BOXVTXPITMODE));
}
// STUBS