Battery estimator: Warn on dangerously low levels.

We need to differentiate between a level where the user should act and where we are about to fall out of the sky (emergency). This helps performing more suitable failsafe actions.
This commit is contained in:
Lorenz Meier
2017-02-22 22:03:21 +01:00
parent 7372014aee
commit 029c6de4a9
3 changed files with 24 additions and 3 deletions
+5 -1
View File
@@ -51,6 +51,7 @@ Battery::Battery() :
_param_r_internal(this, "R_INTERNAL"),
_param_low_thr(this, "LOW_THR"),
_param_crit_thr(this, "CRIT_THR"),
_param_emergency_thr(this, "EMERGEN_THR"),
_voltage_filtered_v(-1.0f),
_discharged_mah(0.0f),
_remaining_voltage(1.0f),
@@ -219,7 +220,10 @@ void
Battery::determineWarning()
{
// Smallest values must come first
if (_remaining < _param_crit_thr.get()) {
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_low_thr.get()) {