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:
parent
9f39cad2f9
commit
c77c93c8b7
1 changed files with 2 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue