AP_BattMonitor: torqeedo support for multiple instances

This commit is contained in:
Randy Mackay 2024-03-12 12:56:15 +09:00 committed by Andrew Tridgell
parent 72718bb783
commit e605f961f2
1 changed files with 4 additions and 2 deletions

View File

@ -35,10 +35,11 @@ void AP_BattMonitor_Torqeedo::read(void)
} }
// get voltage, current, temp and remaining capacity percentage // get voltage, current, temp and remaining capacity percentage
// assumes battery monitor instance matches torqeedo instance
float volts; float volts;
float current_amps; float current_amps;
float temp_C; float temp_C;
if (torqeedo->get_batt_info(volts, current_amps, temp_C, remaining_pct)) { if (torqeedo->get_batt_info(_state.instance, volts, current_amps, temp_C, remaining_pct)) {
have_info = true; have_info = true;
_state.voltage = volts; _state.voltage = volts;
_state.current_amps = current_amps; _state.current_amps = current_amps;
@ -56,9 +57,10 @@ void AP_BattMonitor_Torqeedo::read(void)
} }
// read battery pack capacity // read battery pack capacity
// assumes battery monitor instance matches torqeedo instance
if (!have_capacity) { if (!have_capacity) {
uint16_t batt_capacity_ah; uint16_t batt_capacity_ah;
if (torqeedo->get_batt_capacity_Ah(batt_capacity_ah)) { if (torqeedo->get_batt_capacity_Ah(_state.instance, batt_capacity_ah)) {
have_capacity = true; have_capacity = true;
if (batt_capacity_ah * 1000 != _params._pack_capacity) { if (batt_capacity_ah * 1000 != _params._pack_capacity) {
_params._pack_capacity.set_and_notify(batt_capacity_ah * 1000); _params._pack_capacity.set_and_notify(batt_capacity_ah * 1000);