fix: Properly scale PREC2 sensor values using "ratio" (#4083)
This commit is contained in:
@@ -707,6 +707,7 @@ int32_t convertTelemetryValue(int32_t value, uint8_t unit, uint8_t prec, uint8_t
|
||||
int32_t TelemetrySensor::getValue(int32_t value, uint8_t unit, uint8_t prec) const
|
||||
{
|
||||
if (type == TELEM_TYPE_CUSTOM && custom.ratio) {
|
||||
/* farzu: Not needed, scaling work properly for the 3 types of prec without it
|
||||
if (this->prec == 2) {
|
||||
value *= 10;
|
||||
prec = 2;
|
||||
@@ -714,7 +715,9 @@ int32_t TelemetrySensor::getValue(int32_t value, uint8_t unit, uint8_t prec) con
|
||||
else {
|
||||
prec = 1;
|
||||
}
|
||||
value = (custom.ratio * value + 122) / 255;
|
||||
*/
|
||||
|
||||
value = (custom.ratio * value + 122) / 255; // 122/255 (0.48) is to aproximate up (ceiling)
|
||||
}
|
||||
|
||||
value = convertTelemetryValue(value, unit, prec, this->unit, this->prec);
|
||||
|
||||
Reference in New Issue
Block a user