mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 12:25:20 +03:00
Made 'features' work when config is in copy.
This commit is contained in:
parent
e441549b58
commit
accb49c157
4 changed files with 11 additions and 19 deletions
|
@ -3116,19 +3116,17 @@ static void cliMcuId(char *cmdline)
|
||||||
cliPrintLinef("mcu_id %08x%08x%08x", U_ID_0, U_ID_1, U_ID_2);
|
cliPrintLinef("mcu_id %08x%08x%08x", U_ID_0, U_ID_1, U_ID_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t getFeatureMask(const uint32_t featureMask)
|
static uint32_t *getFeatureMask(void)
|
||||||
{
|
{
|
||||||
if (featureMaskIsCopied) {
|
if (featureMaskIsCopied) {
|
||||||
return featureMaskCopy;
|
return &featureMaskCopy;
|
||||||
} else {
|
} else {
|
||||||
return featureMask;
|
return &featureConfigMutable()->enabledFeatures;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printFeature(dumpFlags_t dumpMask, const featureConfig_t *featureConfig, const featureConfig_t *featureConfigDefault, const char *headingStr)
|
static void printFeature(dumpFlags_t dumpMask, const uint32_t mask, const uint32_t defaultMask, const char *headingStr)
|
||||||
{
|
{
|
||||||
const uint32_t mask = getFeatureMask(featureConfig->enabledFeatures);
|
|
||||||
const uint32_t defaultMask = featureConfigDefault->enabledFeatures;
|
|
||||||
headingStr = cliPrintSectionHeading(dumpMask, false, headingStr);
|
headingStr = cliPrintSectionHeading(dumpMask, false, headingStr);
|
||||||
for (uint32_t i = 0; featureNames[i]; i++) { // disabled features first
|
for (uint32_t i = 0; featureNames[i]; i++) { // disabled features first
|
||||||
if (strcmp(featureNames[i], emptyString) != 0) { //Skip unused
|
if (strcmp(featureNames[i], emptyString) != 0) { //Skip unused
|
||||||
|
@ -3157,7 +3155,7 @@ static void printFeature(dumpFlags_t dumpMask, const featureConfig_t *featureCon
|
||||||
static void cliFeature(char *cmdline)
|
static void cliFeature(char *cmdline)
|
||||||
{
|
{
|
||||||
uint32_t len = strlen(cmdline);
|
uint32_t len = strlen(cmdline);
|
||||||
const uint32_t mask = getFeatureMask(featureMask());
|
const uint32_t mask = *getFeatureMask();
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
cliPrint("Enabled: ");
|
cliPrint("Enabled: ");
|
||||||
for (uint32_t i = 0; ; i++) {
|
for (uint32_t i = 0; ; i++) {
|
||||||
|
@ -3180,8 +3178,8 @@ static void cliFeature(char *cmdline)
|
||||||
cliPrintLinefeed();
|
cliPrintLinefeed();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (!featureMaskIsCopied) {
|
if (!featureMaskIsCopied && !configIsInCopy) {
|
||||||
featureMaskCopy = featureMask();
|
featureMaskCopy = featureConfig()->enabledFeatures;
|
||||||
featureMaskIsCopied = true;
|
featureMaskIsCopied = true;
|
||||||
}
|
}
|
||||||
uint32_t feature;
|
uint32_t feature;
|
||||||
|
@ -3215,10 +3213,10 @@ static void cliFeature(char *cmdline)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (remove) {
|
if (remove) {
|
||||||
featureClear(feature, &featureMaskCopy);
|
featureClear(feature, getFeatureMask());
|
||||||
cliPrint("Disabled");
|
cliPrint("Disabled");
|
||||||
} else {
|
} else {
|
||||||
featureSet(feature, &featureMaskCopy);
|
featureSet(feature, getFeatureMask());
|
||||||
cliPrint("Enabled");
|
cliPrint("Enabled");
|
||||||
}
|
}
|
||||||
cliPrintLinef(" %s", featureNames[i]);
|
cliPrintLinef(" %s", featureNames[i]);
|
||||||
|
@ -5971,7 +5969,7 @@ static void printConfig(char *cmdline, bool doDiff)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printFeature(dumpMask, &featureConfig_Copy, featureConfig(), "feature");
|
printFeature(dumpMask, featureConfig_Copy.enabledFeatures, *getFeatureMask(), "feature");
|
||||||
|
|
||||||
#if defined(USE_BEEPER)
|
#if defined(USE_BEEPER)
|
||||||
printBeeper(dumpMask, beeperConfig_Copy.beeper_off_flags, beeperConfig()->beeper_off_flags, "beeper", BEEPER_ALLOWED_MODES, "beeper");
|
printBeeper(dumpMask, beeperConfig_Copy.beeper_off_flags, beeperConfig()->beeper_off_flags, "beeper", BEEPER_ALLOWED_MODES, "beeper");
|
||||||
|
|
|
@ -64,8 +64,3 @@ void featureDisableAll(void)
|
||||||
{
|
{
|
||||||
featureConfigMutable()->enabledFeatures = 0;
|
featureConfigMutable()->enabledFeatures = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t featureMask(void)
|
|
||||||
{
|
|
||||||
return featureConfig()->enabledFeatures;
|
|
||||||
}
|
|
||||||
|
|
|
@ -66,7 +66,6 @@ bool featureIsEnabled(const uint32_t mask);
|
||||||
void featureEnable(const uint32_t mask);
|
void featureEnable(const uint32_t mask);
|
||||||
void featureDisable(const uint32_t mask);
|
void featureDisable(const uint32_t mask);
|
||||||
void featureDisableAll(void);
|
void featureDisableAll(void);
|
||||||
uint32_t featureMask(void);
|
|
||||||
|
|
||||||
void featureSet(const uint32_t mask, uint32_t *features);
|
void featureSet(const uint32_t mask, uint32_t *features);
|
||||||
void featureClear(const uint32_t mask, uint32_t *features);
|
void featureClear(const uint32_t mask, uint32_t *features);
|
||||||
|
|
|
@ -177,7 +177,7 @@ static uint32_t getFeatureMask(void)
|
||||||
if (featureMaskIsCopied) {
|
if (featureMaskIsCopied) {
|
||||||
return featureMaskCopy;
|
return featureMaskCopy;
|
||||||
} else {
|
} else {
|
||||||
return featureMask();
|
return featureConfig()->enabledFeatures;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue