mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
Move modes and adjustments from profile to free up flash
This commit is contained in:
parent
27772ba56a
commit
69c7c2f9c7
9 changed files with 22 additions and 20 deletions
|
@ -850,7 +850,7 @@ void startBlackbox(void)
|
|||
*/
|
||||
blackboxBuildConditionCache();
|
||||
|
||||
blackboxModeActivationConditionPresent = isModeActivationConditionPresent(currentProfile->modeActivationConditions, BOXBLACKBOX);
|
||||
blackboxModeActivationConditionPresent = isModeActivationConditionPresent(masterConfig.modeActivationConditions, BOXBLACKBOX);
|
||||
|
||||
blackboxIteration = 0;
|
||||
blackboxPFrameIndex = 0;
|
||||
|
|
|
@ -765,7 +765,7 @@ void activateConfig(void)
|
|||
resetAdjustmentStates();
|
||||
|
||||
useRcControlsConfig(
|
||||
currentProfile->modeActivationConditions,
|
||||
masterConfig.modeActivationConditions,
|
||||
&masterConfig.escAndServoConfig,
|
||||
¤tProfile->pidProfile
|
||||
);
|
||||
|
|
|
@ -101,6 +101,8 @@ typedef struct master_t {
|
|||
profile_t profile[MAX_PROFILE_COUNT];
|
||||
uint8_t current_profile_index;
|
||||
controlRateConfig_t controlRateProfiles[MAX_CONTROL_RATE_PROFILE_COUNT];
|
||||
modeActivationCondition_t modeActivationConditions[MAX_MODE_ACTIVATION_CONDITION_COUNT];
|
||||
adjustmentRange_t adjustmentRanges[MAX_ADJUSTMENT_RANGE_COUNT];
|
||||
|
||||
#ifdef BLACKBOX
|
||||
uint8_t blackbox_rate_num;
|
||||
|
|
|
@ -36,9 +36,9 @@ typedef struct profile_s {
|
|||
|
||||
uint8_t acc_unarmedcal; // turn automatic acc compensation on/off
|
||||
|
||||
modeActivationCondition_t modeActivationConditions[MAX_MODE_ACTIVATION_CONDITION_COUNT];
|
||||
|
||||
|
||||
adjustmentRange_t adjustmentRanges[MAX_ADJUSTMENT_RANGE_COUNT];
|
||||
|
||||
|
||||
// Radio/ESC-related configuration
|
||||
|
||||
|
|
|
@ -728,7 +728,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 = ¤tProfile->modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
const box_t *box = &boxes[mac->modeId];
|
||||
bstWrite8(box->permanentId);
|
||||
bstWrite8(mac->auxChannelIndex);
|
||||
|
@ -738,7 +738,7 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
|||
break;
|
||||
case BST_ADJUSTMENT_RANGES:
|
||||
for (i = 0; i < MAX_ADJUSTMENT_RANGE_COUNT; i++) {
|
||||
adjustmentRange_t *adjRange = ¤tProfile->adjustmentRanges[i];
|
||||
adjustmentRange_t *adjRange = &masterConfig.adjustmentRanges[i];
|
||||
bstWrite8(adjRange->adjustmentIndex);
|
||||
bstWrite8(adjRange->auxChannelIndex);
|
||||
bstWrite8(adjRange->range.startStep);
|
||||
|
@ -1089,7 +1089,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
|||
case BST_SET_MODE_RANGE:
|
||||
i = bstRead8();
|
||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||
modeActivationCondition_t *mac = ¤tProfile->modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
i = bstRead8();
|
||||
const box_t *box = findBoxByPermenantId(i);
|
||||
if (box) {
|
||||
|
@ -1109,7 +1109,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
|||
case BST_SET_ADJUSTMENT_RANGE:
|
||||
i = bstRead8();
|
||||
if (i < MAX_ADJUSTMENT_RANGE_COUNT) {
|
||||
adjustmentRange_t *adjRange = ¤tProfile->adjustmentRanges[i];
|
||||
adjustmentRange_t *adjRange = &masterConfig.adjustmentRanges[i];
|
||||
i = bstRead8();
|
||||
if (i < MAX_SIMULTANEOUS_ADJUSTMENT_COUNT) {
|
||||
adjRange->adjustmentIndex = i;
|
||||
|
|
|
@ -874,7 +874,7 @@ static void cliAux(char *cmdline)
|
|||
if (isEmpty(cmdline)) {
|
||||
// print out aux channel settings
|
||||
for (i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
modeActivationCondition_t *mac = ¤tProfile->modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
cliPrintf("aux %u %u %u %u %u\r\n",
|
||||
i,
|
||||
mac->modeId,
|
||||
|
@ -887,7 +887,7 @@ static void cliAux(char *cmdline)
|
|||
ptr = cmdline;
|
||||
i = atoi(ptr++);
|
||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||
modeActivationCondition_t *mac = ¤tProfile->modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
uint8_t validArgumentCount = 0;
|
||||
ptr = strchr(ptr, ' ');
|
||||
if (ptr) {
|
||||
|
@ -1021,7 +1021,7 @@ static void cliAdjustmentRange(char *cmdline)
|
|||
if (isEmpty(cmdline)) {
|
||||
// print out adjustment ranges channel settings
|
||||
for (i = 0; i < MAX_ADJUSTMENT_RANGE_COUNT; i++) {
|
||||
adjustmentRange_t *ar = ¤tProfile->adjustmentRanges[i];
|
||||
adjustmentRange_t *ar = &masterConfig.adjustmentRanges[i];
|
||||
cliPrintf("adjrange %u %u %u %u %u %u %u\r\n",
|
||||
i,
|
||||
ar->adjustmentIndex,
|
||||
|
@ -1036,7 +1036,7 @@ static void cliAdjustmentRange(char *cmdline)
|
|||
ptr = cmdline;
|
||||
i = atoi(ptr++);
|
||||
if (i < MAX_ADJUSTMENT_RANGE_COUNT) {
|
||||
adjustmentRange_t *ar = ¤tProfile->adjustmentRanges[i];
|
||||
adjustmentRange_t *ar = &masterConfig.adjustmentRanges[i];
|
||||
uint8_t validArgumentCount = 0;
|
||||
|
||||
ptr = strchr(ptr, ' ');
|
||||
|
|
|
@ -837,7 +837,7 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
case MSP_MODE_RANGES:
|
||||
headSerialReply(4 * MAX_MODE_ACTIVATION_CONDITION_COUNT);
|
||||
for (i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
modeActivationCondition_t *mac = ¤tProfile->modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
const box_t *box = &boxes[mac->modeId];
|
||||
serialize8(box->permanentId);
|
||||
serialize8(mac->auxChannelIndex);
|
||||
|
@ -855,7 +855,7 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
1 // aux switch channel index
|
||||
));
|
||||
for (i = 0; i < MAX_ADJUSTMENT_RANGE_COUNT; i++) {
|
||||
adjustmentRange_t *adjRange = ¤tProfile->adjustmentRanges[i];
|
||||
adjustmentRange_t *adjRange = &masterConfig.adjustmentRanges[i];
|
||||
serialize8(adjRange->adjustmentIndex);
|
||||
serialize8(adjRange->auxChannelIndex);
|
||||
serialize8(adjRange->range.startStep);
|
||||
|
@ -1310,7 +1310,7 @@ static bool processInCommand(void)
|
|||
case MSP_SET_MODE_RANGE:
|
||||
i = read8();
|
||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||
modeActivationCondition_t *mac = ¤tProfile->modeActivationConditions[i];
|
||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
||||
i = read8();
|
||||
const box_t *box = findBoxByPermenantId(i);
|
||||
if (box) {
|
||||
|
@ -1319,7 +1319,7 @@ static bool processInCommand(void)
|
|||
mac->range.startStep = read8();
|
||||
mac->range.endStep = read8();
|
||||
|
||||
useRcControlsConfig(currentProfile->modeActivationConditions, &masterConfig.escAndServoConfig, ¤tProfile->pidProfile);
|
||||
useRcControlsConfig(masterConfig.modeActivationConditions, &masterConfig.escAndServoConfig, ¤tProfile->pidProfile);
|
||||
} else {
|
||||
headSerialError(0);
|
||||
}
|
||||
|
@ -1330,7 +1330,7 @@ static bool processInCommand(void)
|
|||
case MSP_SET_ADJUSTMENT_RANGE:
|
||||
i = read8();
|
||||
if (i < MAX_ADJUSTMENT_RANGE_COUNT) {
|
||||
adjustmentRange_t *adjRange = ¤tProfile->adjustmentRanges[i];
|
||||
adjustmentRange_t *adjRange = &masterConfig.adjustmentRanges[i];
|
||||
i = read8();
|
||||
if (i < MAX_SIMULTANEOUS_ADJUSTMENT_COUNT) {
|
||||
adjRange->adjustmentIndex = i;
|
||||
|
|
|
@ -490,7 +490,7 @@ void init(void)
|
|||
|
||||
failsafeInit(&masterConfig.rxConfig, masterConfig.flight3DConfig.deadband3d_throttle);
|
||||
|
||||
rxInit(&masterConfig.rxConfig, currentProfile->modeActivationConditions);
|
||||
rxInit(&masterConfig.rxConfig, masterConfig.modeActivationConditions);
|
||||
|
||||
#ifdef GPS
|
||||
if (feature(FEATURE_GPS)) {
|
||||
|
|
|
@ -531,10 +531,10 @@ void processRx(void)
|
|||
updateInflightCalibrationState();
|
||||
}
|
||||
|
||||
updateActivatedModes(currentProfile->modeActivationConditions);
|
||||
updateActivatedModes(masterConfig.modeActivationConditions);
|
||||
|
||||
if (!cliMode) {
|
||||
updateAdjustmentStates(currentProfile->adjustmentRanges);
|
||||
updateAdjustmentStates(masterConfig.adjustmentRanges);
|
||||
processRcAdjustments(currentControlRateProfile, &masterConfig.rxConfig);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue