Browse Source

AP_BattMonitor: add floating point constant designators

master
Peter Barker 6 years ago committed by Tom Pittenger
parent
commit
e4b928be4d
  1. 6
      libraries/AP_BattMonitor/AP_BattMonitor_FuelFlow.cpp
  2. 2
      libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Solo.cpp

6
libraries/AP_BattMonitor/AP_BattMonitor_FuelFlow.cpp

@ -81,7 +81,7 @@ void AP_BattMonitor_FuelFlow::read()
_state.last_time_micros = now_us; _state.last_time_micros = now_us;
return; return;
} }
float dt = (now_us - _state.last_time_micros) * 1.0e-6; float dt = (now_us - _state.last_time_micros) * 1.0e-6f;
if (dt < 1 && irq_state.pulse_count == 0) { if (dt < 1 && irq_state.pulse_count == 0) {
// we allow for up to 1 second with no pulses to cope with low // we allow for up to 1 second with no pulses to cope with low
@ -101,13 +101,13 @@ void AP_BattMonitor_FuelFlow::read()
this driver assumes that BATTx_AMP_PERVLT is set to give the this driver assumes that BATTx_AMP_PERVLT is set to give the
number of millilitres per pulse. number of millilitres per pulse.
*/ */
float irq_dt = state.total_us * 1.0e-6; float irq_dt = state.total_us * 1.0e-6f;
float litres, litres_pec_sec; float litres, litres_pec_sec;
if (state.pulse_count == 0) { if (state.pulse_count == 0) {
litres = 0; litres = 0;
litres_pec_sec = 0; litres_pec_sec = 0;
} else { } else {
litres = state.pulse_count * _params._curr_amp_per_volt * 0.001; litres = state.pulse_count * _params._curr_amp_per_volt * 0.001f;
litres_pec_sec = litres / irq_dt; litres_pec_sec = litres / irq_dt;
} }

2
libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Solo.cpp

@ -53,7 +53,7 @@ void AP_BattMonitor_SMBus_Solo::timer()
// because the Solo's I2C bus is so noisy, it's worth not spending the // because the Solo's I2C bus is so noisy, it's worth not spending the
// time and bus bandwidth to request the pack voltage as a seperate // time and bus bandwidth to request the pack voltage as a seperate
// transaction // transaction
_state.voltage = pack_voltage_mv * 1e-3; _state.voltage = pack_voltage_mv * 1e-3f;
_state.last_time_micros = tnow; _state.last_time_micros = tnow;
_state.healthy = true; _state.healthy = true;
} }

Loading…
Cancel
Save