mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
OP-994 Exclude alarm for estimated flight time if Capacity setting is 0
+review OPReview-506
This commit is contained in:
parent
402c84c003
commit
104bae01e8
@ -160,10 +160,10 @@ static void onTimer(__attribute__((unused)) UAVObjEvent *ev)
|
||||
it makes sense to saturate at max and min values, because a misreading could as easily be very large, as negative. The simple
|
||||
sign check doesn't catch this.*/
|
||||
energyRemaining = batterySettings.Capacity - flightBatteryData.ConsumedEnergy; // in mAh
|
||||
if (flightBatteryData.AvgCurrent > 0) {
|
||||
if (batterySettings.Capacity > 0 && flightBatteryData.AvgCurrent > 0) {
|
||||
flightBatteryData.EstimatedFlightTime = (energyRemaining / (flightBatteryData.AvgCurrent * 1000.0f)) * 3600.0f; // in Sec
|
||||
} else {
|
||||
flightBatteryData.EstimatedFlightTime = 9999;
|
||||
flightBatteryData.EstimatedFlightTime = 0;
|
||||
}
|
||||
|
||||
// generate alarms where needed...
|
||||
@ -174,9 +174,9 @@ static void onTimer(__attribute__((unused)) UAVObjEvent *ev)
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_FLIGHTTIME, SYSTEMALARMS_ALARM_ERROR);
|
||||
} else {
|
||||
// FIXME: should make the timer alarms user configurable
|
||||
if (flightBatteryData.EstimatedFlightTime < 30) {
|
||||
if (batterySettings.Capacity > 0 && flightBatteryData.EstimatedFlightTime < 30) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_FLIGHTTIME, SYSTEMALARMS_ALARM_CRITICAL);
|
||||
} else if (flightBatteryData.EstimatedFlightTime < 120) {
|
||||
} else if (batterySettings.Capacity > 0 && flightBatteryData.EstimatedFlightTime < 120) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_FLIGHTTIME, SYSTEMALARMS_ALARM_WARNING);
|
||||
} else {
|
||||
AlarmsClear(SYSTEMALARMS_ALARM_FLIGHTTIME);
|
||||
|
Loading…
x
Reference in New Issue
Block a user