forked from Archive/PX4-Autopilot
batteryCheck: improve user notification for low battery events
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
parent
bc19ccdd1f
commit
b7f8ee8ee7
|
@ -195,6 +195,7 @@ void BatteryChecks::checkAndReport(const Context &context, Report &reporter)
|
|||
}
|
||||
|
||||
if (context.isArmed()) {
|
||||
// if armed, only allow increase of battery warning severity
|
||||
if (worst_warning > reporter.failsafeFlags().battery_warning) {
|
||||
reporter.failsafeFlags().battery_warning = worst_warning;
|
||||
}
|
||||
|
@ -205,16 +206,23 @@ void BatteryChecks::checkAndReport(const Context &context, Report &reporter)
|
|||
|
||||
if (reporter.failsafeFlags().battery_warning > battery_status_s::BATTERY_WARNING_NONE
|
||||
&& reporter.failsafeFlags().battery_warning < battery_status_s::BATTERY_WARNING_FAILED) {
|
||||
bool critical_or_higher = reporter.failsafeFlags().battery_warning >= battery_status_s::BATTERY_WARNING_CRITICAL;
|
||||
const bool critical_or_higher = reporter.failsafeFlags().battery_warning >= battery_status_s::BATTERY_WARNING_CRITICAL;
|
||||
NavModes affected_modes = critical_or_higher ? NavModes::All : NavModes::None;
|
||||
events::LogLevel log_level = critical_or_higher ? events::Log::Critical : events::Log::Warning;
|
||||
/* EVENT
|
||||
* @description
|
||||
* The battery state of charge of the worst battery is below the warning threshold.
|
||||
*
|
||||
* <profile name="dev">
|
||||
* This check can be configured via <param>BAT_LOW_THR</param>, <param>BAT_CRIT_THR</param> and <param>BAT_EMERGEN_THR</param> parameters.
|
||||
* </profile>
|
||||
*/
|
||||
reporter.armingCheckFailure(affected_modes, health_component_t::battery, events::ID("check_battery_low"), log_level,
|
||||
"Low battery");
|
||||
|
||||
if (reporter.mavlink_log_pub()) {
|
||||
mavlink_log_emergency(reporter.mavlink_log_pub(), "Preflight Fail: low battery\t");
|
||||
mavlink_log_emergency(reporter.mavlink_log_pub(), "Low battery level\t");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue