Skip to content

Commit

Permalink
AP_BattMonitor: Change to floating value multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
muramura committed Aug 13, 2023
1 parent 484312d commit c7bcf7a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions libraries/AP_BattMonitor/AP_BattMonitor_Torqeedo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void AP_BattMonitor_Torqeedo::read(void)
const uint32_t tnow_us = AP_HAL::micros();
const uint32_t diff_us = tnow_us - _state.last_time_micros;
if (diff_us < AP_BATTMON_TORQEEDO_TIMEOUT_US) {
_state.consumed_mah += _state.current_amps * diff_us / 1000000.0 / 3600.0 * 1000.0;
_state.consumed_mah += _state.current_amps * diff_us * 1e-6f / 3600.0 * 1000.0;
}
_state.last_time_micros = tnow_us;
_state.healthy = true;
Expand Down Expand Up @@ -77,4 +77,3 @@ bool AP_BattMonitor_Torqeedo::capacity_remaining_pct(uint8_t &percentage) const
}

#endif // AP_BATTERY_TORQEEDO_ENABLED

0 comments on commit c7bcf7a

Please sign in to comment.