1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Merge remote-tracking branch 'origin/amorale/OP-1874_notifications_improvements' into HEAD

This commit is contained in:
Alessio Morale 2015-05-18 10:05:56 +02:00
commit 330b396a73
2 changed files with 28 additions and 8 deletions

View File

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

View File

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