From 79e152e1bfe95b1db6020a33bd445d87c78804d6 Mon Sep 17 00:00:00 2001 From: "bsongis@gmail.com" Date: Sun, 4 Aug 2013 21:56:24 +0000 Subject: [PATCH] [stock] Issue 86 fixed (tx voltage calibration issue) --- src/opentx.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/opentx.cpp b/src/opentx.cpp index 932c621c8..adb0d77d8 100644 --- a/src/opentx.cpp +++ b/src/opentx.cpp @@ -3822,20 +3822,17 @@ void perMain() } if (counter-- == 0) { counter = 10; -#if defined(PCBTARANIS) int32_t instant_vbat = anaIn(TX_VOLTAGE); +#if defined(PCBTARANIS) instant_vbat = (instant_vbat + instant_vbat*(g_eeGeneral.vBatCalib)/128) * BATT_SCALE; instant_vbat >>= 11; instant_vbat += 2; // because of the diode #elif defined(PCBSKY9X) - int32_t instant_vbat = anaIn(TX_VOLTAGE); instant_vbat = (instant_vbat + instant_vbat*(g_eeGeneral.vBatCalib)/128) * 4191; instant_vbat /= 55296; #elif defined(PCBGRUVIN9X) - uint16_t instant_vbat = anaIn(TX_VOLTAGE); - instant_vbat = ((uint32_t)instant_vbat*1112 + (int32_t)instant_vbat*g_eeGeneral.vBatCalib + (BandGap<<2)) / (BandGap<<3); + instant_vbat = (instant_vbat*1112 + instant_vbat*g_eeGeneral.vBatCalib + (BandGap<<2)) / (BandGap<<3); #else - uint16_t instant_vbat = anaIn(TX_VOLTAGE); instant_vbat = (instant_vbat*16 + instant_vbat*g_eeGeneral.vBatCalib/8) / BandGap; #endif