2 ******************************************************************************
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
6 * @brief Handles user notifications.
8 * @see The GNU Public License (GPL) Version 3
10 *****************************************************************************/
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #ifndef PIOS_NOTIFY_H_
27 #define PIOS_NOTIFY_H_
35 } pios_notify_notification
;
38 NOTIFY_PRIORITY_CRITICAL
= 2,
39 NOTIFY_PRIORITY_REGULAR
= 1,
40 NOTIFY_PRIORITY_LOW
= 0,
41 NOTIFY_PRIORITY_BACKGROUND
= -1,
42 } pios_notify_priority
;
45 // A single led step, Color, time On/Off, repeat count
46 #define NOTIFY_SEQUENCE_MAX_STEPS 5
56 int8_t repeats
; // -1 for infinite repetitions
57 LedStep_t steps
[NOTIFY_SEQUENCE_MAX_STEPS
];
61 LedSequence_t sequence
;
62 pios_notify_priority priority
;
63 } ExtLedNotification_t
;
65 #define NOTIFY_IS_NULL_STEP(x) (!x || (!x->time_off && !x->time_on && !x->repeats))
68 * start a new notification. If a notification is active it will be overwritten if its priority is lower than the new one.
69 * The new will be discarded otherwise
70 * @param notification kind of notification
71 * @param priority priority of the new notification
73 void PIOS_NOTIFY_StartNotification(pios_notify_notification notification
, pios_notify_priority priority
);
76 * retrieve any active notification
80 pios_notify_notification
PIOS_NOTIFY_GetActiveNotification(bool clear
);
83 * Play a sequence on the default external led. Sequences with priority higher than NOTIFY_PRIORITY_LOW
84 * are repeated only once if repeat = -1
85 * @param sequence Sequence to be played
86 * @param priority Priority of the sequence being played
87 * @return true if sequence is enqueued, false otherwise
89 bool PIOS_NOTIFICATION_Default_Ext_Led_Play(const LedSequence_t
*sequence
, pios_notify_priority priority
);
92 * Play a sequence on an external rgb led. Sequences with priority higher than NOTIFY_PRIORITY_LOW
93 * are repeated only once if repeat = -1
94 * @param sequence Sequence to be played
95 * @param ledNumber Led number
96 * @param priority Priority of the sequence being played
99 // void PIOS_NOTIFICATION_Ext_Led_Play(const LedSequence_t sequence, uint8_t ledNumber, pios_notify_priority priority);
101 ExtLedNotification_t
*PIOS_NOTIFY_GetNewExtLedSequence(bool clear
);
103 #endif /* PIOS_NOTIFY_H_ */