mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
OP-1290 saved some RAM by removing last alarm update time from UAVObject
(static allocated array instead, and smaller element size)
This commit is contained in:
parent
48876620fc
commit
3018e73e91
@ -37,6 +37,7 @@
|
||||
|
||||
// Private variables
|
||||
static xSemaphoreHandle lock;
|
||||
static volatile uint16_t lastAlarmChange[SYSTEMALARMS_ALARM_NUMELEM] = { 0 }; // this deliberately overflows every 2^16 milliseconds to save memory
|
||||
|
||||
// Private functions
|
||||
static int32_t hasSeverity(SystemAlarmsAlarmOptions severity);
|
||||
@ -75,12 +76,12 @@ int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity
|
||||
|
||||
// Read alarm and update its severity only if it was changed
|
||||
SystemAlarmsGet(&alarms);
|
||||
uint32_t flightTime = xTaskGetTickCount() * portTICK_RATE_MS;
|
||||
if ((flightTime - cast_struct_to_array(alarms.LastChange, alarms.LastChange.Actuator)[alarm] > 1000 &&
|
||||
uint16_t flightTime = xTaskGetTickCount() * portTICK_RATE_MS; // this deliberately overflows every 2^16 milliseconds to save memory
|
||||
if ((flightTime - lastAlarmChange[alarm] > 1000 &&
|
||||
cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] != severity)
|
||||
|| cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] < severity) {
|
||||
cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] = severity;
|
||||
cast_struct_to_array(alarms.LastChange, alarms.LastChange.Actuator)[alarm] = flightTime;
|
||||
lastAlarmChange[alarm] = flightTime;
|
||||
SystemAlarmsSet(&alarms);
|
||||
}
|
||||
|
||||
@ -114,14 +115,14 @@ int32_t ExtendedAlarmsSet(SystemAlarmsAlarmElem alarm,
|
||||
|
||||
// Read alarm and update its severity only if it was changed
|
||||
SystemAlarmsGet(&alarms);
|
||||
uint32_t flightTime = xTaskGetTickCount() * portTICK_RATE_MS;
|
||||
if ((flightTime - cast_struct_to_array(alarms.LastChange, alarms.LastChange.Actuator)[alarm] > 1000 &&
|
||||
uint16_t flightTime = xTaskGetTickCount() * portTICK_RATE_MS; // this deliberately overflows every 2^16 milliseconds to save memory
|
||||
if ((flightTime - lastAlarmChange[alarm] > 1000 &&
|
||||
cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] != severity)
|
||||
|| cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] < severity) {
|
||||
cast_struct_to_array(alarms.ExtendedAlarmStatus, alarms.ExtendedAlarmStatus.BootFault)[alarm] = status;
|
||||
cast_struct_to_array(alarms.ExtendedAlarmSubStatus, alarms.ExtendedAlarmStatus.BootFault)[alarm] = subStatus;
|
||||
cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] = severity;
|
||||
cast_struct_to_array(alarms.LastChange, alarms.LastChange.Actuator)[alarm] = flightTime;
|
||||
lastAlarmChange[alarm] = flightTime;
|
||||
SystemAlarmsSet(&alarms);
|
||||
}
|
||||
|
||||
|
@ -26,31 +26,6 @@
|
||||
<elementname>Power</elementname>
|
||||
</elementnames>
|
||||
</field>
|
||||
<field name="LastChange" units="ms" type="uint32">
|
||||
<elementnames>
|
||||
<elementname>SystemConfiguration</elementname>
|
||||
<elementname>BootFault</elementname>
|
||||
<elementname>OutOfMemory</elementname>
|
||||
<elementname>StackOverflow</elementname>
|
||||
<elementname>CPUOverload</elementname>
|
||||
<elementname>EventSystem</elementname>
|
||||
<elementname>Telemetry</elementname>
|
||||
<elementname>Receiver</elementname>
|
||||
<elementname>ManualControl</elementname>
|
||||
<elementname>Actuator</elementname>
|
||||
<elementname>Attitude</elementname>
|
||||
<elementname>Sensors</elementname>
|
||||
<elementname>Airspeed</elementname>
|
||||
<elementname>Stabilization</elementname>
|
||||
<elementname>Guidance</elementname>
|
||||
<elementname>PathPlan</elementname>
|
||||
<elementname>Battery</elementname>
|
||||
<elementname>FlightTime</elementname>
|
||||
<elementname>I2C</elementname>
|
||||
<elementname>GPS</elementname>
|
||||
<elementname>Power</elementname>
|
||||
</elementnames>
|
||||
</field>
|
||||
<field name="ExtendedAlarmStatus" units="" type="enum" defaultvalue="None">
|
||||
<elementnames>
|
||||
<elementname>SystemConfiguration</elementname>
|
||||
|
Loading…
x
Reference in New Issue
Block a user