2014-08-13 15:18:17 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file sequences.h
|
2016-03-14 23:02:07 +01:00
|
|
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
|
|
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
2014-08-13 15:18:17 +02:00
|
|
|
* @brief Notify module, sequences configuration.
|
|
|
|
*
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
#ifndef SEQUENCES_H_
|
|
|
|
#define SEQUENCES_H_
|
|
|
|
#include <optypes.h>
|
|
|
|
#include <pios_notify.h>
|
|
|
|
#include <flightstatus.h>
|
|
|
|
#include <systemalarms.h>
|
|
|
|
#include <pios_helpers.h>
|
|
|
|
|
2014-08-18 16:35:02 +02:00
|
|
|
// This represent the list of basic light sequences, defined later
|
2014-08-13 15:18:17 +02:00
|
|
|
typedef enum {
|
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_MANUAL = 0,
|
2016-07-17 17:19:34 +02:00
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_STABILIZED1,
|
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_STABILIZED2,
|
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_STABILIZED3,
|
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_STABILIZED4,
|
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_STABILIZED5,
|
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_STABILIZED6,
|
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_GPS,
|
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_RTH,
|
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_LAND,
|
|
|
|
NOTIFY_SEQUENCE_ARMED_FM_AUTO,
|
|
|
|
NOTIFY_SEQUENCE_ALM_WARN_GPS,
|
|
|
|
NOTIFY_SEQUENCE_ALM_ERROR_GPS,
|
|
|
|
NOTIFY_SEQUENCE_ALM_WARN_BATTERY,
|
|
|
|
NOTIFY_SEQUENCE_ALM_ERROR_BATTERY,
|
|
|
|
NOTIFY_SEQUENCE_ALM_WARN_MAG,
|
|
|
|
NOTIFY_SEQUENCE_ALM_ERROR_MAG,
|
|
|
|
NOTIFY_SEQUENCE_ALM_CONFIG,
|
|
|
|
NOTIFY_SEQUENCE_ALM_RECEIVER,
|
|
|
|
NOTIFY_SEQUENCE_DISARMED,
|
|
|
|
NOTIFY_SEQUENCE_ALM_ATTITUDE,
|
2015-05-03 23:13:53 +02:00
|
|
|
NOTIFY_SEQUENCE_NULL = 255, // skips any signalling for this condition
|
2014-08-13 15:18:17 +02:00
|
|
|
} NotifySequences;
|
|
|
|
|
2014-08-18 16:35:02 +02:00
|
|
|
// This structure determine sequences attached to an alarm
|
2014-08-13 15:18:17 +02:00
|
|
|
typedef struct {
|
2014-08-18 16:35:02 +02:00
|
|
|
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)
|
2015-05-03 23:13:53 +02:00
|
|
|
uint8_t criticalNotification; // index of the sequence to be used when alarm is in critical status(pick one from NotifySequences enum)
|
2014-08-18 16:35:02 +02:00
|
|
|
uint8_t errorNotification; // index of the sequence to be used when alarm is in error status(pick one from NotifySequences enum)
|
2014-08-13 15:18:17 +02:00
|
|
|
} AlarmDefinition_t;
|
|
|
|
|
2016-07-17 17:19:34 +02:00
|
|
|
#define STANDARD_ERROR_SEQUENCE(alarm_color, alarm_repeats) \
|
|
|
|
{ .repeats = alarm_repeats, .steps = { \
|
|
|
|
{ .time_off = 200, .time_on = 10, .color = COLOR_BLACK, .repeats = 1, }, \
|
|
|
|
{ .time_off = 100, .time_on = 300, .color = COLOR_DARKRED, .repeats = 1, }, \
|
|
|
|
{ .time_off = 100, .time_on = 300, .color = alarm_color, .repeats = 2, }, \
|
|
|
|
{ .time_off = 100, .time_on = 10, .color = COLOR_BLACK, .repeats = 1, }, \
|
|
|
|
}, }
|
|
|
|
|
|
|
|
#define STANDARD_WARN_SEQUENCE(alarm_color, alarm_repeats) \
|
|
|
|
{ .repeats = alarm_repeats, .steps = { \
|
|
|
|
{ .time_off = 200, .time_on = 10, .color = COLOR_BLACK, .repeats = 1, }, \
|
|
|
|
{ .time_off = 100, .time_on = 300, .color = COLOR_ORANGE, .repeats = 1, }, \
|
|
|
|
{ .time_off = 100, .time_on = 300, .color = alarm_color, .repeats = 1, }, \
|
|
|
|
{ .time_off = 200, .time_on = 10, .color = COLOR_BLACK, .repeats = 1, }, \
|
|
|
|
}, }
|
2014-08-13 15:18:17 +02:00
|
|
|
|
2014-08-18 16:35:02 +02:00
|
|
|
// This is the list of defined light sequences
|
|
|
|
/* how each sequence is defined
|
|
|
|
* [NOTIFY_SEQUENCE_DISARMED] = { // Sequence ID
|
|
|
|
.repeats = -1, // Number of repetitions or -1 for infinite
|
|
|
|
.steps = { // List of steps (until NOTIFY_SEQUENCE_MAX_STEPS steps, default to 5)
|
|
|
|
{
|
|
|
|
.time_off = 500, // Off time for the step
|
|
|
|
.time_on = 500, // On time for the step
|
|
|
|
.color = COLOR_TEAL, // color
|
|
|
|
.repeats = 1, // repetitions for this step
|
|
|
|
},
|
2014-08-13 15:18:17 +02:00
|
|
|
},
|
|
|
|
},
|
2014-08-18 16:35:02 +02:00
|
|
|
*
|
|
|
|
* There are two kind of sequences:
|
|
|
|
* - "Background" sequences, executed if no higher priority sequence is played;
|
|
|
|
* - "Alarm" sequences, that are "modal", they temporarily suspends background sequences and plays.
|
|
|
|
* Cannot have "-1" repetitions
|
|
|
|
* At the end background sequence are resumed;
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
const LedSequence_t notifications[] = {
|
|
|
|
[NOTIFY_SEQUENCE_DISARMED] = { .repeats = -1, .steps = {
|
2016-07-17 17:19:34 +02:00
|
|
|
{ .time_off = 200, .time_on = 10, .color = COLOR_BLACK, .repeats = 1, },
|
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_WHITE, .repeats = 1, },
|
|
|
|
{ .time_off = 200, .time_on = 10, .color = COLOR_BLACK, .repeats = 1, },
|
2014-08-18 16:35:02 +02:00
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_MANUAL] = { .repeats = -1, .steps = {
|
2016-07-17 17:19:34 +02:00
|
|
|
{ .time_off = 900, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, },
|
2014-08-18 16:35:02 +02:00
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED1] = { .repeats = -1, .steps = {
|
|
|
|
{ .time_off = 900, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, },
|
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED2] = { .repeats = -1, .steps = {
|
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, },
|
|
|
|
{ .time_off = 700, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, },
|
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED3] = { .repeats = -1, .steps = {
|
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_BLUE, .repeats = 2, },
|
|
|
|
{ .time_off = 500, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, },
|
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED4] = { .repeats = -1, .steps = {
|
|
|
|
{ .time_off = 900, .time_on = 100, .color = COLOR_PURPLE, .repeats = 1, },
|
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED5] = { .repeats = -1, .steps = {
|
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_PURPLE, .repeats = 1, },
|
|
|
|
{ .time_off = 700, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, },
|
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED6] = { .repeats = -1, .steps = {
|
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_PURPLE, .repeats = 1, },
|
2015-05-18 10:05:56 +02:00
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, },
|
2014-08-18 16:35:02 +02:00
|
|
|
{ .time_off = 500, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, },
|
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_GPS] = { .repeats = -1, .steps = {
|
|
|
|
{ .time_off = 800, .time_on = 200, .color = COLOR_GREEN, .repeats = 1, },
|
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_RTH] = { .repeats = -1, .steps = {
|
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_GREEN, .repeats = 1, },
|
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_YELLOW, .repeats = 1, },
|
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_LAND] = { .repeats = -1, .steps = {
|
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_GREEN, .repeats = 1, },
|
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ARMED_FM_AUTO] = { .repeats = -1, .steps = {
|
|
|
|
{ .time_off = 100, .time_on = 200, .color = COLOR_GREEN, .repeats = 2, },
|
|
|
|
{ .time_off = 500, .time_on = 200, .color = COLOR_GREEN, .repeats = 1, },
|
|
|
|
}, },
|
2016-07-17 17:19:34 +02:00
|
|
|
[NOTIFY_SEQUENCE_ALM_WARN_GPS] = STANDARD_WARN_SEQUENCE(COLOR_GREEN, 1),
|
|
|
|
[NOTIFY_SEQUENCE_ALM_ERROR_GPS] = STANDARD_ERROR_SEQUENCE(COLOR_GREEN, 1),
|
2014-08-18 16:35:02 +02:00
|
|
|
[NOTIFY_SEQUENCE_ALM_WARN_BATTERY] = { .repeats = 1, .steps = {
|
2016-07-17 17:19:34 +02:00
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_ORANGE, .repeats = 5, },
|
2014-08-18 16:35:02 +02:00
|
|
|
}, },
|
|
|
|
[NOTIFY_SEQUENCE_ALM_ERROR_BATTERY] = { .repeats = 1, .steps = {
|
2016-07-17 17:19:34 +02:00
|
|
|
{ .time_off = 100, .time_on = 100, .color = COLOR_RED, .repeats = 5, },
|
2014-08-18 16:35:02 +02:00
|
|
|
}, },
|
2016-07-17 17:19:34 +02:00
|
|
|
[NOTIFY_SEQUENCE_ALM_ERROR_MAG] = STANDARD_ERROR_SEQUENCE(COLOR_PURPLE, 1),
|
|
|
|
[NOTIFY_SEQUENCE_ALM_WARN_MAG] = STANDARD_WARN_SEQUENCE(COLOR_PURPLE, 1),
|
|
|
|
[NOTIFY_SEQUENCE_ALM_CONFIG] = STANDARD_ERROR_SEQUENCE(COLOR_RED, 2),
|
|
|
|
[NOTIFY_SEQUENCE_ALM_RECEIVER] = STANDARD_ERROR_SEQUENCE(COLOR_YELLOW, 1),
|
|
|
|
[NOTIFY_SEQUENCE_ALM_ATTITUDE] = { .repeats = 10, .steps = {
|
2015-05-03 23:13:53 +02:00
|
|
|
{ .time_off = 0, .time_on = 50, .color = COLOR_RED, .repeats = 1, },
|
|
|
|
{ .time_off = 0, .time_on = 50, .color = COLOR_BLUE, .repeats = 1, },
|
|
|
|
}, },
|
2014-08-13 15:18:17 +02:00
|
|
|
};
|
|
|
|
|
2014-08-18 16:35:02 +02:00
|
|
|
// List of background sequences attached to each flight mode
|
2014-08-13 15:18:17 +02:00
|
|
|
const LedSequence_t *flightModeMap[] = {
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_MANUAL] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_MANUAL],
|
2014-11-08 12:56:17 +01:00
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_STABILIZED1] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED1],
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_STABILIZED2] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED2],
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_STABILIZED3] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED3],
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_STABILIZED4] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED4],
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_STABILIZED5] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED5],
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_STABILIZED6] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED6],
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_PATHPLANNER] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_AUTO],
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_POSITIONHOLD] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_GPS],
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_COURSELOCK] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_GPS],
|
2015-05-22 09:34:43 +02:00
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_VELOCITYROAM] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_GPS],
|
2014-11-08 16:01:59 +01:00
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_HOMELEASH] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_GPS],
|
2014-11-08 12:56:17 +01:00
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_ABSOLUTEPOSITION] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_GPS],
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_RETURNTOBASE] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_RTH],
|
2014-08-13 15:18:17 +02:00
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_LAND] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_LAND],
|
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_POI] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_GPS],
|
2014-11-08 12:56:17 +01:00
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_AUTOCRUISE] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_GPS],
|
2015-05-22 09:34:43 +02:00
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_AUTOTAKEOFF] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_LAND],
|
2016-02-28 09:48:13 +01:00
|
|
|
#if !defined(PIOS_EXCLUDE_ADVANCED_FEATURES)
|
2016-03-14 21:58:06 +01:00
|
|
|
[FLIGHTSTATUS_FLIGHTMODE_AUTOTUNE] = ¬ifications[NOTIFY_SEQUENCE_ARMED_FM_MANUAL],
|
2016-02-28 09:48:13 +01:00
|
|
|
#endif /* !defined(PIOS_EXCLUDE_ADVANCED_FEATURES) */
|
2014-08-13 15:18:17 +02:00
|
|
|
};
|
|
|
|
|
2014-08-18 16:35:02 +02:00
|
|
|
// List of alarms to show with attached sequences for each status
|
2014-08-13 15:18:17 +02:00
|
|
|
const AlarmDefinition_t alarmsMap[] = {
|
|
|
|
{
|
2016-07-17 17:19:34 +02:00
|
|
|
.timeBetweenNotifications = 5000,
|
2014-08-13 15:18:17 +02:00
|
|
|
.alarmIndex = SYSTEMALARMS_ALARM_GPS,
|
|
|
|
.warnNotification = NOTIFY_SEQUENCE_ALM_WARN_GPS,
|
2015-05-03 23:13:53 +02:00
|
|
|
.criticalNotification = NOTIFY_SEQUENCE_ALM_ERROR_GPS,
|
2014-08-13 15:18:17 +02:00
|
|
|
.errorNotification = NOTIFY_SEQUENCE_ALM_ERROR_GPS,
|
|
|
|
},
|
|
|
|
{
|
2015-05-03 23:13:53 +02:00
|
|
|
.timeBetweenNotifications = 5000,
|
2014-08-13 15:18:17 +02:00
|
|
|
.alarmIndex = SYSTEMALARMS_ALARM_MAGNETOMETER,
|
2016-07-17 17:19:34 +02:00
|
|
|
.warnNotification = NOTIFY_SEQUENCE_ALM_WARN_MAG,
|
|
|
|
.criticalNotification = NOTIFY_SEQUENCE_ALM_ERROR_MAG,
|
|
|
|
.errorNotification = NOTIFY_SEQUENCE_ALM_ERROR_MAG,
|
2014-08-13 15:18:17 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.timeBetweenNotifications = 15000,
|
|
|
|
.alarmIndex = SYSTEMALARMS_ALARM_BATTERY,
|
|
|
|
.warnNotification = NOTIFY_SEQUENCE_ALM_WARN_BATTERY,
|
2015-05-03 23:13:53 +02:00
|
|
|
.criticalNotification = NOTIFY_SEQUENCE_ALM_ERROR_BATTERY,
|
2014-08-13 15:18:17 +02:00
|
|
|
.errorNotification = NOTIFY_SEQUENCE_ALM_ERROR_BATTERY,
|
|
|
|
},
|
2014-08-18 16:35:02 +02:00
|
|
|
{
|
|
|
|
.timeBetweenNotifications = 5000,
|
|
|
|
.alarmIndex = SYSTEMALARMS_ALARM_SYSTEMCONFIGURATION,
|
|
|
|
.warnNotification = NOTIFY_SEQUENCE_NULL,
|
2015-05-03 23:13:53 +02:00
|
|
|
.criticalNotification = NOTIFY_SEQUENCE_ALM_CONFIG,
|
2014-08-18 16:35:02 +02:00
|
|
|
.errorNotification = NOTIFY_SEQUENCE_ALM_CONFIG,
|
|
|
|
},
|
|
|
|
{
|
2016-07-17 17:19:34 +02:00
|
|
|
.timeBetweenNotifications = 5000,
|
2014-08-18 16:35:02 +02:00
|
|
|
.alarmIndex = SYSTEMALARMS_ALARM_RECEIVER,
|
|
|
|
.warnNotification = NOTIFY_SEQUENCE_ALM_RECEIVER,
|
2015-05-03 23:13:53 +02:00
|
|
|
.criticalNotification = NOTIFY_SEQUENCE_ALM_RECEIVER,
|
2014-08-18 16:35:02 +02:00
|
|
|
.errorNotification = NOTIFY_SEQUENCE_ALM_RECEIVER,
|
|
|
|
},
|
2015-05-03 23:13:53 +02:00
|
|
|
{
|
|
|
|
.timeBetweenNotifications = 1000,
|
|
|
|
.alarmIndex = SYSTEMALARMS_ALARM_ATTITUDE,
|
|
|
|
.warnNotification = NOTIFY_SEQUENCE_ALM_ATTITUDE,
|
|
|
|
.criticalNotification = NOTIFY_SEQUENCE_NULL,
|
|
|
|
.errorNotification = NOTIFY_SEQUENCE_ALM_ATTITUDE,
|
|
|
|
},
|
2014-08-13 15:18:17 +02:00
|
|
|
};
|
2014-08-18 16:35:02 +02:00
|
|
|
|
2014-08-13 15:18:17 +02:00
|
|
|
const uint8_t alarmsMapSize = NELEMENTS(alarmsMap);
|
|
|
|
|
|
|
|
#endif /* SEQUENCES_H_ */
|