Fix for negative gvars precision - inspired by #6446 thanks @ elecpower
This commit is contained in:
+3
-9
@@ -48,18 +48,12 @@ int16_t getGVarValue(int8_t gv, int8_t fm)
|
|||||||
|
|
||||||
int32_t getGVarValuePrec1(int8_t gv, int8_t fm)
|
int32_t getGVarValuePrec1(int8_t gv, int8_t fm)
|
||||||
{
|
{
|
||||||
int8_t mul;
|
int8_t idx = (gv >= 0 ? gv : -idx - 1);
|
||||||
uint8_t prec = g_model.gvars[abs((int)gv)].prec; // explicit cast to `int` needed, othervise gv is promoted to double!
|
int8_t mul = (g_model.gvars[idx].prec == 0 ? 10 : 1); // explicit cast to `int` needed, othervise gv is promoted to double!
|
||||||
if (prec == 0)
|
|
||||||
mul = 10;
|
|
||||||
else
|
|
||||||
mul = 1;
|
|
||||||
|
|
||||||
if (gv < 0) {
|
if (gv < 0) {
|
||||||
gv = -1-gv;
|
|
||||||
mul = -mul;
|
mul = -mul;
|
||||||
}
|
}
|
||||||
return GVAR_VALUE(gv, getGVarFlightMode(fm, gv)) * mul;
|
return GVAR_VALUE(idx, getGVarFlightMode(fm, idx)) * mul;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setGVarValue(uint8_t gv, int16_t value, int8_t fm)
|
void setGVarValue(uint8_t gv, int16_t value, int8_t fm)
|
||||||
|
|||||||
Reference in New Issue
Block a user