From 1560fa8bd9cd2793632d99763e12e3079521a1af Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 19 Jun 2014 10:13:11 +0200 Subject: [PATCH] Companion bug in speed values (Logical Switches) --- companion/src/eeprominterface.cpp | 16 ++++++++++++---- companion/src/eeprominterface.h | 2 +- companion/src/firmwares/opentx/opentxeeprom.cpp | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index c0c745001..fd4804dd6 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "eeprominterface.h" #include "firmwares/er9x/er9xinterface.h" #include "firmwares/th9x/th9xinterface.h" @@ -103,6 +104,10 @@ RawSourceRange RawSource::getRange(bool singleprec) switch (type) { case SOURCE_TYPE_TELEMETRY: + if (singleprec) { + result.offset = -DBL_MAX; + } + switch (index) { case TELEMETRY_SOURCE_TX_BATT: result.step = 0.1; @@ -165,10 +170,12 @@ RawSourceRange RawSource::getRange(bool singleprec) case TELEMETRY_SOURCE_FUEL: result.max = 100; break; + case TELEMETRY_SOURCE_ASPEED: + case TELEMETRY_SOURCE_ASPEED_MAX: case TELEMETRY_SOURCE_SPEED: case TELEMETRY_SOURCE_SPEED_MAX: - result.step = singleprec ? 4 : 1; - result.max = singleprec ? (4*236) : 2000; + result.step = singleprec ? 1 : 1; + result.max = singleprec ? (1*255) : 2000; if (model && !model->frsky.imperial) { result.step *= 1.852; result.max *= 1.852; @@ -225,14 +232,15 @@ RawSourceRange RawSource::getRange(bool singleprec) result.max = 125; break; } - if (singleprec && !result.offset) { + + if (singleprec && result.offset==-DBL_MAX) { result.offset = result.max - (127*result.step); } break; default: result.max = (model && model->extendedLimits ? 125 : 100); - result.min = - result.max; + result.min = -result.max; break; } diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index a4ceddde4..ea7aed2cb 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -252,7 +252,7 @@ enum TelemetrySource { TELEMETRY_SOURCE_ACCZ, TELEMETRY_SOURCE_HDG, TELEMETRY_SOURCE_VERTICAL_SPEED, - TELEMETRY_SOURCE_ASPD, + TELEMETRY_SOURCE_ASPEED, TELEMETRY_SOURCE_DTE, TELEMETRY_SOURCE_A1_MIN, TELEMETRY_SOURCE_A2_MIN, diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index c42e80483..dd4dd8f3b 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -260,7 +260,7 @@ class SourcesConversionTable: public ConversionTable { for (int i=0; i= 216) { - addConversion(1+TELEMETRY_SOURCE_ASPD, val++); + addConversion(1+TELEMETRY_SOURCE_ASPEED, val++); addConversion(1+TELEMETRY_SOURCE_DTE, val++); } if (IS_ARM(board) && version >= 216) {