[Taranis] Overflow with negative battery calibration value

This commit is contained in:
bernet.andre@gmail.com
2013-05-13 21:03:58 +00:00
parent ed268ff085
commit 406d17ff35
+1 -1
View File
@@ -991,7 +991,7 @@ void menuGeneralDiagAna(uint8_t event)
lcd_putsLeft(6*FH+1, STR_BATT_CALIB);
static uint32_t adcBatt;
adcBatt = ((adcBatt * 7) + anaIn(8)) / 8; // running average, sourced directly (to avoid unending debate :P)
uint32_t batCalV = ( adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128 ) * BATT_SCALE;
uint32_t batCalV = ( adcBatt + ((int32_t)adcBatt*g_eeGeneral.vBatCalib)/128 ) * BATT_SCALE;
batCalV >>= 11;
batCalV += 2; // because of the diode
putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, batCalV, (m_posVert==1 ? INVERS : 0));