mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 09:28:58 +00:00
battery:Only change the warning level on a connected battery.
Connected is assumed when the battery voltages is greater than a predefined level.
This commit is contained in:
committed by
Daniel Agar
parent
63ac56aeb0
commit
24eb56aa27
@@ -95,7 +95,7 @@ Battery::updateBatteryStatus(hrt_abstime timestamp, float voltage_v, float curre
|
||||
filterCurrent(current_a);
|
||||
sumDischarged(timestamp, current_a);
|
||||
estimateRemaining(voltage_v, current_a, throttle_normalized, armed);
|
||||
determineWarning();
|
||||
determineWarning(connected);
|
||||
computeScale();
|
||||
|
||||
if (_voltage_filtered_v > 2.1f) {
|
||||
@@ -222,17 +222,19 @@ Battery::estimateRemaining(float voltage_v, float current_a, float throttle_norm
|
||||
}
|
||||
|
||||
void
|
||||
Battery::determineWarning()
|
||||
Battery::determineWarning(bool connected)
|
||||
{
|
||||
// Smallest values must come first
|
||||
if (_remaining < _param_emergency_thr.get()) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_EMERGENCY;
|
||||
if (connected) {
|
||||
// Smallest values must come first
|
||||
if (_remaining < _param_emergency_thr.get()) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_EMERGENCY;
|
||||
|
||||
} else if (_remaining < _param_crit_thr.get()) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
|
||||
} else if (_remaining < _param_crit_thr.get()) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
|
||||
|
||||
} else if (_remaining < _param_low_thr.get()) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_LOW;
|
||||
} else if (_remaining < _param_low_thr.get()) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_LOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user