mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Add default display to cli get command if value has been changed
Presents the user with the default value for reference when displaying a parameter with the "get" command - but only if the current value differs from the default.
This commit is contained in:
parent
041362614b
commit
fc2f01cdf7
1 changed files with 22 additions and 2 deletions
|
@ -3075,6 +3075,24 @@ static void cliDefaults(char *cmdline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cliPrintVarDefault(const clivalue_t *value)
|
||||||
|
{
|
||||||
|
const pgRegistry_t *pg = pgFind(value->pgn);
|
||||||
|
if (pg) {
|
||||||
|
const char *defaultFormat = "Default value: ";
|
||||||
|
const int valueOffset = getValueOffset(value);
|
||||||
|
memcpy(pg->copy, pg->address, pg->size);
|
||||||
|
pgReset(pg);
|
||||||
|
const bool equalsDefault = valuePtrEqualsDefault(value, pg->copy + valueOffset, pg->address + valueOffset);
|
||||||
|
if (!equalsDefault) {
|
||||||
|
cliPrintf(defaultFormat, value->name);
|
||||||
|
printValuePointer(value, (uint8_t*)pg->address + valueOffset, false);
|
||||||
|
cliPrintLinefeed();
|
||||||
|
}
|
||||||
|
memcpy(pg->address, pg->copy, pg->size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
STATIC_UNIT_TESTED void cliGet(char *cmdline)
|
STATIC_UNIT_TESTED void cliGet(char *cmdline)
|
||||||
{
|
{
|
||||||
const clivalue_t *val;
|
const clivalue_t *val;
|
||||||
|
@ -3083,12 +3101,14 @@ STATIC_UNIT_TESTED void cliGet(char *cmdline)
|
||||||
for (uint32_t i = 0; i < valueTableEntryCount; i++) {
|
for (uint32_t i = 0; i < valueTableEntryCount; i++) {
|
||||||
if (strcasestr(valueTable[i].name, cmdline)) {
|
if (strcasestr(valueTable[i].name, cmdline)) {
|
||||||
val = &valueTable[i];
|
val = &valueTable[i];
|
||||||
|
if (matchedCommands > 0) {
|
||||||
|
cliPrintLinefeed();
|
||||||
|
}
|
||||||
cliPrintf("%s = ", valueTable[i].name);
|
cliPrintf("%s = ", valueTable[i].name);
|
||||||
cliPrintVar(val, 0);
|
cliPrintVar(val, 0);
|
||||||
cliPrintLinefeed();
|
cliPrintLinefeed();
|
||||||
cliPrintVarRange(val);
|
cliPrintVarRange(val);
|
||||||
cliPrintLinefeed();
|
cliPrintVarDefault(val);
|
||||||
|
|
||||||
matchedCommands++;
|
matchedCommands++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue