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