mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 19:40:31 +03:00
Revise feature logic to separate runtime and config settings (#9029)
Revise feature logic to separate runtime and config settings
This commit is contained in:
commit
2888bdd2b8
8 changed files with 71 additions and 78 deletions
|
@ -196,9 +196,6 @@ static bool configIsInCopy = false;
|
|||
static int8_t pidProfileIndexToUse = CURRENT_PROFILE_INDEX;
|
||||
static int8_t rateProfileIndexToUse = CURRENT_PROFILE_INDEX;
|
||||
|
||||
static bool featureMaskIsCopied = false;
|
||||
static uint32_t featureMaskCopy;
|
||||
|
||||
#ifdef USE_CLI_BATCH
|
||||
static bool commandBatchActive = false;
|
||||
static bool commandBatchError = false;
|
||||
|
@ -3123,15 +3120,6 @@ static void cliMcuId(char *cmdline)
|
|||
cliPrintLinef("mcu_id %08x%08x%08x", U_ID_0, U_ID_1, U_ID_2);
|
||||
}
|
||||
|
||||
static uint32_t *getFeatureMask(void)
|
||||
{
|
||||
if (featureMaskIsCopied) {
|
||||
return &featureMaskCopy;
|
||||
} else {
|
||||
return &featureConfigMutable()->enabledFeatures;
|
||||
}
|
||||
}
|
||||
|
||||
static void printFeature(dumpFlags_t dumpMask, const uint32_t mask, const uint32_t defaultMask, const char *headingStr)
|
||||
{
|
||||
headingStr = cliPrintSectionHeading(dumpMask, false, headingStr);
|
||||
|
@ -3162,7 +3150,7 @@ static void printFeature(dumpFlags_t dumpMask, const uint32_t mask, const uint32
|
|||
static void cliFeature(char *cmdline)
|
||||
{
|
||||
uint32_t len = strlen(cmdline);
|
||||
const uint32_t mask = *getFeatureMask();
|
||||
const uint32_t mask = featureConfig()->enabledFeatures;
|
||||
if (len == 0) {
|
||||
cliPrint("Enabled: ");
|
||||
for (uint32_t i = 0; ; i++) {
|
||||
|
@ -3185,10 +3173,6 @@ static void cliFeature(char *cmdline)
|
|||
cliPrintLinefeed();
|
||||
return;
|
||||
} else {
|
||||
if (!featureMaskIsCopied && !configIsInCopy) {
|
||||
featureMaskCopy = featureConfig()->enabledFeatures;
|
||||
featureMaskIsCopied = true;
|
||||
}
|
||||
uint32_t feature;
|
||||
|
||||
bool remove = false;
|
||||
|
@ -3220,10 +3204,10 @@ static void cliFeature(char *cmdline)
|
|||
}
|
||||
#endif
|
||||
if (remove) {
|
||||
featureClear(feature, getFeatureMask());
|
||||
featureConfigClear(feature);
|
||||
cliPrint("Disabled");
|
||||
} else {
|
||||
featureSet(feature, getFeatureMask());
|
||||
featureConfigSet(feature);
|
||||
cliPrint("Enabled");
|
||||
}
|
||||
cliPrintLinef(" %s", featureNames[i]);
|
||||
|
@ -4173,11 +4157,6 @@ static bool prepareSave(void)
|
|||
#endif
|
||||
#endif // USE_BOARD_INFO
|
||||
|
||||
if (featureMaskIsCopied) {
|
||||
featureDisableAll();
|
||||
featureEnable(featureMaskCopy);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6067,7 +6046,7 @@ static void printConfig(char *cmdline, bool doDiff)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
printFeature(dumpMask, featureConfig_Copy.enabledFeatures, *getFeatureMask(), "feature");
|
||||
printFeature(dumpMask, featureConfig_Copy.enabledFeatures, featureConfig()->enabledFeatures, "feature");
|
||||
|
||||
#if defined(USE_BEEPER)
|
||||
printBeeper(dumpMask, beeperConfig_Copy.beeper_off_flags, beeperConfig()->beeper_off_flags, "beeper", BEEPER_ALLOWED_MODES, "beeper");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue