1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 03:50:02 +03:00

Revise PID/Rate profile names to use get/set and eliminate extra PG's

Removes the custom CLI commands to update or display the PID and Rate profile names. Moves the storage into the pidProfile and controlRateProfile PG's.

Names can now be set with:
set profile_name = NAME
set rate_profile_name = NAME

Also added profile name display to the profile and rate CMS menus.
This commit is contained in:
Bruce Luckcuck 2019-05-07 15:33:57 -04:00
parent 67d1f720ff
commit f5bc673ada
11 changed files with 57 additions and 116 deletions

View file

@ -671,58 +671,9 @@ static const char *dumpPgValue(const clivalue_t *value, dumpFlags_t dumpMask, co
return headingStr;
}
#ifdef USE_PROFILE_NAMES
static void printRateProfileName(uint8_t dumpMask, const profileName_t *rateProfileNameConfig)
{
const bool equalsDefault = strlen(rateProfileNameConfig->name) == 0;
cliDumpPrintLinef(dumpMask, equalsDefault, "rateprofile_name %s", equalsDefault ? emptyName : rateProfileNameConfig->name);
}
static void cliRateProfileName(char *cmdline)
{
const unsigned int len = strlen(cmdline);
uint8_t profileIndex = getCurrentControlRateProfileIndex();
if (len > 0) {
memset(rateProfileNameMutable()->profile[profileIndex].name, 0, ARRAYLEN(rateProfileNameMutable()->profile[profileIndex].name));
if (strncmp(cmdline, emptyName, len)) {
strncpy(rateProfileNameMutable()->profile[profileIndex].name, cmdline, MIN(len, MAX_PROFILE_NAME_LENGTH));
}
}
printRateProfileName(DUMP_MASTER, &rateProfileName()->profile[profileIndex]);
}
static void printPidProfileName(uint8_t dumpMask, const profileName_t *pidProfileNameConfig)
{
const bool equalsDefault = strlen(pidProfileNameConfig->name) == 0;
cliDumpPrintLinef(dumpMask, equalsDefault, "profile_name %s", equalsDefault ? emptyName : pidProfileNameConfig->name);
}
static void cliPidProfileName(char *cmdline)
{
const unsigned int len = strlen(cmdline);
uint8_t profileIndex = getCurrentPidProfileIndex();
if (len > 0) {
memset(pidProfileNameMutable()->profile[profileIndex].name, 0, ARRAYLEN(pidProfileNameMutable()->profile[profileIndex].name));
if (strncmp(cmdline, emptyName, len)) {
strncpy(pidProfileNameMutable()->profile[profileIndex].name, cmdline, MIN(len, MAX_PROFILE_NAME_LENGTH));
}
}
printPidProfileName(DUMP_MASTER, &pidProfileName()->profile[profileIndex]);
}
#endif
static void dumpAllValues(uint16_t valueSection, dumpFlags_t dumpMask, const char *headingStr)
{
headingStr = cliPrintSectionHeading(dumpMask, false, headingStr);
#ifdef USE_PROFILE_NAMES
if (valueSection == PROFILE_VALUE) {
printPidProfileName(DUMP_MASTER, &pidProfileName()->profile[getPidProfileIndexToUse()]);
}
if (valueSection == PROFILE_RATE_VALUE) {
printRateProfileName(DUMP_MASTER, &rateProfileName()->profile[getRateProfileIndexToUse()]);
}
#endif
for (uint32_t i = 0; i < valueTableEntryCount; i++) {
const clivalue_t *value = &valueTable[i];
@ -5864,13 +5815,7 @@ const clicmd_t cmdTable[] = {
CLI_COMMAND_DEF("play_sound", NULL, "[<index>]", cliPlaySound),
#endif
CLI_COMMAND_DEF("profile", "change profile", "[<index>]", cliProfile),
#ifdef USE_PROFILE_NAMES
CLI_COMMAND_DEF("profile_name", "name of pid profile", NULL, cliPidProfileName),
#endif
CLI_COMMAND_DEF("rateprofile", "change rate profile", "[<index>]", cliRateProfile),
#ifdef USE_PROFILE_NAMES
CLI_COMMAND_DEF("rateprofile_name", "name of rate profile", NULL, cliRateProfileName),
#endif
#ifdef USE_RC_SMOOTHING_FILTER
CLI_COMMAND_DEF("rc_smoothing_info", "show rc_smoothing operational settings", NULL, cliRcSmoothing),
#endif // USE_RC_SMOOTHING_FILTER