mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 03:53:34 +08:00
Update ADC voltage calculation instances to avoid divide by integer.
This commit is contained in:
@@ -376,7 +376,7 @@ ADC::update_system_power(hrt_abstime now)
|
||||
|
||||
if (_samples[i].am_channel == ADC_5V_RAIL_SENSE) {
|
||||
// it is 2:1 scaled
|
||||
system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096);
|
||||
system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ ADC::update_system_power(void)
|
||||
for (unsigned i = 0; i < _channel_count; i++) {
|
||||
if (_samples[i].am_channel == 4) {
|
||||
// it is 2:1 scaled
|
||||
system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096);
|
||||
system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -281,6 +281,7 @@ int board_adc_init()
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
ADC::init()
|
||||
{
|
||||
@@ -401,7 +402,7 @@ ADC::update_system_power(hrt_abstime now)
|
||||
|
||||
if (_samples[i].am_channel == ADC_SCALED_V5_SENSE) {
|
||||
// it is 2:1 scaled
|
||||
system_power.voltage5V_v = _samples[i].am_data * (ADC_V5_V_FULL_SCALE / 4096);
|
||||
system_power.voltage5V_v = _samples[i].am_data * (ADC_V5_V_FULL_SCALE / 4096.0f);
|
||||
cnt--;
|
||||
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user