mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Merge pull request #7061 from pulquero/support_uint32_set_vars
Support for setting uint32 vars.
This commit is contained in:
commit
3259abfbc0
2 changed files with 39 additions and 14 deletions
|
@ -445,12 +445,23 @@ static void printValuePointer(const clivalue_t *var, const void *valuePointer, b
|
||||||
|
|
||||||
switch (var->type & VALUE_MODE_MASK) {
|
switch (var->type & VALUE_MODE_MASK) {
|
||||||
case MODE_DIRECT:
|
case MODE_DIRECT:
|
||||||
if ((value < var->config.minmax.min) || (value > var->config.minmax.max)) {
|
if ((var->type & VALUE_TYPE_MASK) == VAR_UINT32) {
|
||||||
cliPrintCorruptMessage(value);
|
if ((uint32_t) value > var->config.u32_max) {
|
||||||
|
cliPrintCorruptMessage(value);
|
||||||
|
} else {
|
||||||
|
cliPrintf("%d", value);
|
||||||
|
if (full) {
|
||||||
|
cliPrintf(" 0 %d", var->config.u32_max);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cliPrintf("%d", value);
|
if ((value < var->config.minmax.min) || (value > var->config.minmax.max)) {
|
||||||
if (full) {
|
cliPrintCorruptMessage(value);
|
||||||
cliPrintf(" %d %d", var->config.minmax.min, var->config.minmax.max);
|
} else {
|
||||||
|
cliPrintf("%d", value);
|
||||||
|
if (full) {
|
||||||
|
cliPrintf(" %d %d", var->config.minmax.min, var->config.minmax.max);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -628,7 +639,7 @@ static void cliPrintVarRange(const clivalue_t *var)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cliSetVar(const clivalue_t *var, const int16_t value)
|
static void cliSetVar(const clivalue_t *var, const uint32_t value)
|
||||||
{
|
{
|
||||||
void *ptr = cliGetValuePointer(var);
|
void *ptr = cliGetValuePointer(var);
|
||||||
uint32_t workValue;
|
uint32_t workValue;
|
||||||
|
@ -681,6 +692,10 @@ static void cliSetVar(const clivalue_t *var, const int16_t value)
|
||||||
case VAR_INT16:
|
case VAR_INT16:
|
||||||
*(int16_t *)ptr = value;
|
*(int16_t *)ptr = value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VAR_UINT32:
|
||||||
|
*(uint32_t *)ptr = value;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3433,11 +3448,20 @@ STATIC_UNIT_TESTED void cliSet(char *cmdline)
|
||||||
int16_t value = 0;
|
int16_t value = 0;
|
||||||
switch (val->type & VALUE_MODE_MASK) {
|
switch (val->type & VALUE_MODE_MASK) {
|
||||||
case MODE_DIRECT: {
|
case MODE_DIRECT: {
|
||||||
int16_t value = atoi(eqptr);
|
if ((val->type & VALUE_TYPE_MASK) == VAR_UINT32) {
|
||||||
|
uint32_t value = strtol(eqptr, NULL, 10);
|
||||||
|
|
||||||
if (value >= val->config.minmax.min && value <= val->config.minmax.max) {
|
if (value <= val->config.u32_max) {
|
||||||
cliSetVar(val, value);
|
cliSetVar(val, value);
|
||||||
valueChanged = true;
|
valueChanged = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int16_t value = atoi(eqptr);
|
||||||
|
|
||||||
|
if (value >= val->config.minmax.min && value <= val->config.minmax.max) {
|
||||||
|
cliSetVar(val, value);
|
||||||
|
valueChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,10 +181,11 @@ typedef struct cliArrayLengthConfig_s {
|
||||||
} cliArrayLengthConfig_t;
|
} cliArrayLengthConfig_t;
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
cliLookupTableConfig_t lookup;
|
cliLookupTableConfig_t lookup; // used for MODE_LOOKUP excl. VAR_UINT32
|
||||||
cliMinMaxConfig_t minmax;
|
cliMinMaxConfig_t minmax; // used for MODE_DIRECT
|
||||||
cliArrayLengthConfig_t array;
|
cliArrayLengthConfig_t array; // used for MODE_ARRAY
|
||||||
uint8_t bitpos;
|
uint8_t bitpos; // used for MODE_BITSET
|
||||||
|
uint32_t u32_max; // used for MODE_DIRECT with VAR_UINT32
|
||||||
} cliValueConfig_t;
|
} cliValueConfig_t;
|
||||||
|
|
||||||
typedef struct clivalue_s {
|
typedef struct clivalue_s {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue