1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

Update battery voltage calculation to use a hex value for the 12bit ADC

value.
This commit is contained in:
Dominic Clifton 2014-05-12 00:20:15 +01:00
parent 9f39cad2f9
commit c77c93c8b7

View file

@ -17,8 +17,8 @@ static batteryConfig_t *batteryConfig;
uint16_t batteryAdcToVoltage(uint16_t src)
{
// calculate battery voltage based on ADC reading
// result is Vbatt in 0.1V steps. 3.3V = ADC Vref, 4095 = 12bit adc, 110 = 11:1 voltage divider (10k:1k) * 10 for 0.1V
return (((src) * 3.3f) / 4095) * batteryConfig->vbatscale;
// result is Vbatt in 0.1V steps. 3.3V = ADC Vref, 0xFFF = 12bit adc, 110 = 11:1 voltage divider (10k:1k) * 10 for 0.1V
return (((src) * 3.3f) / 0xFFF) * batteryConfig->vbatscale;
}