Skip to content

Commit

Permalink
#4021 Fix proper scaling using "ratio"
Browse files Browse the repository at this point in the history
1. Remove  code that seems that was not needed and creating problems
  • Loading branch information
frankiearzu authored and pfeerick committed Jan 6, 2024
1 parent 2635a49 commit ba0a6c7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion radio/src/telemetry/telemetry_sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,14 +707,17 @@ 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;
}
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);
Expand Down

0 comments on commit ba0a6c7

Please sign in to comment.