mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 16:25:26 +03:00
Remove configuration of pid controller via name.
Makes merging of #1488 easier.
This commit is contained in:
parent
fb85e7f08a
commit
e58595fcb8
1 changed files with 5 additions and 57 deletions
|
@ -186,11 +186,6 @@ static const rxFailsafeChannelMode_e rxFailsafeModesTable[RX_FAILSAFE_TYPE_COUNT
|
||||||
{ RX_FAILSAFE_MODE_INVALID, RX_FAILSAFE_MODE_HOLD, RX_FAILSAFE_MODE_SET }
|
{ RX_FAILSAFE_MODE_INVALID, RX_FAILSAFE_MODE_HOLD, RX_FAILSAFE_MODE_SET }
|
||||||
};
|
};
|
||||||
|
|
||||||
// sync this with pidControllerType_e
|
|
||||||
static const char * const pidControllers[] = {
|
|
||||||
"REWRITE", "LUXFLOAT", "MULTIWII23", NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef CJMCU
|
#ifndef CJMCU
|
||||||
// sync this with sensors_e
|
// sync this with sensors_e
|
||||||
static const char * const sensorTypeNames[] = {
|
static const char * const sensorTypeNames[] = {
|
||||||
|
@ -1413,14 +1408,8 @@ static void dumpValues(uint16_t mask)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(valueTable[i].name, "pid_controller")) {
|
printf("set %s = ", valueTable[i].name);
|
||||||
void *pidPtr= value->ptr;
|
cliPrintVar(value, 0);
|
||||||
pidPtr= ((uint8_t *)pidPtr) + (sizeof(profile_t) * masterConfig.current_profile_index);
|
|
||||||
cliPrint(pidControllers[*(uint8_t *)pidPtr-1]);
|
|
||||||
} else {
|
|
||||||
cliPrintVar(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
cliPrint("\r\n");
|
cliPrint("\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2060,42 +2049,9 @@ static void cliSet(char *cmdline)
|
||||||
valuef = fastA2F(eqptr);
|
valuef = fastA2F(eqptr);
|
||||||
for (i = 0; i < VALUE_COUNT; i++) {
|
for (i = 0; i < VALUE_COUNT; i++) {
|
||||||
val = &valueTable[i];
|
val = &valueTable[i];
|
||||||
|
// ensure exact match when setting to prevent setting variables with shorter names
|
||||||
if (strncasecmp(cmdline, valueTable[i].name, strlen(valueTable[i].name)) == 0 && variableNameLength == strlen(valueTable[i].name)) {
|
if (strncasecmp(cmdline, valueTable[i].name, strlen(valueTable[i].name)) == 0 && variableNameLength == strlen(valueTable[i].name)) {
|
||||||
// ensure exact match when setting to prevent setting variables with shorter names
|
if (valuef >= valueTable[i].min && valuef <= valueTable[i].max) { // here we compare the float value since... it should work, RIGHT?
|
||||||
if (strstr(valueTable[i].name, "pid_controller")) {
|
|
||||||
int_float_value_t tmp;
|
|
||||||
tmp.int_value = 0;
|
|
||||||
bool pidControllerSet = false;
|
|
||||||
|
|
||||||
if (value) {
|
|
||||||
if (value >= valueTable[i].min && value <= valueTable[i].max) {
|
|
||||||
tmp.int_value = value;
|
|
||||||
cliSetVar(val, tmp);
|
|
||||||
printf("%s set to %s \r\n", valueTable[i].name, pidControllers[value - 1]);
|
|
||||||
pidControllerSet = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int pid = 0; pid < (PID_COUNT - 1); pid++) {
|
|
||||||
if (strstr(eqptr, pidControllers[pid])) {
|
|
||||||
tmp.int_value = pid + 1;
|
|
||||||
cliSetVar(val, tmp);
|
|
||||||
printf("%s set to %s \r\n", valueTable[i].name, pidControllers[pid]);
|
|
||||||
pidControllerSet = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pidControllerSet) {
|
|
||||||
printf("Invalid Value! (Available PID Controllers: ");
|
|
||||||
for (int pid = 0; pid < (PID_COUNT - 1); pid++) {
|
|
||||||
printf(pidControllers[pid]);
|
|
||||||
printf(" ");
|
|
||||||
}
|
|
||||||
printf(")\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
} else if (valuef >= valueTable[i].min && valuef <= valueTable[i].max) { // here we compare the float value since... it should work, RIGHT?
|
|
||||||
int_float_value_t tmp;
|
int_float_value_t tmp;
|
||||||
if (valueTable[i].type & VAR_FLOAT)
|
if (valueTable[i].type & VAR_FLOAT)
|
||||||
tmp.float_value = valuef;
|
tmp.float_value = valuef;
|
||||||
|
@ -2127,15 +2083,7 @@ static void cliGet(char *cmdline)
|
||||||
if (strstr(valueTable[i].name, cmdline)) {
|
if (strstr(valueTable[i].name, cmdline)) {
|
||||||
val = &valueTable[i];
|
val = &valueTable[i];
|
||||||
printf("%s = ", valueTable[i].name);
|
printf("%s = ", valueTable[i].name);
|
||||||
|
cliPrintVar(val, 0);
|
||||||
if (strstr(valueTable[i].name, "pid_controller")) {
|
|
||||||
void *pidPtr= val->ptr;
|
|
||||||
pidPtr= ((uint8_t *)pidPtr) + (sizeof(profile_t) * masterConfig.current_profile_index);
|
|
||||||
cliPrint(pidControllers[*(uint8_t *)pidPtr-1]);
|
|
||||||
} else {
|
|
||||||
cliPrintVar(val, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
cliPrint("\r\n");
|
cliPrint("\r\n");
|
||||||
|
|
||||||
matchedCommands++;
|
matchedCommands++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue