Merge pull request #1851 from martinbudden/bf_config_arrays
Added adjustmentProfile() and modeActivationProfile() macros
This commit is contained in:
commit
c2af22c4f1
|
@ -820,7 +820,7 @@ void startBlackbox(void)
|
|||
*/
|
||||
blackboxBuildConditionCache();
|
||||
|
||||
blackboxModeActivationConditionPresent = isModeActivationConditionPresent(masterConfig.modeActivationConditions, BOXBLACKBOX);
|
||||
blackboxModeActivationConditionPresent = isModeActivationConditionPresent(modeActivationProfile()->modeActivationConditions, BOXBLACKBOX);
|
||||
|
||||
blackboxIteration = 0;
|
||||
blackboxPFrameIndex = 0;
|
||||
|
|
|
@ -99,6 +99,8 @@
|
|||
#define blackboxConfig(x) (&masterConfig.blackboxConfig)
|
||||
#define flashConfig(x) (&masterConfig.flashConfig)
|
||||
#define pidConfig(x) (&masterConfig.pidConfig)
|
||||
#define adjustmentProfile(x) (&masterConfig.adjustmentProfile)
|
||||
#define modeActivationProfile(x) (&masterConfig.modeActivationProfile)
|
||||
|
||||
|
||||
// System-wide
|
||||
|
@ -215,9 +217,8 @@ typedef struct master_s {
|
|||
profile_t profile[MAX_PROFILE_COUNT];
|
||||
uint8_t current_profile_index;
|
||||
|
||||
modeActivationCondition_t modeActivationConditions[MAX_MODE_ACTIVATION_CONDITION_COUNT];
|
||||
adjustmentRange_t adjustmentRanges[MAX_ADJUSTMENT_RANGE_COUNT];
|
||||
|
||||
modeActivationProfile_t modeActivationProfile;
|
||||
adjustmentProfile_t adjustmentProfile;
|
||||
#ifdef VTX
|
||||
uint8_t vtx_band; //1=A, 2=B, 3=E, 4=F(Airwaves/Fatshark), 5=Raceband
|
||||
uint8_t vtx_channel; //1-8
|
||||
|
|
|
@ -882,7 +882,7 @@ void activateConfig(void)
|
|||
resetAdjustmentStates();
|
||||
|
||||
useRcControlsConfig(
|
||||
masterConfig.modeActivationConditions,
|
||||
modeActivationProfile()->modeActivationConditions,
|
||||
&masterConfig.motorConfig,
|
||||
¤tProfile->pidProfile
|
||||
);
|
||||
|
|
|
@ -797,7 +797,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
|
||||
case MSP_MODE_RANGES:
|
||||
for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||
const box_t *box = &boxes[mac->modeId];
|
||||
sbufWriteU8(dst, box->permanentId);
|
||||
sbufWriteU8(dst, mac->auxChannelIndex);
|
||||
|
@ -808,7 +808,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
|
||||
case MSP_ADJUSTMENT_RANGES:
|
||||
for (int i = 0; i < MAX_ADJUSTMENT_RANGE_COUNT; i++) {
|
||||
adjustmentRange_t *adjRange = &masterConfig.adjustmentRanges[i];
|
||||
adjustmentRange_t *adjRange = &adjustmentProfile()->adjustmentRanges[i];
|
||||
sbufWriteU8(dst, adjRange->adjustmentIndex);
|
||||
sbufWriteU8(dst, adjRange->auxChannelIndex);
|
||||
sbufWriteU8(dst, adjRange->range.startStep);
|
||||
|
@ -1316,7 +1316,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
case MSP_SET_MODE_RANGE:
|
||||
i = sbufReadU8(src);
|
||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||
i = sbufReadU8(src);
|
||||
const box_t *box = findBoxByPermenantId(i);
|
||||
if (box) {
|
||||
|
@ -1325,7 +1325,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
mac->range.startStep = sbufReadU8(src);
|
||||
mac->range.endStep = sbufReadU8(src);
|
||||
|
||||
useRcControlsConfig(masterConfig.modeActivationConditions, &masterConfig.motorConfig, ¤tProfile->pidProfile);
|
||||
useRcControlsConfig(modeActivationProfile()->modeActivationConditions, &masterConfig.motorConfig, ¤tProfile->pidProfile);
|
||||
} else {
|
||||
return MSP_RESULT_ERROR;
|
||||
}
|
||||
|
@ -1337,7 +1337,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
case MSP_SET_ADJUSTMENT_RANGE:
|
||||
i = sbufReadU8(src);
|
||||
if (i < MAX_ADJUSTMENT_RANGE_COUNT) {
|
||||
adjustmentRange_t *adjRange = &masterConfig.adjustmentRanges[i];
|
||||
adjustmentRange_t *adjRange = &adjustmentProfile()->adjustmentRanges[i];
|
||||
i = sbufReadU8(src);
|
||||
if (i < MAX_SIMULTANEOUS_ADJUSTMENT_COUNT) {
|
||||
adjRange->adjustmentIndex = i;
|
||||
|
|
|
@ -576,11 +576,11 @@ void processRx(timeUs_t currentTimeUs)
|
|||
updateInflightCalibrationState();
|
||||
}
|
||||
|
||||
updateActivatedModes(masterConfig.modeActivationConditions);
|
||||
updateActivatedModes(modeActivationProfile()->modeActivationConditions);
|
||||
|
||||
if (!cliMode) {
|
||||
updateAdjustmentStates(masterConfig.adjustmentRanges);
|
||||
processRcAdjustments(currentControlRateProfile, &masterConfig.rxConfig);
|
||||
updateAdjustmentStates(adjustmentProfile()->adjustmentRanges);
|
||||
processRcAdjustments(currentControlRateProfile, rxConfig());
|
||||
}
|
||||
|
||||
bool canUseHorizonMode = true;
|
||||
|
|
|
@ -140,6 +140,10 @@ typedef struct modeActivationCondition_s {
|
|||
channelRange_t range;
|
||||
} modeActivationCondition_t;
|
||||
|
||||
typedef struct modeActivationProfile_s {
|
||||
modeActivationCondition_t modeActivationConditions[MAX_MODE_ACTIVATION_CONDITION_COUNT];
|
||||
} modeActivationProfile_t;
|
||||
|
||||
#define IS_RANGE_USABLE(range) ((range)->startStep < (range)->endStep)
|
||||
|
||||
typedef struct controlRateConfig_s {
|
||||
|
@ -263,6 +267,10 @@ typedef struct adjustmentState_s {
|
|||
|
||||
#define MAX_ADJUSTMENT_RANGE_COUNT 15
|
||||
|
||||
typedef struct adjustmentProfile_s {
|
||||
adjustmentRange_t adjustmentRanges[MAX_ADJUSTMENT_RANGE_COUNT];
|
||||
} adjustmentProfile_t;
|
||||
|
||||
bool isAirmodeActive(void);
|
||||
void resetAdjustmentStates(void);
|
||||
void updateAdjustmentStates(adjustmentRange_t *adjustmentRanges);
|
||||
|
|
|
@ -1216,8 +1216,8 @@ static void printAux(uint8_t dumpMask, master_t *defaultConfig)
|
|||
modeActivationCondition_t *macDefault;
|
||||
bool equalsDefault;
|
||||
for (uint32_t i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
mac = &masterConfig.modeActivationConditions[i];
|
||||
macDefault = &defaultConfig->modeActivationConditions[i];
|
||||
mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||
macDefault = &defaultConfig->modeActivationProfile.modeActivationConditions[i];
|
||||
equalsDefault = mac->modeId == macDefault->modeId
|
||||
&& mac->auxChannelIndex == macDefault->auxChannelIndex
|
||||
&& mac->range.startStep == macDefault->range.startStep
|
||||
|
@ -1251,7 +1251,7 @@ static void cliAux(char *cmdline)
|
|||
ptr = cmdline;
|
||||
i = atoi(ptr++);
|
||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||
uint8_t validArgumentCount = 0;
|
||||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
|
@ -1485,8 +1485,8 @@ static void printAdjustmentRange(uint8_t dumpMask, master_t *defaultConfig)
|
|||
adjustmentRange_t *arDefault;
|
||||
bool equalsDefault;
|
||||
for (uint32_t i = 0; i < MAX_ADJUSTMENT_RANGE_COUNT; i++) {
|
||||
ar = &masterConfig.adjustmentRanges[i];
|
||||
arDefault = &defaultConfig->adjustmentRanges[i];
|
||||
ar = &adjustmentProfile()->adjustmentRanges[i];
|
||||
arDefault = &defaultConfig->adjustmentProfile.adjustmentRanges[i];
|
||||
equalsDefault = ar->auxChannelIndex == arDefault->auxChannelIndex
|
||||
&& ar->range.startStep == arDefault->range.startStep
|
||||
&& ar->range.endStep == arDefault->range.endStep
|
||||
|
@ -1526,7 +1526,7 @@ static void cliAdjustmentRange(char *cmdline)
|
|||
ptr = cmdline;
|
||||
i = atoi(ptr++);
|
||||
if (i < MAX_ADJUSTMENT_RANGE_COUNT) {
|
||||
adjustmentRange_t *ar = &masterConfig.adjustmentRanges[i];
|
||||
adjustmentRange_t *ar = &adjustmentProfile()->adjustmentRanges[i];
|
||||
uint8_t validArgumentCount = 0;
|
||||
|
||||
ptr = nextArg(ptr);
|
||||
|
|
|
@ -441,7 +441,7 @@ void init(void)
|
|||
|
||||
failsafeInit(rxConfig(), flight3DConfig()->deadband3d_throttle);
|
||||
|
||||
rxInit(rxConfig(), masterConfig.modeActivationConditions);
|
||||
rxInit(rxConfig(), modeActivationProfile()->modeActivationConditions);
|
||||
|
||||
#ifdef GPS
|
||||
if (feature(FEATURE_GPS)) {
|
||||
|
|
|
@ -720,7 +720,7 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
|||
break;
|
||||
case BST_MODE_RANGES:
|
||||
for (i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||
const box_t *box = &boxes[mac->modeId];
|
||||
bstWrite8(box->permanentId);
|
||||
bstWrite8(mac->auxChannelIndex);
|
||||
|
@ -730,7 +730,7 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
|||
break;
|
||||
case BST_ADJUSTMENT_RANGES:
|
||||
for (i = 0; i < MAX_ADJUSTMENT_RANGE_COUNT; i++) {
|
||||
adjustmentRange_t *adjRange = &masterConfig.adjustmentRanges[i];
|
||||
adjustmentRange_t *adjRange = &adjustmentProfile()->adjustmentRanges[i];
|
||||
bstWrite8(adjRange->adjustmentIndex);
|
||||
bstWrite8(adjRange->auxChannelIndex);
|
||||
bstWrite8(adjRange->range.startStep);
|
||||
|
@ -1056,7 +1056,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
|||
case BST_SET_MODE_RANGE:
|
||||
i = bstRead8();
|
||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||
i = bstRead8();
|
||||
const box_t *box = findBoxByPermenantId(i);
|
||||
if (box) {
|
||||
|
@ -1065,7 +1065,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
|||
mac->range.startStep = bstRead8();
|
||||
mac->range.endStep = bstRead8();
|
||||
|
||||
useRcControlsConfig(masterConfig.modeActivationConditions, &masterConfig.motorConfig, ¤tProfile->pidProfile);
|
||||
useRcControlsConfig(modeActivationProfile()->modeActivationConditions, &masterConfig.motorConfig, ¤tProfile->pidProfile);
|
||||
} else {
|
||||
ret = BST_FAILED;
|
||||
}
|
||||
|
@ -1076,7 +1076,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
|||
case BST_SET_ADJUSTMENT_RANGE:
|
||||
i = bstRead8();
|
||||
if (i < MAX_ADJUSTMENT_RANGE_COUNT) {
|
||||
adjustmentRange_t *adjRange = &masterConfig.adjustmentRanges[i];
|
||||
adjustmentRange_t *adjRange = &adjustmentProfile()->adjustmentRanges[i];
|
||||
i = bstRead8();
|
||||
if (i < MAX_SIMULTANEOUS_ADJUSTMENT_COUNT) {
|
||||
adjRange->adjustmentIndex = i;
|
||||
|
|
|
@ -57,14 +57,14 @@ void targetConfiguration(master_t *config)
|
|||
config->rcControlsConfig.yaw_deadband = 2;
|
||||
config->rcControlsConfig.deadband = 2;
|
||||
|
||||
config->modeActivationConditions[0].modeId = BOXANGLE;
|
||||
config->modeActivationConditions[0].auxChannelIndex = AUX1 - NON_AUX_CHANNEL_COUNT;
|
||||
config->modeActivationConditions[0].range.startStep = CHANNEL_VALUE_TO_STEP(900);
|
||||
config->modeActivationConditions[0].range.endStep = CHANNEL_VALUE_TO_STEP(1400);
|
||||
config->modeActivationConditions[1].modeId = BOXHORIZON;
|
||||
config->modeActivationConditions[1].auxChannelIndex = AUX1 - NON_AUX_CHANNEL_COUNT;
|
||||
config->modeActivationConditions[1].range.startStep = CHANNEL_VALUE_TO_STEP(1425);
|
||||
config->modeActivationConditions[1].range.endStep = CHANNEL_VALUE_TO_STEP(1575);
|
||||
config->modeActivationProfile.modeActivationConditions[0].modeId = BOXANGLE;
|
||||
config->modeActivationProfile.modeActivationConditions[0].auxChannelIndex = AUX1 - NON_AUX_CHANNEL_COUNT;
|
||||
config->modeActivationProfile.modeActivationConditions[0].range.startStep = CHANNEL_VALUE_TO_STEP(900);
|
||||
config->modeActivationProfile.modeActivationConditions[0].range.endStep = CHANNEL_VALUE_TO_STEP(1400);
|
||||
config->modeActivationProfile.modeActivationConditions[1].modeId = BOXHORIZON;
|
||||
config->modeActivationProfile.modeActivationConditions[1].auxChannelIndex = AUX1 - NON_AUX_CHANNEL_COUNT;
|
||||
config->modeActivationProfile.modeActivationConditions[1].range.startStep = CHANNEL_VALUE_TO_STEP(1425);
|
||||
config->modeActivationProfile.modeActivationConditions[1].range.endStep = CHANNEL_VALUE_TO_STEP(1575);
|
||||
|
||||
config->failsafeConfig.failsafe_delay = 2;
|
||||
config->failsafeConfig.failsafe_off_delay = 0;
|
||||
|
|
Loading…
Reference in New Issue