mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 16:25:26 +03:00
Port from BF: Show Allowed values or range on get commands (#411)
This commit is contained in:
parent
0489eb8b08
commit
742f429d70
1 changed files with 29 additions and 4 deletions
|
@ -802,7 +802,7 @@ const clivalue_t valueTable[] = {
|
||||||
{ "max_angle_inclination_rll", VAR_INT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.max_angle_inclination[FD_ROLL], .config.minmax = { 100, 900 }, 0 },
|
{ "max_angle_inclination_rll", VAR_INT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.max_angle_inclination[FD_ROLL], .config.minmax = { 100, 900 }, 0 },
|
||||||
{ "max_angle_inclination_pit", VAR_INT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.max_angle_inclination[FD_PITCH], .config.minmax = { 100, 900 }, 0 },
|
{ "max_angle_inclination_pit", VAR_INT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.max_angle_inclination[FD_PITCH], .config.minmax = { 100, 900 }, 0 },
|
||||||
|
|
||||||
{ "gyro_soft_lpf_hz", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.gyro_soft_lpf_hz, .config.minmax = {0, 200 } },
|
{ "gyro_soft_lpf_hz", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.gyro_soft_lpf_hz, .config.minmax = {0, 200 } },
|
||||||
{ "acc_soft_lpf_hz", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.acc_soft_lpf_hz, .config.minmax = {0, 200 } },
|
{ "acc_soft_lpf_hz", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.acc_soft_lpf_hz, .config.minmax = {0, 200 } },
|
||||||
{ "dterm_lpf_hz", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.dterm_lpf_hz, .config.minmax = {0, 200 } },
|
{ "dterm_lpf_hz", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.dterm_lpf_hz, .config.minmax = {0, 200 } },
|
||||||
{ "yaw_lpf_hz", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.yaw_lpf_hz, .config.minmax = {0, 200 } },
|
{ "yaw_lpf_hz", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.yaw_lpf_hz, .config.minmax = {0, 200 } },
|
||||||
|
@ -846,6 +846,7 @@ typedef union {
|
||||||
|
|
||||||
static void cliSetVar(const clivalue_t *var, const int_float_value_t value);
|
static void cliSetVar(const clivalue_t *var, const int_float_value_t value);
|
||||||
static void cliPrintVar(const clivalue_t *var, uint32_t full);
|
static void cliPrintVar(const clivalue_t *var, uint32_t full);
|
||||||
|
static void cliPrintVarRange(const clivalue_t *var);
|
||||||
static void cliPrint(const char *str);
|
static void cliPrint(const char *str);
|
||||||
static void cliPrintf(const char *fmt, ...);
|
static void cliPrintf(const char *fmt, ...);
|
||||||
static void cliWrite(uint8_t ch);
|
static void cliWrite(uint8_t ch);
|
||||||
|
@ -2521,6 +2522,28 @@ static void cliPrintVar(const clivalue_t *var, uint32_t full)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cliPrintVarRange(const clivalue_t *var)
|
||||||
|
{
|
||||||
|
switch (var->type & VALUE_MODE_MASK) {
|
||||||
|
case (MODE_DIRECT): {
|
||||||
|
cliPrintf("Allowed range: %d - %d\r\n", var->config.minmax.min, var->config.minmax.max);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case (MODE_LOOKUP): {
|
||||||
|
const lookupTableEntry_t *tableEntry = &lookupTables[var->config.lookup.tableIndex];
|
||||||
|
cliPrint("Allowed values:");
|
||||||
|
uint8_t i;
|
||||||
|
for (i = 0; i < tableEntry->valueCount ; i++) {
|
||||||
|
if (i > 0)
|
||||||
|
cliPrint(",");
|
||||||
|
cliPrintf(" %s", tableEntry->values[i]);
|
||||||
|
}
|
||||||
|
cliPrint("\r\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void cliSetVar(const clivalue_t *var, const int_float_value_t value)
|
static void cliSetVar(const clivalue_t *var, const int_float_value_t value)
|
||||||
{
|
{
|
||||||
void *ptr = var->ptr;
|
void *ptr = var->ptr;
|
||||||
|
@ -2638,8 +2661,8 @@ static void cliSet(char *cmdline)
|
||||||
cliPrintf("%s set to ", valueTable[i].name);
|
cliPrintf("%s set to ", valueTable[i].name);
|
||||||
cliPrintVar(val, 0);
|
cliPrintVar(val, 0);
|
||||||
} else {
|
} else {
|
||||||
cliPrint("Invalid value. Allowed values are: ");
|
cliPrint("Invalid value.");
|
||||||
cliPrintVar(val, 1); // print out min/max/table values
|
cliPrintVarRange(val);
|
||||||
cliPrint("\r\n");
|
cliPrint("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2664,6 +2687,8 @@ static void cliGet(char *cmdline)
|
||||||
val = &valueTable[i];
|
val = &valueTable[i];
|
||||||
cliPrintf("%s = ", valueTable[i].name);
|
cliPrintf("%s = ", valueTable[i].name);
|
||||||
cliPrintVar(val, 0);
|
cliPrintVar(val, 0);
|
||||||
|
cliPrint("\n");
|
||||||
|
cliPrintVarRange(val);
|
||||||
cliPrint("\r\n");
|
cliPrint("\r\n");
|
||||||
|
|
||||||
matchedCommands++;
|
matchedCommands++;
|
||||||
|
@ -2672,7 +2697,7 @@ static void cliGet(char *cmdline)
|
||||||
|
|
||||||
|
|
||||||
if (matchedCommands) {
|
if (matchedCommands) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPrint("Invalid name\r\n");
|
cliPrint("Invalid name\r\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue