1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-1874 - Add notification for Critical alarms, add Attitude, modify alarm repetition rates.

reduce rate for Magnetometer, Receiver. Include Attitude.
This commit is contained in:
Alessio Morale 2015-05-03 23:13:53 +02:00
parent 9a312ef115
commit 9dcd6990d3
2 changed files with 27 additions and 7 deletions

View File

@ -52,7 +52,8 @@ typedef enum {
NOTIFY_SEQUENCE_ALM_CONFIG = 17,
NOTIFY_SEQUENCE_ALM_RECEIVER = 18,
NOTIFY_SEQUENCE_DISARMED = 19,
NOTIFY_SEQUENCE_NULL = 255, // skips any signalling for this condition
NOTIFY_SEQUENCE_ALM_ATTITUDE = 20,
NOTIFY_SEQUENCE_NULL = 255, // skips any signalling for this condition
} NotifySequences;
// This structure determine sequences attached to an alarm
@ -60,6 +61,7 @@ typedef struct {
uint32_t timeBetweenNotifications; // time in milliseconds to wait between each notification iteration
uint8_t alarmIndex; // Index of the alarm, use one of the SYSTEMALARMS_ALARM_XXXXX defines
uint8_t warnNotification; // index of the sequence to be used when alarm is in warning status(pick one from NotifySequences enum)
uint8_t criticalNotification; // index of the sequence to be used when alarm is in critical status(pick one from NotifySequences enum)
uint8_t errorNotification; // index of the sequence to be used when alarm is in error status(pick one from NotifySequences enum)
} AlarmDefinition_t;
@ -156,6 +158,10 @@ const LedSequence_t notifications[] = {
{ .time_off = 50, .time_on = 50, .color = COLOR_ORANGE, .repeats = 9, },
{ .time_off = 500, .time_on = 50, .color = COLOR_ORANGE, .repeats = 1, },
}, },
[NOTIFY_SEQUENCE_ALM_ATTITUDE] = { .repeats = 10, .steps = {
{ .time_off = 0, .time_on = 50, .color = COLOR_RED, .repeats = 1, },
{ .time_off = 0, .time_on = 50, .color = COLOR_BLUE, .repeats = 1, },
}, },
};
// List of background sequences attached to each flight mode
@ -185,32 +191,44 @@ const AlarmDefinition_t alarmsMap[] = {
.timeBetweenNotifications = 10000,
.alarmIndex = SYSTEMALARMS_ALARM_GPS,
.warnNotification = NOTIFY_SEQUENCE_ALM_WARN_GPS,
.criticalNotification = NOTIFY_SEQUENCE_ALM_ERROR_GPS,
.errorNotification = NOTIFY_SEQUENCE_ALM_ERROR_GPS,
},
{
.timeBetweenNotifications = 15000,
.timeBetweenNotifications = 5000,
.alarmIndex = SYSTEMALARMS_ALARM_MAGNETOMETER,
.warnNotification = NOTIFY_SEQUENCE_NULL,
.criticalNotification = NOTIFY_SEQUENCE_ALM_MAG,
.errorNotification = NOTIFY_SEQUENCE_ALM_MAG,
},
{
.timeBetweenNotifications = 15000,
.alarmIndex = SYSTEMALARMS_ALARM_BATTERY,
.warnNotification = NOTIFY_SEQUENCE_ALM_WARN_BATTERY,
.criticalNotification = NOTIFY_SEQUENCE_ALM_ERROR_BATTERY,
.errorNotification = NOTIFY_SEQUENCE_ALM_ERROR_BATTERY,
},
{
.timeBetweenNotifications = 5000,
.alarmIndex = SYSTEMALARMS_ALARM_SYSTEMCONFIGURATION,
.warnNotification = NOTIFY_SEQUENCE_NULL,
.criticalNotification = NOTIFY_SEQUENCE_ALM_CONFIG,
.errorNotification = NOTIFY_SEQUENCE_ALM_CONFIG,
},
{
.timeBetweenNotifications = 5000,
.timeBetweenNotifications = 2000,
.alarmIndex = SYSTEMALARMS_ALARM_RECEIVER,
.warnNotification = NOTIFY_SEQUENCE_ALM_RECEIVER,
.criticalNotification = NOTIFY_SEQUENCE_ALM_RECEIVER,
.errorNotification = NOTIFY_SEQUENCE_ALM_RECEIVER,
},
{
.timeBetweenNotifications = 1000,
.alarmIndex = SYSTEMALARMS_ALARM_ATTITUDE,
.warnNotification = NOTIFY_SEQUENCE_ALM_ATTITUDE,
.criticalNotification = NOTIFY_SEQUENCE_NULL,
.errorNotification = NOTIFY_SEQUENCE_ALM_ATTITUDE,
},
};
const uint8_t alarmsMapSize = NELEMENTS(alarmsMap);

View File

@ -49,7 +49,7 @@ typedef struct {
static void updatedCb(UAVObjEvent *ev);
static void onTimerCb(UAVObjEvent *ev);
static void checkAlarm(uint8_t alarm, uint8_t *last_alarm, uint32_t *last_alm_time,
uint8_t warn_sequence, uint8_t error_sequence,
uint8_t warn_sequence, uint8_t critical_sequence, uint8_t error_sequence,
uint32_t timeBetweenNotifications);
static AlarmStatus_t *alarmStatus;
int32_t NotifyInitialize(void)
@ -111,17 +111,19 @@ void onTimerCb(__attribute__((unused)) UAVObjEvent *ev)
&alarmStatus[i].lastAlarm,
&alarmStatus[i].lastAlarmTime,
alarmsMap[i].warnNotification,
alarmsMap[i].criticalNotification,
alarmsMap[i].errorNotification,
alarmsMap[i].timeBetweenNotifications);
}
}
void checkAlarm(uint8_t alarm, uint8_t *last_alarm, uint32_t *last_alm_time, uint8_t warn_sequence, uint8_t error_sequence, uint32_t timeBetweenNotifications)
void checkAlarm(uint8_t alarm, uint8_t *last_alarm, uint32_t *last_alm_time, uint8_t warn_sequence, uint8_t critical_sequence, uint8_t error_sequence, uint32_t timeBetweenNotifications)
{
if (alarm > SYSTEMALARMS_ALARM_OK) {
uint32_t current_time = PIOS_DELAY_GetuS();
if (*last_alarm < alarm || *last_alm_time + timeBetweenNotifications * 1000 < current_time) {
uint8_t sequence = (alarm == SYSTEMALARMS_ALARM_WARNING) ? warn_sequence : error_sequence;
if (*last_alarm < alarm || *last_alm_time + timeBetweenNotifications * 1000 > current_time) {
uint8_t sequence = (alarm == SYSTEMALARMS_ALARM_WARNING) ? warn_sequence :
((alarm == SYSTEMALARMS_ALARM_CRITICAL) ? critical_sequence : error_sequence);
if (sequence != NOTIFY_SEQUENCE_NULL) {
PIOS_NOTIFICATION_Default_Ext_Led_Play(
&notifications[sequence],