mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Added modeActivationProfile() macro
This commit is contained in:
parent
389eaacd8a
commit
953d23851d
9 changed files with 19 additions and 14 deletions
|
@ -820,7 +820,7 @@ void startBlackbox(void)
|
||||||
*/
|
*/
|
||||||
blackboxBuildConditionCache();
|
blackboxBuildConditionCache();
|
||||||
|
|
||||||
blackboxModeActivationConditionPresent = isModeActivationConditionPresent(masterConfig.modeActivationConditions, BOXBLACKBOX);
|
blackboxModeActivationConditionPresent = isModeActivationConditionPresent(modeActivationProfile()->modeActivationConditions, BOXBLACKBOX);
|
||||||
|
|
||||||
blackboxIteration = 0;
|
blackboxIteration = 0;
|
||||||
blackboxPFrameIndex = 0;
|
blackboxPFrameIndex = 0;
|
||||||
|
|
|
@ -100,6 +100,7 @@
|
||||||
#define flashConfig(x) (&masterConfig.flashConfig)
|
#define flashConfig(x) (&masterConfig.flashConfig)
|
||||||
#define pidConfig(x) (&masterConfig.pidConfig)
|
#define pidConfig(x) (&masterConfig.pidConfig)
|
||||||
#define adjustmentProfile(x) (&masterConfig.adjustmentProfile)
|
#define adjustmentProfile(x) (&masterConfig.adjustmentProfile)
|
||||||
|
#define modeActivationProfile(x) (&masterConfig.modeActivationProfile)
|
||||||
|
|
||||||
|
|
||||||
// System-wide
|
// System-wide
|
||||||
|
@ -216,7 +217,7 @@ typedef struct master_s {
|
||||||
profile_t profile[MAX_PROFILE_COUNT];
|
profile_t profile[MAX_PROFILE_COUNT];
|
||||||
uint8_t current_profile_index;
|
uint8_t current_profile_index;
|
||||||
|
|
||||||
modeActivationCondition_t modeActivationConditions[MAX_MODE_ACTIVATION_CONDITION_COUNT];
|
modeActivationProfile_t modeActivationProfile;
|
||||||
adjustmentProfile_t adjustmentProfile;
|
adjustmentProfile_t adjustmentProfile;
|
||||||
#ifdef VTX
|
#ifdef VTX
|
||||||
uint8_t vtx_band; //1=A, 2=B, 3=E, 4=F(Airwaves/Fatshark), 5=Raceband
|
uint8_t vtx_band; //1=A, 2=B, 3=E, 4=F(Airwaves/Fatshark), 5=Raceband
|
||||||
|
|
|
@ -882,7 +882,7 @@ void activateConfig(void)
|
||||||
resetAdjustmentStates();
|
resetAdjustmentStates();
|
||||||
|
|
||||||
useRcControlsConfig(
|
useRcControlsConfig(
|
||||||
masterConfig.modeActivationConditions,
|
modeActivationProfile()->modeActivationConditions,
|
||||||
&masterConfig.motorConfig,
|
&masterConfig.motorConfig,
|
||||||
¤tProfile->pidProfile
|
¤tProfile->pidProfile
|
||||||
);
|
);
|
||||||
|
|
|
@ -797,7 +797,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
||||||
|
|
||||||
case MSP_MODE_RANGES:
|
case MSP_MODE_RANGES:
|
||||||
for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
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];
|
const box_t *box = &boxes[mac->modeId];
|
||||||
sbufWriteU8(dst, box->permanentId);
|
sbufWriteU8(dst, box->permanentId);
|
||||||
sbufWriteU8(dst, mac->auxChannelIndex);
|
sbufWriteU8(dst, mac->auxChannelIndex);
|
||||||
|
@ -1316,7 +1316,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
||||||
case MSP_SET_MODE_RANGE:
|
case MSP_SET_MODE_RANGE:
|
||||||
i = sbufReadU8(src);
|
i = sbufReadU8(src);
|
||||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
modeActivationCondition_t *mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||||
i = sbufReadU8(src);
|
i = sbufReadU8(src);
|
||||||
const box_t *box = findBoxByPermenantId(i);
|
const box_t *box = findBoxByPermenantId(i);
|
||||||
if (box) {
|
if (box) {
|
||||||
|
@ -1325,7 +1325,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
||||||
mac->range.startStep = sbufReadU8(src);
|
mac->range.startStep = sbufReadU8(src);
|
||||||
mac->range.endStep = sbufReadU8(src);
|
mac->range.endStep = sbufReadU8(src);
|
||||||
|
|
||||||
useRcControlsConfig(masterConfig.modeActivationConditions, &masterConfig.motorConfig, ¤tProfile->pidProfile);
|
useRcControlsConfig(modeActivationProfile()->modeActivationConditions, &masterConfig.motorConfig, ¤tProfile->pidProfile);
|
||||||
} else {
|
} else {
|
||||||
return MSP_RESULT_ERROR;
|
return MSP_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -576,7 +576,7 @@ void processRx(timeUs_t currentTimeUs)
|
||||||
updateInflightCalibrationState();
|
updateInflightCalibrationState();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateActivatedModes(masterConfig.modeActivationConditions);
|
updateActivatedModes(modeActivationProfile()->modeActivationConditions);
|
||||||
|
|
||||||
if (!cliMode) {
|
if (!cliMode) {
|
||||||
updateAdjustmentStates(adjustmentProfile()->adjustmentRanges);
|
updateAdjustmentStates(adjustmentProfile()->adjustmentRanges);
|
||||||
|
|
|
@ -140,6 +140,10 @@ typedef struct modeActivationCondition_s {
|
||||||
channelRange_t range;
|
channelRange_t range;
|
||||||
} modeActivationCondition_t;
|
} 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)
|
#define IS_RANGE_USABLE(range) ((range)->startStep < (range)->endStep)
|
||||||
|
|
||||||
typedef struct controlRateConfig_s {
|
typedef struct controlRateConfig_s {
|
||||||
|
|
|
@ -1216,8 +1216,8 @@ static void printAux(uint8_t dumpMask, master_t *defaultConfig)
|
||||||
modeActivationCondition_t *macDefault;
|
modeActivationCondition_t *macDefault;
|
||||||
bool equalsDefault;
|
bool equalsDefault;
|
||||||
for (uint32_t i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
for (uint32_t i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||||
mac = &masterConfig.modeActivationConditions[i];
|
mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||||
macDefault = &defaultConfig->modeActivationConditions[i];
|
macDefault = &defaultConfig->modeActivationProfile.modeActivationConditions[i];
|
||||||
equalsDefault = mac->modeId == macDefault->modeId
|
equalsDefault = mac->modeId == macDefault->modeId
|
||||||
&& mac->auxChannelIndex == macDefault->auxChannelIndex
|
&& mac->auxChannelIndex == macDefault->auxChannelIndex
|
||||||
&& mac->range.startStep == macDefault->range.startStep
|
&& mac->range.startStep == macDefault->range.startStep
|
||||||
|
@ -1251,7 +1251,7 @@ static void cliAux(char *cmdline)
|
||||||
ptr = cmdline;
|
ptr = cmdline;
|
||||||
i = atoi(ptr++);
|
i = atoi(ptr++);
|
||||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
modeActivationCondition_t *mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||||
uint8_t validArgumentCount = 0;
|
uint8_t validArgumentCount = 0;
|
||||||
ptr = nextArg(ptr);
|
ptr = nextArg(ptr);
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
|
|
|
@ -441,7 +441,7 @@ void init(void)
|
||||||
|
|
||||||
failsafeInit(rxConfig(), flight3DConfig()->deadband3d_throttle);
|
failsafeInit(rxConfig(), flight3DConfig()->deadband3d_throttle);
|
||||||
|
|
||||||
rxInit(rxConfig(), masterConfig.modeActivationConditions);
|
rxInit(rxConfig(), modeActivationProfile()->modeActivationConditions);
|
||||||
|
|
||||||
#ifdef GPS
|
#ifdef GPS
|
||||||
if (feature(FEATURE_GPS)) {
|
if (feature(FEATURE_GPS)) {
|
||||||
|
|
|
@ -720,7 +720,7 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
||||||
break;
|
break;
|
||||||
case BST_MODE_RANGES:
|
case BST_MODE_RANGES:
|
||||||
for (i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
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];
|
const box_t *box = &boxes[mac->modeId];
|
||||||
bstWrite8(box->permanentId);
|
bstWrite8(box->permanentId);
|
||||||
bstWrite8(mac->auxChannelIndex);
|
bstWrite8(mac->auxChannelIndex);
|
||||||
|
@ -1056,7 +1056,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
||||||
case BST_SET_MODE_RANGE:
|
case BST_SET_MODE_RANGE:
|
||||||
i = bstRead8();
|
i = bstRead8();
|
||||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
modeActivationCondition_t *mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||||
i = bstRead8();
|
i = bstRead8();
|
||||||
const box_t *box = findBoxByPermenantId(i);
|
const box_t *box = findBoxByPermenantId(i);
|
||||||
if (box) {
|
if (box) {
|
||||||
|
@ -1065,7 +1065,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
||||||
mac->range.startStep = bstRead8();
|
mac->range.startStep = bstRead8();
|
||||||
mac->range.endStep = bstRead8();
|
mac->range.endStep = bstRead8();
|
||||||
|
|
||||||
useRcControlsConfig(masterConfig.modeActivationConditions, &masterConfig.motorConfig, ¤tProfile->pidProfile);
|
useRcControlsConfig(modeActivationProfile()->modeActivationConditions, &masterConfig.motorConfig, ¤tProfile->pidProfile);
|
||||||
} else {
|
} else {
|
||||||
ret = BST_FAILED;
|
ret = BST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue