mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 02:01:35 +08:00
battery: separate out publishing from updating
to allow smart battery drivers to use the battery class and filling in additional information in case it makes sense.
This commit is contained in:
@@ -71,7 +71,7 @@ INA238::INA238(const I2CSPIDriverConfig &config, int battery_index) :
|
||||
_battery.setConnected(false);
|
||||
_battery.updateVoltage(0.f);
|
||||
_battery.updateCurrent(0.f);
|
||||
_battery.updateBatteryStatus(hrt_absolute_time());
|
||||
_battery.updateAndPublishBatteryStatus(hrt_absolute_time());
|
||||
}
|
||||
|
||||
INA238::~INA238()
|
||||
@@ -197,7 +197,7 @@ int INA238::collect()
|
||||
_battery.setConnected(success);
|
||||
_battery.updateVoltage(static_cast<float>(bus_voltage * INA238_VSCALE));
|
||||
_battery.updateCurrent(static_cast<float>(current * _current_lsb));
|
||||
_battery.updateBatteryStatus(hrt_absolute_time());
|
||||
_battery.updateAndPublishBatteryStatus(hrt_absolute_time());
|
||||
|
||||
perf_end(_sample_perf);
|
||||
|
||||
@@ -254,7 +254,7 @@ void INA238::RunImpl()
|
||||
_battery.setConnected(false);
|
||||
_battery.updateVoltage(0.f);
|
||||
_battery.updateCurrent(0.f);
|
||||
_battery.updateBatteryStatus(hrt_absolute_time());
|
||||
_battery.updateAndPublishBatteryStatus(hrt_absolute_time());
|
||||
|
||||
if (init() != PX4_OK) {
|
||||
ScheduleDelayed(INA238_INIT_RETRY_INTERVAL_US);
|
||||
|
||||
Reference in New Issue
Block a user