Using the right precision for unknown (custom) sensors (#7508)
Co-authored-by: Herman Kruisman <herman@server.thuis.local>
This commit is contained in:
co-authored by
Herman Kruisman
parent
9c632b582d
commit
ce3f8374a1
@@ -130,7 +130,7 @@ uint16_t rboxState;
|
|||||||
void sportProcessTelemetryPacket(uint16_t id, uint8_t subId, uint8_t instance, uint32_t data, TelemetryUnit unit=UNIT_RAW)
|
void sportProcessTelemetryPacket(uint16_t id, uint8_t subId, uint8_t instance, uint32_t data, TelemetryUnit unit=UNIT_RAW)
|
||||||
{
|
{
|
||||||
const FrSkySportSensor * sensor = getFrSkySportSensor(id, subId);
|
const FrSkySportSensor * sensor = getFrSkySportSensor(id, subId);
|
||||||
uint8_t precision = 0;
|
uint8_t precision = 255;
|
||||||
if (sensor) {
|
if (sensor) {
|
||||||
if (unit == UNIT_RAW)
|
if (unit == UNIT_RAW)
|
||||||
unit = sensor->unit;
|
unit = sensor->unit;
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t val, uint32
|
|||||||
{
|
{
|
||||||
int32_t newVal = val;
|
int32_t newVal = val;
|
||||||
|
|
||||||
|
if(prec == 255) {
|
||||||
|
prec = sensor.prec;
|
||||||
|
}
|
||||||
|
|
||||||
if (unit == UNIT_CELLS) {
|
if (unit == UNIT_CELLS) {
|
||||||
uint32_t data = uint32_t(newVal);
|
uint32_t data = uint32_t(newVal);
|
||||||
uint8_t cellsCount = (data >> 24);
|
uint8_t cellsCount = (data >> 24);
|
||||||
|
|||||||
Reference in New Issue
Block a user