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

Merge pull request #7218 from mikeller/fix_profile_switching

Fixed PID profile switching.
This commit is contained in:
Michael Keller 2018-12-17 13:28:12 +13:00 committed by GitHub
commit d3a7d8c073
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 76 additions and 86 deletions

View file

@ -128,8 +128,8 @@ static void activateConfig(void)
resetAdjustmentStates();
pidInit(currentPidProfile);
useRcControlsConfig(currentPidProfile);
useAdjustmentConfig(currentPidProfile);
rcControlsInit();
failsafeReset();
setAccelerationTrims(&accelerometerConfigMutable()->accZero);
@ -575,6 +575,8 @@ void changePidProfile(uint8_t pidProfileIndex)
if (pidProfileIndex < MAX_PROFILE_COUNT) {
systemConfigMutable()->pidProfileIndex = pidProfileIndex;
loadPidProfile();
pidInit(currentPidProfile);
}
beeperConfirmationBeeps(pidProfileIndex + 1);

View file

@ -35,12 +35,9 @@
#include "common/maths.h"
#include "common/utils.h"
#include "drivers/time.h"
#include "config/feature.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "pg/rx.h"
#include "drivers/time.h"
#include "flight/pid.h"
@ -51,12 +48,17 @@
#include "fc/config.h"
#include "fc/controlrate_profile.h"
#include "fc/rc_adjustments.h"
#include "fc/rc_controls.h"
#include "fc/rc.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "pg/rx.h"
#include "rx/rx.h"
#include "rc_adjustments.h"
#define ADJUSTMENT_RANGE_COUNT_INVALID -1
PG_REGISTER_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges, PG_ADJUSTMENT_RANGE_CONFIG, 1);
@ -76,8 +78,6 @@ uint8_t pidAudioPositionToModeMap[7] = {
// Note: Last 3 positions are currently pending implementations and use PID_AUDIO_OFF for now.
};
static pidProfile_t *pidProfile;
static int activeAdjustmentCount = ADJUSTMENT_RANGE_COUNT_INVALID;
static uint8_t activeAdjustmentArray[MAX_ADJUSTMENT_RANGE_COUNT];
static int activeAbsoluteAdjustmentCount;
@ -369,8 +369,8 @@ static int applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t a
break;
case ADJUSTMENT_PITCH_ROLL_P:
case ADJUSTMENT_PITCH_P:
newValue = constrain((int)pidProfile->pid[PID_PITCH].P + delta, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_PITCH].P = newValue;
newValue = constrain((int)currentPidProfile->pid[PID_PITCH].P + delta, 0, 200); // FIXME magic numbers repeated in cli.c
currentPidProfile->pid[PID_PITCH].P = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_P, newValue);
if (adjustmentFunction == ADJUSTMENT_PITCH_P) {
@ -379,14 +379,14 @@ static int applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t a
// fall through for combined ADJUSTMENT_PITCH_ROLL_P
FALLTHROUGH;
case ADJUSTMENT_ROLL_P:
newValue = constrain((int)pidProfile->pid[PID_ROLL].P + delta, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_ROLL].P = newValue;
newValue = constrain((int)currentPidProfile->pid[PID_ROLL].P + delta, 0, 200); // FIXME magic numbers repeated in cli.c
currentPidProfile->pid[PID_ROLL].P = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_P, newValue);
break;
case ADJUSTMENT_PITCH_ROLL_I:
case ADJUSTMENT_PITCH_I:
newValue = constrain((int)pidProfile->pid[PID_PITCH].I + delta, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_PITCH].I = newValue;
newValue = constrain((int)currentPidProfile->pid[PID_PITCH].I + delta, 0, 200); // FIXME magic numbers repeated in cli.c
currentPidProfile->pid[PID_PITCH].I = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_I, newValue);
if (adjustmentFunction == ADJUSTMENT_PITCH_I) {
break;
@ -394,14 +394,14 @@ static int applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t a
// fall through for combined ADJUSTMENT_PITCH_ROLL_I
FALLTHROUGH;
case ADJUSTMENT_ROLL_I:
newValue = constrain((int)pidProfile->pid[PID_ROLL].I + delta, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_ROLL].I = newValue;
newValue = constrain((int)currentPidProfile->pid[PID_ROLL].I + delta, 0, 200); // FIXME magic numbers repeated in cli.c
currentPidProfile->pid[PID_ROLL].I = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_I, newValue);
break;
case ADJUSTMENT_PITCH_ROLL_D:
case ADJUSTMENT_PITCH_D:
newValue = constrain((int)pidProfile->pid[PID_PITCH].D + delta, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_PITCH].D = newValue;
newValue = constrain((int)currentPidProfile->pid[PID_PITCH].D + delta, 0, 200); // FIXME magic numbers repeated in cli.c
currentPidProfile->pid[PID_PITCH].D = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_D, newValue);
if (adjustmentFunction == ADJUSTMENT_PITCH_D) {
break;
@ -409,23 +409,23 @@ static int applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t a
// fall through for combined ADJUSTMENT_PITCH_ROLL_D
FALLTHROUGH;
case ADJUSTMENT_ROLL_D:
newValue = constrain((int)pidProfile->pid[PID_ROLL].D + delta, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_ROLL].D = newValue;
newValue = constrain((int)currentPidProfile->pid[PID_ROLL].D + delta, 0, 200); // FIXME magic numbers repeated in cli.c
currentPidProfile->pid[PID_ROLL].D = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_D, newValue);
break;
case ADJUSTMENT_YAW_P:
newValue = constrain((int)pidProfile->pid[PID_YAW].P + delta, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_YAW].P = newValue;
newValue = constrain((int)currentPidProfile->pid[PID_YAW].P + delta, 0, 200); // FIXME magic numbers repeated in cli.c
currentPidProfile->pid[PID_YAW].P = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_P, newValue);
break;
case ADJUSTMENT_YAW_I:
newValue = constrain((int)pidProfile->pid[PID_YAW].I + delta, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_YAW].I = newValue;
newValue = constrain((int)currentPidProfile->pid[PID_YAW].I + delta, 0, 200); // FIXME magic numbers repeated in cli.c
currentPidProfile->pid[PID_YAW].I = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_I, newValue);
break;
case ADJUSTMENT_YAW_D:
newValue = constrain((int)pidProfile->pid[PID_YAW].D + delta, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_YAW].D = newValue;
newValue = constrain((int)currentPidProfile->pid[PID_YAW].D + delta, 0, 200); // FIXME magic numbers repeated in cli.c
currentPidProfile->pid[PID_YAW].D = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_D, newValue);
break;
case ADJUSTMENT_RC_RATE_YAW:
@ -435,8 +435,8 @@ static int applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t a
break;
case ADJUSTMENT_PITCH_ROLL_F:
case ADJUSTMENT_PITCH_F:
newValue = constrain(pidProfile->pid[PID_PITCH].F + delta, 0, 2000);
pidProfile->pid[PID_PITCH].F = newValue;
newValue = constrain(currentPidProfile->pid[PID_PITCH].F + delta, 0, 2000);
currentPidProfile->pid[PID_PITCH].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_F, newValue);
if (adjustmentFunction == ADJUSTMENT_PITCH_F) {
@ -445,18 +445,18 @@ static int applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t a
// fall through for combined ADJUSTMENT_PITCH_ROLL_F
FALLTHROUGH;
case ADJUSTMENT_ROLL_F:
newValue = constrain(pidProfile->pid[PID_ROLL].F + delta, 0, 2000);
pidProfile->pid[PID_ROLL].F = newValue;
newValue = constrain(currentPidProfile->pid[PID_ROLL].F + delta, 0, 2000);
currentPidProfile->pid[PID_ROLL].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_F, newValue);
break;
case ADJUSTMENT_YAW_F:
newValue = constrain(pidProfile->pid[PID_YAW].F + delta, 0, 2000);
pidProfile->pid[PID_YAW].F = newValue;
newValue = constrain(currentPidProfile->pid[PID_YAW].F + delta, 0, 2000);
currentPidProfile->pid[PID_YAW].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_F, newValue);
break;
case ADJUSTMENT_FEEDFORWARD_TRANSITION:
newValue = constrain(pidProfile->feedForwardTransition + delta, 1, 100); // FIXME magic numbers repeated in cli.c
pidProfile->feedForwardTransition = newValue;
newValue = constrain(currentPidProfile->feedForwardTransition + delta, 1, 100); // FIXME magic numbers repeated in cli.c
currentPidProfile->feedForwardTransition = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_FEEDFORWARD_TRANSITION, newValue);
break;
default:
@ -471,7 +471,7 @@ static int applyAbsoluteAdjustment(controlRateConfig_t *controlRateConfig, adjus
{
int newValue;
if ( !controlRateConfig || !pidProfile) {
if ( !controlRateConfig || !currentPidProfile) {
return 0;
}
@ -535,7 +535,7 @@ static int applyAbsoluteAdjustment(controlRateConfig_t *controlRateConfig, adjus
case ADJUSTMENT_PITCH_ROLL_P:
case ADJUSTMENT_PITCH_P:
newValue = constrain(value, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_PITCH].P = newValue;
currentPidProfile->pid[PID_PITCH].P = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_P, newValue);
if (adjustmentFunction == ADJUSTMENT_PITCH_P) {
@ -545,13 +545,13 @@ static int applyAbsoluteAdjustment(controlRateConfig_t *controlRateConfig, adjus
FALLTHROUGH;
case ADJUSTMENT_ROLL_P:
newValue = constrain(value, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_ROLL].P = newValue;
currentPidProfile->pid[PID_ROLL].P = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_P, newValue);
break;
case ADJUSTMENT_PITCH_ROLL_I:
case ADJUSTMENT_PITCH_I:
newValue = constrain(value, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_PITCH].I = newValue;
currentPidProfile->pid[PID_PITCH].I = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_I, newValue);
if (adjustmentFunction == ADJUSTMENT_PITCH_I) {
break;
@ -560,13 +560,13 @@ static int applyAbsoluteAdjustment(controlRateConfig_t *controlRateConfig, adjus
FALLTHROUGH;
case ADJUSTMENT_ROLL_I:
newValue = constrain(value, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_ROLL].I = newValue;
currentPidProfile->pid[PID_ROLL].I = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_I, newValue);
break;
case ADJUSTMENT_PITCH_ROLL_D:
case ADJUSTMENT_PITCH_D:
newValue = constrain(value, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_PITCH].D = newValue;
currentPidProfile->pid[PID_PITCH].D = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_D, newValue);
if (adjustmentFunction == ADJUSTMENT_PITCH_D) {
break;
@ -575,22 +575,22 @@ static int applyAbsoluteAdjustment(controlRateConfig_t *controlRateConfig, adjus
FALLTHROUGH;
case ADJUSTMENT_ROLL_D:
newValue = constrain(value, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_ROLL].D = newValue;
currentPidProfile->pid[PID_ROLL].D = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_D, newValue);
break;
case ADJUSTMENT_YAW_P:
newValue = constrain(value, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_YAW].P = newValue;
currentPidProfile->pid[PID_YAW].P = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_P, newValue);
break;
case ADJUSTMENT_YAW_I:
newValue = constrain(value, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_YAW].I = newValue;
currentPidProfile->pid[PID_YAW].I = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_I, newValue);
break;
case ADJUSTMENT_YAW_D:
newValue = constrain(value, 0, 200); // FIXME magic numbers repeated in cli.c
pidProfile->pid[PID_YAW].D = newValue;
currentPidProfile->pid[PID_YAW].D = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_D, newValue);
break;
case ADJUSTMENT_RC_RATE_YAW:
@ -601,7 +601,7 @@ static int applyAbsoluteAdjustment(controlRateConfig_t *controlRateConfig, adjus
case ADJUSTMENT_PITCH_ROLL_F:
case ADJUSTMENT_PITCH_F:
newValue = constrain(value, 0, 2000);
pidProfile->pid[PID_PITCH].F = newValue;
currentPidProfile->pid[PID_PITCH].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_F, newValue);
if (adjustmentFunction == ADJUSTMENT_PITCH_F) {
@ -611,17 +611,17 @@ static int applyAbsoluteAdjustment(controlRateConfig_t *controlRateConfig, adjus
FALLTHROUGH;
case ADJUSTMENT_ROLL_F:
newValue = constrain(value, 0, 2000);
pidProfile->pid[PID_ROLL].F = newValue;
currentPidProfile->pid[PID_ROLL].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_F, newValue);
break;
case ADJUSTMENT_YAW_F:
newValue = constrain(value, 0, 2000);
pidProfile->pid[PID_YAW].F = newValue;
currentPidProfile->pid[PID_YAW].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_F, newValue);
break;
case ADJUSTMENT_FEEDFORWARD_TRANSITION:
newValue = constrain(value, 1, 100); // FIXME magic numbers repeated in cli.c
pidProfile->feedForwardTransition = newValue;
currentPidProfile->feedForwardTransition = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_FEEDFORWARD_TRANSITION, newValue);
break;
default:
@ -648,9 +648,9 @@ static uint8_t applySelectAdjustment(adjustmentFunction_e adjustmentFunction, ui
case ADJUSTMENT_HORIZON_STRENGTH:
{
uint8_t newValue = constrain(position, 0, 200); // FIXME magic numbers repeated in serial_cli.c
if (pidProfile->pid[PID_LEVEL].D != newValue) {
beeps = ((newValue - pidProfile->pid[PID_LEVEL].D) / 8) + 1;
pidProfile->pid[PID_LEVEL].D = newValue;
if (currentPidProfile->pid[PID_LEVEL].D != newValue) {
beeps = ((newValue - currentPidProfile->pid[PID_LEVEL].D) / 8) + 1;
currentPidProfile->pid[PID_LEVEL].D = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_HORIZON_STRENGTH, position);
}
}
@ -777,7 +777,7 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig)
}
newValue = applyStepAdjustment(controlRateConfig, adjustmentFunction, delta);
pidInitConfig(pidProfile);
pidInitConfig(currentPidProfile);
} else if (adjustmentState->config->mode == ADJUSTMENT_MODE_SELECT) {
int switchPositions = adjustmentState->config->data.switchPositions;
if (adjustmentFunction == ADJUSTMENT_RATE_PROFILE && systemConfig()->rateProfile6PosSwitch) {
@ -821,7 +821,7 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig)
lastRcData[index] = rcData[channelIndex];
applyAbsoluteAdjustment(controlRateConfig, adjustmentConfig->adjustmentFunction, value);
pidInitConfig(pidProfile);
pidInitConfig(currentPidProfile);
}
}
}
@ -831,11 +831,6 @@ void resetAdjustmentStates(void)
memset(adjustmentStates, 0, sizeof(adjustmentStates));
}
void useAdjustmentConfig(pidProfile_t *pidProfileToUse)
{
pidProfile = pidProfileToUse;
}
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
const char *getAdjustmentsRangeName(void)
{

View file

@ -112,8 +112,6 @@ typedef struct adjustmentState_s {
void resetAdjustmentStates(void);
struct controlRateConfig_s;
void processRcAdjustments(struct controlRateConfig_s *controlRateConfig);
struct pidProfile_s;
void useAdjustmentConfig(struct pidProfile_s *pidProfileToUse);
const char *getAdjustmentsRangeName(void);
int getAdjustmentsRangeValue(void);
void activeAdjustmentRangeReset(void);

View file

@ -66,8 +66,6 @@
#include "flight/pid.h"
#include "flight/failsafe.h"
static pidProfile_t *pidProfile;
// true if arming is done via the sticks (as opposed to a switch)
static bool isUsingSticksToArm = true;
@ -392,9 +390,7 @@ int32_t getRcStickDeflection(int32_t axis, uint16_t midrc) {
return MIN(ABS(rcData[axis] - midrc), 500);
}
void useRcControlsConfig(pidProfile_t *pidProfileToUse)
void rcControlsInit(void)
{
pidProfile = pidProfileToUse;
isUsingSticksToArm = !isModeActivationConditionPresent(BOXARM);
}

View file

@ -169,6 +169,4 @@ void processRcStickPositions();
bool isUsingSticksForArming(void);
int32_t getRcStickDeflection(int32_t axis, uint16_t midrc);
struct pidProfile_s;
struct modeActivationCondition_s;
void useRcControlsConfig(struct pidProfile_s *pidProfileToUse);
void rcControlsInit(void);

View file

@ -1608,7 +1608,7 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
mac->range.startStep = sbufReadU8(src);
mac->range.endStep = sbufReadU8(src);
useRcControlsConfig(currentPidProfile);
rcControlsInit();
} else {
return MSP_RESULT_ERROR;
}

View file

@ -494,7 +494,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
mac->range.startStep = bstRead8();
mac->range.endStep = bstRead8();
useRcControlsConfig(currentPidProfile);
rcControlsInit();
} else {
ret = BST_FAILED;
}

View file

@ -93,7 +93,7 @@ TEST(ArmingPreventionTest, CalibrationPowerOnGraceAngleThrottleArmSwitch)
modeActivationConditionsMutable(0)->modeId = BOXARM;
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -183,7 +183,7 @@ TEST(ArmingPreventionTest, ArmingGuardRadioLeftOnAndArmed)
modeActivationConditionsMutable(0)->modeId = BOXARM;
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -261,7 +261,7 @@ TEST(ArmingPreventionTest, Prearm)
modeActivationConditionsMutable(1)->modeId = BOXPREARM;
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -304,7 +304,7 @@ TEST(ArmingPreventionTest, RadioTurnedOnAtAnyTimeArmed)
modeActivationConditionsMutable(0)->modeId = BOXARM;
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -370,7 +370,7 @@ TEST(ArmingPreventionTest, In3DModeAllowArmingWhenEnteringThrottleDeadband)
modeActivationConditionsMutable(0)->modeId = BOXARM;
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->midrc = 1500;
@ -437,7 +437,7 @@ TEST(ArmingPreventionTest, When3DModeDisabledThenNormalThrottleArmingConditionAp
modeActivationConditionsMutable(1)->modeId = BOX3D;
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -538,7 +538,7 @@ TEST(ArmingPreventionTest, WhenUsingSwitched3DModeThenNormalThrottleArmingCondit
modeActivationConditionsMutable(1)->modeId = BOX3D;
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -632,7 +632,7 @@ TEST(ArmingPreventionTest, Rescue)
modeActivationConditionsMutable(1)->modeId = BOXGPSRESCUE;
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -744,7 +744,7 @@ TEST(ArmingPreventionTest, ParalyzeOnAtBoot)
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);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -794,7 +794,7 @@ TEST(ArmingPreventionTest, Paralyze)
modeActivationConditionsMutable(2)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
modeActivationConditionsMutable(3)->modeId = BOXVTXPITMODE;
modeActivationConditionsMutable(3)->linkedTo = BOXPARALYZE;
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;

View file

@ -566,7 +566,6 @@ TEST_F(RcControlsAdjustmentsTest, processPIDIncreasePidController0)
pidProfile.pid[PID_YAW].P = 7;
pidProfile.pid[PID_YAW].I = 17;
pidProfile.pid[PID_YAW].D = 27;
useAdjustmentConfig(&pidProfile);
// and
controlRateConfig_t controlRateConfig;
memset(&controlRateConfig, 0, sizeof (controlRateConfig));
@ -602,7 +601,8 @@ TEST_F(RcControlsAdjustmentsTest, processPIDIncreasePidController0)
(1 << 5);
// when
useRcControlsConfig(&pidProfile);
currentPidProfile = &pidProfile;
rcControlsInit();
processRcAdjustments(&controlRateConfig);
// then
@ -638,7 +638,6 @@ TEST_F(RcControlsAdjustmentsTest, processPIDIncreasePidController2)
pidProfile.D_f[PIDPITCH] = 20.0f;
pidProfile.D_f[PIDROLL] = 25.0f;
pidProfile.D_f[PIDYAW] = 27.0f;
useAdjustmentConfig(&pidProfile);
// and
controlRateConfig_t controlRateConfig;
@ -675,7 +674,8 @@ TEST_F(RcControlsAdjustmentsTest, processPIDIncreasePidController2)
(1 << 5);
// when
useRcControlsConfig(&escAndServoConfig, &pidProfile);
currentPidProfile = &pidProfile;
rcControlsInit();
processRcAdjustments(&controlRateConfig, &rxConfig);
// then
@ -733,6 +733,7 @@ uint16_t flightModeFlags = 0;
int16_t heading;
uint8_t stateFlags = 0;
int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT];
pidProfile_t *currentPidProfile;
rxRuntimeConfig_t rxRuntimeConfig;
PG_REGISTER(blackboxConfig_t, blackboxConfig, PG_BLACKBOX_CONFIG, 0);
PG_REGISTER(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 2);