diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index bf1e6dc20..b81e509f8 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -820,7 +820,7 @@ void startBlackbox(void) */ blackboxBuildConditionCache(); - blackboxModeActivationConditionPresent = isModeActivationConditionPresent(masterConfig.modeActivationConditions, BOXBLACKBOX); + blackboxModeActivationConditionPresent = isModeActivationConditionPresent(modeActivationProfile()->modeActivationConditions, BOXBLACKBOX); blackboxIteration = 0; blackboxPFrameIndex = 0; diff --git a/src/main/config/config_master.h b/src/main/config/config_master.h index 4a03ff0ec..bedfe58a3 100644 --- a/src/main/config/config_master.h +++ b/src/main/config/config_master.h @@ -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 diff --git a/src/main/fc/config.c b/src/main/fc/config.c index d597fc128..54bdc3bd1 100755 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -882,7 +882,7 @@ void activateConfig(void) resetAdjustmentStates(); useRcControlsConfig( - masterConfig.modeActivationConditions, + modeActivationProfile()->modeActivationConditions, &masterConfig.motorConfig, ¤tProfile->pidProfile ); diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 79c01a047..50c401564 100755 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -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; diff --git a/src/main/fc/mw.c b/src/main/fc/mw.c index cfcf30fd2..5d6c83498 100644 --- a/src/main/fc/mw.c +++ b/src/main/fc/mw.c @@ -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; diff --git a/src/main/fc/rc_controls.h b/src/main/fc/rc_controls.h index 13c5dc6cb..e416b682b 100644 --- a/src/main/fc/rc_controls.h +++ b/src/main/fc/rc_controls.h @@ -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); diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 5783a3a17..a19d21e56 100755 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -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); diff --git a/src/main/main.c b/src/main/main.c index 6412f8d6d..eb67fe857 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -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)) { diff --git a/src/main/target/COLIBRI_RACE/i2c_bst.c b/src/main/target/COLIBRI_RACE/i2c_bst.c index bb9f92918..4e5913136 100644 --- a/src/main/target/COLIBRI_RACE/i2c_bst.c +++ b/src/main/target/COLIBRI_RACE/i2c_bst.c @@ -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; diff --git a/src/main/target/MULTIFLITEPICO/config.c b/src/main/target/MULTIFLITEPICO/config.c index 54a609b48..70ac3912b 100755 --- a/src/main/target/MULTIFLITEPICO/config.c +++ b/src/main/target/MULTIFLITEPICO/config.c @@ -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;