mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
Revise PID/Rate profile names to use get/set and eliminate extra PG's (#8231)
Revise PID/Rate profile names to use get/set and eliminate extra PG's
This commit is contained in:
commit
a27a695fa1
11 changed files with 57 additions and 116 deletions
|
@ -671,58 +671,9 @@ static const char *dumpPgValue(const clivalue_t *value, dumpFlags_t dumpMask, co
|
||||||
return headingStr;
|
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)
|
static void dumpAllValues(uint16_t valueSection, dumpFlags_t dumpMask, const char *headingStr)
|
||||||
{
|
{
|
||||||
headingStr = cliPrintSectionHeading(dumpMask, false, 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++) {
|
for (uint32_t i = 0; i < valueTableEntryCount; i++) {
|
||||||
const clivalue_t *value = &valueTable[i];
|
const clivalue_t *value = &valueTable[i];
|
||||||
|
@ -5866,13 +5817,7 @@ const clicmd_t cmdTable[] = {
|
||||||
CLI_COMMAND_DEF("play_sound", NULL, "[<index>]", cliPlaySound),
|
CLI_COMMAND_DEF("play_sound", NULL, "[<index>]", cliPlaySound),
|
||||||
#endif
|
#endif
|
||||||
CLI_COMMAND_DEF("profile", "change profile", "[<index>]", cliProfile),
|
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),
|
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
|
#ifdef USE_RC_SMOOTHING_FILTER
|
||||||
CLI_COMMAND_DEF("rc_smoothing_info", "show rc_smoothing operational settings", NULL, cliRcSmoothing),
|
CLI_COMMAND_DEF("rc_smoothing_info", "show rc_smoothing operational settings", NULL, cliRcSmoothing),
|
||||||
#endif // USE_RC_SMOOTHING_FILTER
|
#endif // USE_RC_SMOOTHING_FILTER
|
||||||
|
|
|
@ -620,8 +620,6 @@ const clivalue_t valueTable[] = {
|
||||||
#ifdef USE_DYN_LPF
|
#ifdef USE_DYN_LPF
|
||||||
{ "dyn_lpf_gyro_min_hz", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 1000 }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, dyn_lpf_gyro_min_hz) },
|
{ "dyn_lpf_gyro_min_hz", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 1000 }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, dyn_lpf_gyro_min_hz) },
|
||||||
{ "dyn_lpf_gyro_max_hz", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 1000 }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, dyn_lpf_gyro_max_hz) },
|
{ "dyn_lpf_gyro_max_hz", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 1000 }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, dyn_lpf_gyro_max_hz) },
|
||||||
{ "dyn_lpf_dterm_min_hz", VAR_UINT16 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 1000 }, PG_PID_PROFILE, offsetof(pidProfile_t, dyn_lpf_dterm_min_hz) },
|
|
||||||
{ "dyn_lpf_dterm_max_hz", VAR_UINT16 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 1000 }, PG_PID_PROFILE, offsetof(pidProfile_t, dyn_lpf_dterm_max_hz) },
|
|
||||||
#endif
|
#endif
|
||||||
{ "gyro_filter_debug_axis", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_GYRO_FILTER_DEBUG }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, gyro_filter_debug_axis) },
|
{ "gyro_filter_debug_axis", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_GYRO_FILTER_DEBUG }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, gyro_filter_debug_axis) },
|
||||||
|
|
||||||
|
@ -838,6 +836,9 @@ const clivalue_t valueTable[] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// PG_CONTROLRATE_PROFILES
|
// PG_CONTROLRATE_PROFILES
|
||||||
|
#ifdef USE_PROFILE_NAMES
|
||||||
|
{ "rateprofile_name", VAR_UINT8 | PROFILE_RATE_VALUE | MODE_STRING, .config.string = { 1, MAX_RATE_PROFILE_NAME_LENGTH, STRING_FLAGS_NONE }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, profileName) },
|
||||||
|
#endif
|
||||||
{ "thr_mid", VAR_UINT8 | PROFILE_RATE_VALUE, .config.minmaxUnsigned = { 0, 100 }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, thrMid8) },
|
{ "thr_mid", VAR_UINT8 | PROFILE_RATE_VALUE, .config.minmaxUnsigned = { 0, 100 }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, thrMid8) },
|
||||||
{ "thr_expo", VAR_UINT8 | PROFILE_RATE_VALUE, .config.minmaxUnsigned = { 0, 100 }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, thrExpo8) },
|
{ "thr_expo", VAR_UINT8 | PROFILE_RATE_VALUE, .config.minmaxUnsigned = { 0, 100 }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, thrExpo8) },
|
||||||
{ "rates_type", VAR_UINT8 | PROFILE_RATE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_RATES_TYPE }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, rates_type) },
|
{ "rates_type", VAR_UINT8 | PROFILE_RATE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_RATES_TYPE }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, rates_type) },
|
||||||
|
@ -926,6 +927,13 @@ const clivalue_t valueTable[] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// PG_PID_PROFILE
|
// PG_PID_PROFILE
|
||||||
|
#ifdef USE_PROFILE_NAMES
|
||||||
|
{ "profile_name", VAR_UINT8 | PROFILE_VALUE | MODE_STRING, .config.string = { 1, MAX_PROFILE_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PID_PROFILE, offsetof(pidProfile_t, profileName) },
|
||||||
|
#endif
|
||||||
|
#ifdef USE_DYN_LPF
|
||||||
|
{ "dyn_lpf_dterm_min_hz", VAR_UINT16 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 1000 }, PG_PID_PROFILE, offsetof(pidProfile_t, dyn_lpf_dterm_min_hz) },
|
||||||
|
{ "dyn_lpf_dterm_max_hz", VAR_UINT16 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 1000 }, PG_PID_PROFILE, offsetof(pidProfile_t, dyn_lpf_dterm_max_hz) },
|
||||||
|
#endif
|
||||||
{ "dterm_lowpass_type", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_DTERM_LOWPASS_TYPE }, PG_PID_PROFILE, offsetof(pidProfile_t, dterm_filter_type) },
|
{ "dterm_lowpass_type", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_DTERM_LOWPASS_TYPE }, PG_PID_PROFILE, offsetof(pidProfile_t, dterm_filter_type) },
|
||||||
{ "dterm_lowpass_hz", VAR_INT16 | PROFILE_VALUE, .config.minmax = { 0, 16000 }, PG_PID_PROFILE, offsetof(pidProfile_t, dterm_lowpass_hz) },
|
{ "dterm_lowpass_hz", VAR_INT16 | PROFILE_VALUE, .config.minmax = { 0, 16000 }, PG_PID_PROFILE, offsetof(pidProfile_t, dterm_lowpass_hz) },
|
||||||
{ "dterm_lowpass2_type", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_DTERM_LOWPASS_TYPE }, PG_PID_PROFILE, offsetof(pidProfile_t, dterm_filter2_type) },
|
{ "dterm_lowpass2_type", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_DTERM_LOWPASS_TYPE }, PG_PID_PROFILE, offsetof(pidProfile_t, dterm_filter2_type) },
|
||||||
|
|
|
@ -62,13 +62,13 @@
|
||||||
//
|
//
|
||||||
static uint8_t tmpPidProfileIndex;
|
static uint8_t tmpPidProfileIndex;
|
||||||
static uint8_t pidProfileIndex;
|
static uint8_t pidProfileIndex;
|
||||||
static char pidProfileIndexString[] = " p";
|
static char pidProfileIndexString[MAX_PROFILE_NAME_LENGTH + 5];
|
||||||
static uint8_t tempPid[3][3];
|
static uint8_t tempPid[3][3];
|
||||||
static uint16_t tempPidF[3];
|
static uint16_t tempPidF[3];
|
||||||
|
|
||||||
static uint8_t tmpRateProfileIndex;
|
static uint8_t tmpRateProfileIndex;
|
||||||
static uint8_t rateProfileIndex;
|
static uint8_t rateProfileIndex;
|
||||||
static char rateProfileIndexString[] = " p-r";
|
static char rateProfileIndexString[MAX_RATE_PROFILE_NAME_LENGTH + 5];
|
||||||
static controlRateConfig_t rateProfile;
|
static controlRateConfig_t rateProfile;
|
||||||
|
|
||||||
static const char * const osdTableThrottleLimitType[] = {
|
static const char * const osdTableThrottleLimitType[] = {
|
||||||
|
@ -81,6 +81,29 @@ static const char * const osdTableDynNotchRangeType[] = {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void setProfileIndexString(char *profileString, int profileIndex, char *profileName)
|
||||||
|
{
|
||||||
|
int charIndex = 0;
|
||||||
|
profileString[charIndex++] = '1' + profileIndex;
|
||||||
|
|
||||||
|
#ifdef USE_PROFILE_NAMES
|
||||||
|
const int profileNameLen = strlen(profileName);
|
||||||
|
|
||||||
|
if (profileNameLen > 0) {
|
||||||
|
profileString[charIndex++] = ' ';
|
||||||
|
profileString[charIndex++] = '(';
|
||||||
|
for (int i = 0; i < profileNameLen; i++) {
|
||||||
|
profileString[charIndex++] = toupper(profileName[i]);
|
||||||
|
}
|
||||||
|
profileString[charIndex++] = ')';
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
UNUSED(profileName);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
profileString[charIndex] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
static long cmsx_menuImu_onEnter(void)
|
static long cmsx_menuImu_onEnter(void)
|
||||||
{
|
{
|
||||||
pidProfileIndex = getCurrentPidProfileIndex();
|
pidProfileIndex = getCurrentPidProfileIndex();
|
||||||
|
@ -140,7 +163,7 @@ static long cmsx_PidRead(void)
|
||||||
|
|
||||||
static long cmsx_PidOnEnter(void)
|
static long cmsx_PidOnEnter(void)
|
||||||
{
|
{
|
||||||
pidProfileIndexString[1] = '0' + tmpPidProfileIndex;
|
setProfileIndexString(pidProfileIndexString, pidProfileIndex, currentPidProfile->profileName);
|
||||||
cmsx_PidRead();
|
cmsx_PidRead();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -217,8 +240,7 @@ static long cmsx_RateProfileWriteback(const OSD_Entry *self)
|
||||||
|
|
||||||
static long cmsx_RateProfileOnEnter(void)
|
static long cmsx_RateProfileOnEnter(void)
|
||||||
{
|
{
|
||||||
rateProfileIndexString[1] = '0' + tmpPidProfileIndex;
|
setProfileIndexString(rateProfileIndexString, rateProfileIndex, controlRateProfilesMutable(rateProfileIndex)->profileName);
|
||||||
rateProfileIndexString[3] = '0' + tmpRateProfileIndex;
|
|
||||||
cmsx_RateProfileRead();
|
cmsx_RateProfileRead();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -337,7 +359,7 @@ static uint8_t cmsx_d_min_advance;
|
||||||
|
|
||||||
static long cmsx_profileOtherOnEnter(void)
|
static long cmsx_profileOtherOnEnter(void)
|
||||||
{
|
{
|
||||||
pidProfileIndexString[1] = '0' + tmpPidProfileIndex;
|
setProfileIndexString(pidProfileIndexString, pidProfileIndex, currentPidProfile->profileName);
|
||||||
|
|
||||||
const pidProfile_t *pidProfile = pidProfiles(pidProfileIndex);
|
const pidProfile_t *pidProfile = pidProfiles(pidProfileIndex);
|
||||||
|
|
||||||
|
|
|
@ -87,10 +87,6 @@ PG_RESET_TEMPLATE(pilotConfig_t, pilotConfig,
|
||||||
.displayName = { 0 },
|
.displayName = { 0 },
|
||||||
);
|
);
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_FN(rateProfileNameConfig_t, rateProfileName, PG_RATE_PROFILE_NAMES_CONFIG, 1);
|
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_FN(pidProfileNameConfig_t, pidProfileName, PG_PID_PROFILE_NAMES_CONFIG, 1);
|
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_TEMPLATE(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 2);
|
PG_REGISTER_WITH_RESET_TEMPLATE(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 2);
|
||||||
|
|
||||||
PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
||||||
|
@ -126,22 +122,6 @@ uint16_t getCurrentMinthrottle(void)
|
||||||
return motorConfig()->minthrottle;
|
return motorConfig()->minthrottle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pgResetFn_rateProfileName(rateProfileNameConfig_t *rateProfileName)
|
|
||||||
{
|
|
||||||
|
|
||||||
for (int i = 0; i < CONTROL_RATE_PROFILE_COUNT; i++) {
|
|
||||||
tfp_sprintf(rateProfileName->profile[i].name, "RATE %u", i+1, MAX_PROFILE_NAME_LENGTH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void pgResetFn_pidProfileName(pidProfileNameConfig_t *pidProfileName)
|
|
||||||
{
|
|
||||||
|
|
||||||
for (int i = 0; i < PID_PROFILE_COUNT; i++) {
|
|
||||||
tfp_sprintf(pidProfileName->profile[i].name, "PID %u", i+1, MAX_PROFILE_NAME_LENGTH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void resetConfigs(void)
|
void resetConfigs(void)
|
||||||
{
|
{
|
||||||
pgResetAll();
|
pgResetAll();
|
||||||
|
|
|
@ -36,22 +36,6 @@ typedef struct pilotConfig_s {
|
||||||
|
|
||||||
PG_DECLARE(pilotConfig_t, pilotConfig);
|
PG_DECLARE(pilotConfig_t, pilotConfig);
|
||||||
|
|
||||||
typedef struct profileName_s {
|
|
||||||
char name[MAX_PROFILE_NAME_LENGTH + 1];
|
|
||||||
} profileName_t;
|
|
||||||
|
|
||||||
typedef struct rateProfileNameConfig_s {
|
|
||||||
profileName_t profile[CONTROL_RATE_PROFILE_COUNT];
|
|
||||||
} rateProfileNameConfig_t;
|
|
||||||
|
|
||||||
PG_DECLARE(rateProfileNameConfig_t, rateProfileName);
|
|
||||||
|
|
||||||
typedef struct pidProfileNameConfig_s {
|
|
||||||
profileName_t profile[PID_PROFILE_COUNT];
|
|
||||||
} pidProfileNameConfig_t;
|
|
||||||
|
|
||||||
PG_DECLARE(pidProfileNameConfig_t, pidProfileName);
|
|
||||||
|
|
||||||
typedef struct systemConfig_s {
|
typedef struct systemConfig_s {
|
||||||
uint8_t pidProfileIndex;
|
uint8_t pidProfileIndex;
|
||||||
uint8_t activeRateProfile;
|
uint8_t activeRateProfile;
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
controlRateConfig_t *currentControlRateProfile;
|
controlRateConfig_t *currentControlRateProfile;
|
||||||
|
|
||||||
PG_REGISTER_ARRAY_WITH_RESET_FN(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles, PG_CONTROL_RATE_PROFILES, 1);
|
PG_REGISTER_ARRAY_WITH_RESET_FN(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles, PG_CONTROL_RATE_PROFILES, 2);
|
||||||
|
|
||||||
void pgResetFn_controlRateProfiles(controlRateConfig_t *controlRateConfig)
|
void pgResetFn_controlRateProfiles(controlRateConfig_t *controlRateConfig)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +63,7 @@ void pgResetFn_controlRateProfiles(controlRateConfig_t *controlRateConfig)
|
||||||
.rate_limit[FD_PITCH] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX,
|
.rate_limit[FD_PITCH] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX,
|
||||||
.rate_limit[FD_YAW] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX,
|
.rate_limit[FD_YAW] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX,
|
||||||
.tpaMode = TPA_MODE_D,
|
.tpaMode = TPA_MODE_D,
|
||||||
|
.profileName = { 0 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,13 @@ typedef enum {
|
||||||
THROTTLE_LIMIT_TYPE_COUNT // must be the last entry
|
THROTTLE_LIMIT_TYPE_COUNT // must be the last entry
|
||||||
} throttleLimitType_e;
|
} throttleLimitType_e;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TPA_MODE_PD,
|
TPA_MODE_PD,
|
||||||
TPA_MODE_D
|
TPA_MODE_D
|
||||||
} tpaMode_e;
|
} tpaMode_e;
|
||||||
|
|
||||||
|
#define MAX_RATE_PROFILE_NAME_LENGTH 8u
|
||||||
|
|
||||||
typedef struct controlRateConfig_s {
|
typedef struct controlRateConfig_s {
|
||||||
uint8_t thrMid8;
|
uint8_t thrMid8;
|
||||||
uint8_t thrExpo8;
|
uint8_t thrExpo8;
|
||||||
|
@ -55,6 +56,7 @@ typedef struct controlRateConfig_s {
|
||||||
uint8_t throttle_limit_percent; // Sets the maximum pilot commanded throttle limit
|
uint8_t throttle_limit_percent; // Sets the maximum pilot commanded throttle limit
|
||||||
uint16_t rate_limit[3]; // Sets the maximum rate for the axes
|
uint16_t rate_limit[3]; // Sets the maximum rate for the axes
|
||||||
uint8_t tpaMode; // Controls which PID terms TPA effects
|
uint8_t tpaMode; // Controls which PID terms TPA effects
|
||||||
|
char profileName[MAX_RATE_PROFILE_NAME_LENGTH + 1]; // Descriptive name for rate profile
|
||||||
} controlRateConfig_t;
|
} controlRateConfig_t;
|
||||||
|
|
||||||
PG_DECLARE_ARRAY(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles);
|
PG_DECLARE_ARRAY(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles);
|
||||||
|
|
|
@ -128,7 +128,7 @@ static FAST_RAM_ZERO_INIT float airmodeThrottleOffsetLimit;
|
||||||
|
|
||||||
#define LAUNCH_CONTROL_YAW_ITERM_LIMIT 50 // yaw iterm windup limit when launch mode is "FULL" (all axes)
|
#define LAUNCH_CONTROL_YAW_ITERM_LIMIT 50 // yaw iterm windup limit when launch mode is "FULL" (all axes)
|
||||||
|
|
||||||
PG_REGISTER_ARRAY_WITH_RESET_FN(pidProfile_t, PID_PROFILE_COUNT, pidProfiles, PG_PID_PROFILE, 10);
|
PG_REGISTER_ARRAY_WITH_RESET_FN(pidProfile_t, PID_PROFILE_COUNT, pidProfiles, PG_PID_PROFILE, 11);
|
||||||
|
|
||||||
void resetPidProfile(pidProfile_t *pidProfile)
|
void resetPidProfile(pidProfile_t *pidProfile)
|
||||||
{
|
{
|
||||||
|
@ -204,6 +204,7 @@ void resetPidProfile(pidProfile_t *pidProfile)
|
||||||
.motor_output_limit = 100,
|
.motor_output_limit = 100,
|
||||||
.auto_profile_cell_count = AUTO_PROFILE_CELL_COUNT_STAY,
|
.auto_profile_cell_count = AUTO_PROFILE_CELL_COUNT_STAY,
|
||||||
.transient_throttle_limit = 15,
|
.transient_throttle_limit = 15,
|
||||||
|
.profileName = { 0 },
|
||||||
);
|
);
|
||||||
#ifndef USE_D_MIN
|
#ifndef USE_D_MIN
|
||||||
pidProfile->pid[PID_ROLL].D = 30;
|
pidProfile->pid[PID_ROLL].D = 30;
|
||||||
|
|
|
@ -100,6 +100,8 @@ typedef enum {
|
||||||
ITERM_RELAX_SETPOINT
|
ITERM_RELAX_SETPOINT
|
||||||
} itermRelaxType_e;
|
} itermRelaxType_e;
|
||||||
|
|
||||||
|
#define MAX_PROFILE_NAME_LENGTH 8u
|
||||||
|
|
||||||
typedef struct pidProfile_s {
|
typedef struct pidProfile_s {
|
||||||
uint16_t yaw_lowpass_hz; // Additional yaw filter when yaw axis too noisy
|
uint16_t yaw_lowpass_hz; // Additional yaw filter when yaw axis too noisy
|
||||||
uint16_t dterm_lowpass_hz; // Delta Filter in hz
|
uint16_t dterm_lowpass_hz; // Delta Filter in hz
|
||||||
|
@ -168,6 +170,7 @@ typedef struct pidProfile_s {
|
||||||
uint8_t motor_output_limit; // Upper limit of the motor output (percent)
|
uint8_t motor_output_limit; // Upper limit of the motor output (percent)
|
||||||
int8_t auto_profile_cell_count; // Cell count for this profile to be used with if auto PID profile switching is used
|
int8_t auto_profile_cell_count; // Cell count for this profile to be used with if auto PID profile switching is used
|
||||||
uint8_t transient_throttle_limit; // Maximum DC component of throttle change to mix into throttle to prevent airmode mirroring noise
|
uint8_t transient_throttle_limit; // Maximum DC component of throttle change to mix into throttle to prevent airmode mirroring noise
|
||||||
|
char profileName[MAX_PROFILE_NAME_LENGTH + 1]; // Descriptive name for profile
|
||||||
} pidProfile_t;
|
} pidProfile_t;
|
||||||
|
|
||||||
PG_DECLARE_ARRAY(pidProfile_t, PID_PROFILE_COUNT, pidProfiles);
|
PG_DECLARE_ARRAY(pidProfile_t, PID_PROFILE_COUNT, pidProfiles);
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
#include "drivers/vtx_common.h"
|
#include "drivers/vtx_common.h"
|
||||||
|
|
||||||
#include "fc/config.h"
|
#include "fc/config.h"
|
||||||
|
#include "fc/controlrate_profile.h"
|
||||||
#include "fc/core.h"
|
#include "fc/core.h"
|
||||||
#include "fc/rc_adjustments.h"
|
#include "fc/rc_adjustments.h"
|
||||||
#include "fc/rc_controls.h"
|
#include "fc/rc_controls.h"
|
||||||
|
@ -650,15 +651,13 @@ static void osdElementDisplayName(osdElementParms_t *element)
|
||||||
#ifdef USE_PROFILE_NAMES
|
#ifdef USE_PROFILE_NAMES
|
||||||
static void osdElementRateProfileName(osdElementParms_t *element)
|
static void osdElementRateProfileName(osdElementParms_t *element)
|
||||||
{
|
{
|
||||||
uint8_t rateProfileIndex = getCurrentControlRateProfileIndex();
|
if (strlen(currentControlRateProfile->profileName) == 0) {
|
||||||
|
tfp_sprintf(element->buff, "RATE_%u", getCurrentControlRateProfileIndex() + 1);
|
||||||
if (strlen(rateProfileName()->profile[rateProfileIndex].name) == 0) {
|
|
||||||
tfp_sprintf(element->buff, "RATE_%u", rateProfileIndex);
|
|
||||||
} else {
|
} else {
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < MAX_PROFILE_NAME_LENGTH; i++) {
|
for (i = 0; i < MAX_PROFILE_NAME_LENGTH; i++) {
|
||||||
if (rateProfileName()->profile[rateProfileIndex].name[i]) {
|
if (currentControlRateProfile->profileName[i]) {
|
||||||
element->buff[i] = toupper((unsigned char)rateProfileName()->profile[rateProfileIndex].name[i]);
|
element->buff[i] = toupper((unsigned char)currentControlRateProfile->profileName[i]);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -669,15 +668,13 @@ static void osdElementRateProfileName(osdElementParms_t *element)
|
||||||
|
|
||||||
static void osdElementPidProfileName(osdElementParms_t *element)
|
static void osdElementPidProfileName(osdElementParms_t *element)
|
||||||
{
|
{
|
||||||
uint8_t pidProfileIndex = getCurrentPidProfileIndex();
|
if (strlen(currentPidProfile->profileName) == 0) {
|
||||||
|
tfp_sprintf(element->buff, "PID_%u", getCurrentPidProfileIndex() + 1);
|
||||||
if (strlen(pidProfileName()->profile[pidProfileIndex].name) == 0) {
|
|
||||||
tfp_sprintf(element->buff, "PID_%u", pidProfileIndex);
|
|
||||||
} else {
|
} else {
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < MAX_PROFILE_NAME_LENGTH; i++) {
|
for (i = 0; i < MAX_PROFILE_NAME_LENGTH; i++) {
|
||||||
if (pidProfileName()->profile[pidProfileIndex].name[i]) {
|
if (currentPidProfile->profileName[i]) {
|
||||||
element->buff[i] = toupper((unsigned char)pidProfileName()->profile[pidProfileIndex].name[i]);
|
element->buff[i] = toupper((unsigned char)currentPidProfile->profileName[i]);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,6 @@
|
||||||
#define PG_GPS_RESCUE 55 // struct OK
|
#define PG_GPS_RESCUE 55 // struct OK
|
||||||
#define PG_POSITION 56
|
#define PG_POSITION 56
|
||||||
#define PG_VTX_IO_CONFIG 57
|
#define PG_VTX_IO_CONFIG 57
|
||||||
#define PG_RATE_PROFILE_NAMES_CONFIG 58
|
|
||||||
#define PG_PID_PROFILE_NAMES_CONFIG 59
|
|
||||||
|
|
||||||
// Driver configuration
|
// Driver configuration
|
||||||
#define PG_DRIVER_PWM_RX_CONFIG 100 // does not exist in betaflight
|
#define PG_DRIVER_PWM_RX_CONFIG 100 // does not exist in betaflight
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue