29#include "generated/airframe.h"
32#ifdef BUZZER_TUNES_ALERT_HEADER
33#include BUZZER_TUNES_ALERT_HEADER
37#ifndef BUZZER_TUNES_EVENTS_ON
38#define BUZZER_TUNES_EVENTS_ON FALSE
42#ifdef BUZZER_TUNES_ARMED_TUNE
47#ifndef BUZZER_TUNES_ALERT_TUNE
48#define BUZZER_TUNES_ALERT_TUNE BUZZER_TUNES_NONE
52#ifndef BUZZER_TUNES_ALERT_END_TUNE
53#define BUZZER_TUNES_ALERT_END_TUNE BUZZER_TUNES_NONE
57#ifndef BUZZER_TUNES_STARTUP_TUNE
58#define BUZZER_TUNES_STARTUP_TUNE BUZZER_TUNES_STARTUP
62#define BUZZER_TUNES_GAP_MS 30
116#define BEATS(_b, _bpm) ((uint16_t)((_b) * 60000.0 / (_bpm)))
123#define TUNE_END {0, 0}
126#ifndef BUZZER_TUNES_RTTTL_1
127#define BUZZER_TUNES_RTTTL_1 ""
129#ifndef BUZZER_TUNES_RTTTL_2
130#define BUZZER_TUNES_RTTTL_2 ""
132#ifndef BUZZER_TUNES_RTTTL_3
133#define BUZZER_TUNES_RTTTL_3 ""
143 {
E6, 300}, {
E6, 300}, {
F6, 300}, {
G6, 300}, {
G6, 300}, {
F6, 300}, {
E6, 300}, {
D6, 300},
144 {
C6, 300}, {
C6, 300}, {
D6, 300}, {
E6, 300}, {
E6, 450}, {
D6, 150}, {
D6, 600},
145 {
E6, 300}, {
E6, 300}, {
F6, 300}, {
G6, 300}, {
G6, 300}, {
F6, 300}, {
E6, 300}, {
D6, 300},
146 {
C6, 300}, {
C6, 300}, {
D6, 300}, {
E6, 300}, {
D6, 450}, {
C6, 150}, {
C6, 600},
147 {
D6, 300}, {
D6, 300}, {
E6, 300}, {
C6, 300}, {
D6, 300}, {
E6, 150}, {
F6, 150}, {
E6, 300}, {
C6, 300},
148 {
D6, 300}, {
E6, 150}, {
F6, 150}, {
E6, 300}, {
D6, 300}, {
C6, 300}, {
D6, 300}, {
G5, 600},
149 {
E6, 300}, {
E6, 300}, {
F6, 300}, {
G6, 300}, {
G6, 300}, {
F6, 300}, {
E6, 300}, {
D6, 300},
150 {
C6, 300}, {
C6, 300}, {
D6, 300}, {
E6, 300}, {
D6, 450}, {
C6, 150}, {
C6, 600},
TUNE_END
155 {
C6, 300}, {
C6, 300}, {
G6, 300}, {
G6, 300}, {
A6, 300}, {
A6, 300}, {
G6, 600},
156 {
F6, 300}, {
F6, 300}, {
E6, 300}, {
E6, 300}, {
D6, 300}, {
D6, 300}, {
C6, 600},
157 {
G6, 300}, {
G6, 300}, {
F6, 300}, {
F6, 300}, {
E6, 300}, {
E6, 300}, {
D6, 600},
158 {
G6, 300}, {
G6, 300}, {
F6, 300}, {
F6, 300}, {
E6, 300}, {
E6, 300}, {
D6, 600},
159 {
C6, 300}, {
C6, 300}, {
G6, 300}, {
G6, 300}, {
A6, 300}, {
A6, 300}, {
G6, 600},
160 {
F6, 300}, {
F6, 300}, {
E6, 300}, {
E6, 300}, {
D6, 300}, {
D6, 300}, {
C6, 600},
TUNE_END
166 {
F5,
BEATS(1,
IT_BPM)}, {
F5,
BEATS(0.75,
IT_BPM)}, {
G5,
BEATS(0.25,
IT_BPM)}, {
F5,
BEATS(1,
IT_BPM)},
167 {
REST,
BEATS(1,
IT_BPM)}, {
D6,
BEATS(1,
IT_BPM)}, {
D6,
BEATS(0.75,
IT_BPM)}, {
Ds6,
BEATS(0.25,
IT_BPM)},
168 {
D6,
BEATS(1,
IT_BPM)}, {
REST,
BEATS(1,
IT_BPM)}, {
D6,
BEATS(1,
IT_BPM)}, {
F6,
BEATS(0.75,
IT_BPM)},
169 {
Ds6,
BEATS(0.25,
IT_BPM)}, {
D6,
BEATS(2,
IT_BPM)}, {
C6,
BEATS(1,
IT_BPM)}, {
D6,
BEATS(0.75,
IT_BPM)},
170 {
C6,
BEATS(0.25,
IT_BPM)}, {
As5,
BEATS(1,
IT_BPM)}, {
REST,
BEATS(1,
IT_BPM)}, {
D6,
BEATS(1,
IT_BPM)},
171 {
D6,
BEATS(1,
IT_BPM)}, {
A5,
BEATS(2,
IT_BPM)}, {
As5,
BEATS(0.75,
IT_BPM)}, {
C6,
BEATS(0.25,
IT_BPM)},
172 {
As5,
BEATS(0.75,
IT_BPM)}, {
A5,
BEATS(0.25,
IT_BPM)}, {
G5,
BEATS(1,
IT_BPM)}, {
REST,
BEATS(1,
IT_BPM)},
173 {
As5,
BEATS(1,
IT_BPM)}, {
A5,
BEATS(0.75,
IT_BPM)}, {
As5,
BEATS(0.25,
IT_BPM)}, {
C6,
BEATS(1,
IT_BPM)},
174 {
REST,
BEATS(1,
IT_BPM)}, {
D5,
BEATS(1,
IT_BPM)}, {
D6,
BEATS(2,
IT_BPM)}, {
Ds6,
BEATS(1,
IT_BPM)},
175 {
F5,
BEATS(1,
IT_BPM)}, {
F5,
BEATS(0.75,
IT_BPM)}, {
G5,
BEATS(0.25,
IT_BPM)}, {
F5,
BEATS(0.5,
IT_BPM)},
176 {
REST,
BEATS(1.5,
IT_BPM)}, {
D6,
BEATS(1,
IT_BPM)}, {
D6,
BEATS(0.75,
IT_BPM)}, {
Ds6,
BEATS(0.25,
IT_BPM)},
177 {
D6,
BEATS(2,
IT_BPM)}, {
D6,
BEATS(1,
IT_BPM)}, {
F6,
BEATS(0.75,
IT_BPM)}, {
Ds6,
BEATS(0.25,
IT_BPM)},
178 {
D6,
BEATS(1.5,
IT_BPM)}, {
F6,
BEATS(0.5,
IT_BPM)}, {
C6,
BEATS(0.5,
IT_BPM)}, {
F6,
BEATS(0.5,
IT_BPM)},
185 {
D5,
BEATS(1,
NL_BPM)}, {
G5,
BEATS(1,
NL_BPM)}, {
G5,
BEATS(1,
NL_BPM)}, {
A5,
BEATS(0.5,
NL_BPM)},
186 {
B5,
BEATS(0.5,
NL_BPM)}, {
C6,
BEATS(0.5,
NL_BPM)}, {
A5,
BEATS(0.5,
NL_BPM)}, {
B5,
BEATS(1,
NL_BPM)},
187 {
A5,
BEATS(0.5,
NL_BPM)}, {
B5,
BEATS(0.5,
NL_BPM)}, {
C6,
BEATS(1,
NL_BPM)}, {
B5,
BEATS(1,
NL_BPM)},
188 {
A5,
BEATS(0.5,
NL_BPM)}, {
G5,
BEATS(0.5,
NL_BPM)}, {
A5,
BEATS(1,
NL_BPM)}, {
G5,
BEATS(3,
NL_BPM)},
189 {
B5,
BEATS(0.5,
NL_BPM)}, {
C6,
BEATS(0.5,
NL_BPM)}, {
D6,
BEATS(2,
NL_BPM)}, {
E6,
BEATS(1,
NL_BPM)},
190 {
D6,
BEATS(2,
NL_BPM)}, {
C6,
BEATS(1,
NL_BPM)}, {
B5,
BEATS(1,
NL_BPM)}, {
A5,
BEATS(0.5,
NL_BPM)},
191 {
B5,
BEATS(0.5,
NL_BPM)}, {
C6,
BEATS(1,
NL_BPM)}, {
B5,
BEATS(1,
NL_BPM)}, {
A5,
BEATS(1,
NL_BPM)},
192 {
G5,
BEATS(1,
NL_BPM)}, {
A5,
BEATS(3,
NL_BPM)}, {
D5,
BEATS(1,
NL_BPM)}, {
G5,
BEATS(0.5,
NL_BPM)},
193 {
Fs5,
BEATS(0.5,
NL_BPM)}, {
G5,
BEATS(0.5,
NL_BPM)}, {
A5,
BEATS(0.5,
NL_BPM)}, {
B5,
BEATS(1,
NL_BPM)},
194 {
A5,
BEATS(2,
NL_BPM)}, {
G5,
BEATS(1,
NL_BPM)}, {
Fs5,
BEATS(1,
NL_BPM)}, {
D5,
BEATS(1,
NL_BPM)},
195 {
E5,
BEATS(0.5,
NL_BPM)}, {
Fs5,
BEATS(0.5,
NL_BPM)}, {
G5,
BEATS(1,
NL_BPM)}, {
G5,
BEATS(1,
NL_BPM)},
202 {
D5,
BEATS(0.25,
FR_BPM)}, {
D5,
BEATS(0.75,
FR_BPM)}, {
D5,
BEATS(0.25,
FR_BPM)}, {
G5,
BEATS(1,
FR_BPM)},
203 {
G5,
BEATS(1,
FR_BPM)}, {
A5,
BEATS(1,
FR_BPM)}, {
A5,
BEATS(1,
FR_BPM)}, {
D6,
BEATS(1.5,
FR_BPM)},
204 {
B5,
BEATS(0.5,
FR_BPM)}, {
G5,
BEATS(0.75,
FR_BPM)}, {
G5,
BEATS(0.25,
FR_BPM)}, {
B5,
BEATS(0.75,
FR_BPM)},
205 {
G5,
BEATS(0.25,
FR_BPM)}, {
E5,
BEATS(1,
FR_BPM)}, {
C6,
BEATS(1,
FR_BPM)}, {
REST,
BEATS(1,
FR_BPM)},
206 {
A5,
BEATS(0.75,
FR_BPM)}, {
Fs5,
BEATS(0.25,
FR_BPM)}, {
G5,
BEATS(1,
FR_BPM)}, {
REST,
BEATS(2,
FR_BPM)},
207 {
G5,
BEATS(0.75,
FR_BPM)}, {
A5,
BEATS(0.25,
FR_BPM)}, {
B5,
BEATS(1,
FR_BPM)}, {
B5,
BEATS(1,
FR_BPM)},
208 {
B5,
BEATS(1,
FR_BPM)}, {
C6,
BEATS(0.75,
FR_BPM)}, {
B5,
BEATS(0.25,
FR_BPM)}, {
B5,
BEATS(1,
FR_BPM)},
209 {
A5,
BEATS(1,
FR_BPM)}, {
REST,
BEATS(1,
FR_BPM)}, {
A5,
BEATS(0.75,
FR_BPM)}, {
B5,
BEATS(0.25,
FR_BPM)},
210 {
C6,
BEATS(1,
FR_BPM)}, {
C6,
BEATS(1,
FR_BPM)}, {
C6,
BEATS(1,
FR_BPM)}, {
D6,
BEATS(0.75,
FR_BPM)},
211 {
C6,
BEATS(0.25,
FR_BPM)}, {
B5,
BEATS(1,
FR_BPM)}, {
REST,
BEATS(2,
FR_BPM)}, {
D6,
BEATS(0.75,
FR_BPM)},
212 {
D6,
BEATS(0.25,
FR_BPM)}, {
D6,
BEATS(1,
FR_BPM)}, {
B5,
BEATS(0.75,
FR_BPM)}, {
G5,
BEATS(0.25,
FR_BPM)},
213 {
D6,
BEATS(1,
FR_BPM)}, {
B5,
BEATS(0.75,
FR_BPM)}, {
G5,
BEATS(0.25,
FR_BPM)}, {
D5,
BEATS(3,
FR_BPM)},
TUNE_END
218 {
G5, 300}, {
G5, 100}, {
A5, 400}, {
G5, 400}, {
C6, 400}, {
B5, 800},
219 {
G5, 300}, {
G5, 100}, {
A5, 400}, {
G5, 400}, {
D6, 400}, {
C6, 800},
220 {
G5, 300}, {
G5, 100}, {
G6, 400}, {
E6, 400}, {
C6, 400}, {
B5, 400}, {
A5, 800},
221 {
F6, 300}, {
F6, 100}, {
E6, 400}, {
C6, 400}, {
D6, 400}, {
C6, 800},
TUNE_END
227 {
E7, 150}, {
E7, 150}, {
REST, 150}, {
E7, 150}, {
REST, 150}, {
C7, 150}, {
E7, 150}, {
REST, 150},
228 {
G7, 300}, {
REST, 300}, {
G6, 300}, {
REST, 300}, {
C7, 450}, {
G6, 150}, {
REST, 300}, {
E6, 450},
229 {
A6, 300}, {
B6, 300}, {
As6, 150}, {
A6, 300}, {
G6, 200}, {
E7, 200}, {
G7, 200}, {
A7, 300},
230 {
F7, 150}, {
G7, 150}, {
REST, 150}, {
E7, 300}, {
C7, 150}, {
D7, 150}, {
B6, 450}, {
C7, 450},
231 {
G6, 150}, {
REST, 300}, {
E6, 450}, {
A6, 300}, {
B6, 300}, {
As6, 150}, {
A6, 300}, {
G6, 200},
232 {
E7, 200}, {
G7, 200}, {
A7, 300}, {
F7, 150}, {
G7, 150}, {
REST, 150}, {
E7, 300}, {
C7, 150},
233 {
D7, 150}, {
B6, 450}, {
REST, 300}, {
G7, 150}, {
Fs7, 150}, {
F7, 150}, {
D7, 300}, {
E7, 150},
234 {
REST, 150}, {
G6, 150}, {
A6, 150}, {
C7, 150}, {
REST, 150}, {
A6, 150}, {
C7, 150}, {
D7, 150},
235 {
REST, 300}, {
G7, 150}, {
Fs7, 150}, {
F7, 150}, {
D7, 300}, {
E7, 150}, {
REST, 150}, {
C5, 300},
236 {
C5, 150}, {
C5, 300}, {
REST, 300}, {
REST, 300}, {
G7, 150}, {
Fs7, 150}, {
F7, 150}, {
D7, 300},
237 {
E7, 150}, {
REST, 150}, {
G6, 150}, {
A6, 150}, {
C7, 150}, {
REST, 150}, {
A6, 150}, {
C7, 150},
238 {
D7, 150}, {
REST, 300}, {
Ds7, 300}, {
REST, 150}, {
D7, 450}, {
C7, 600}, {
REST, 600}, {
C7, 150},
239 {
C7, 300}, {
C7, 150}, {
REST, 150}, {
C7, 150}, {
D7, 300}, {
E7, 150}, {
C7, 300}, {
A6, 150},
240 {
G6, 600}, {
C7, 150}, {
C7, 300}, {
C7, 150}, {
REST, 150}, {
C7, 150}, {
D7, 150}, {
E7, 150},
241 {
REST, 1200}, {
C7, 150}, {
C7, 300}, {
C7, 150}, {
REST, 150}, {
C7, 150}, {
D7, 300}, {
E7, 150},
242 {
C7, 300}, {
A6, 150}, {
G6, 600}, {
E7, 150}, {
E7, 150}, {
REST, 150}, {
E7, 150}, {
REST, 150},
243 {
C7, 150}, {
E7, 300}, {
G7, 300}, {
REST, 300}, {
G6, 300}, {
REST, 300}, {
C7, 450}, {
G6, 150},
244 {
REST, 300}, {
E6, 450}, {
A6, 300}, {
B6, 300}, {
As6, 150}, {
A6, 300}, {
G6, 200}, {
E7, 200},
245 {
G7, 200}, {
A7, 300}, {
F7, 150}, {
G7, 150}, {
REST, 150}, {
E7, 300}, {
C7, 150}, {
D7, 150},
246 {
B6, 450}, {
C7, 450}, {
G6, 150}, {
REST, 300}, {
E6, 450}, {
A6, 300}, {
B6, 300}, {
As6, 150},
247 {
A6, 300}, {
G6, 200}, {
E7, 200}, {
G7, 200}, {
A7, 300}, {
F7, 150}, {
G7, 150}, {
REST, 150},
248 {
E7, 300}, {
C7, 150}, {
D7, 150}, {
B6, 450}, {
E7, 150}, {
C7, 300}, {
G6, 150}, {
REST, 300},
249 {
G6, 300}, {
A6, 150}, {
F7, 300}, {
F7, 150}, {
A6, 600}, {
B6, 200}, {
A7, 200}, {
A7, 200},
250 {
A7, 200}, {
G7, 200}, {
F7, 200}, {
E7, 150}, {
C7, 300}, {
A6, 150}, {
G6, 600}, {
E7, 150},
251 {
C7, 300}, {
G6, 150}, {
REST, 300}, {
G6, 300}, {
A6, 150}, {
F7, 300}, {
F7, 150}, {
A6, 600},
252 {
B6, 150}, {
F7, 300}, {
F7, 150}, {
F7, 200}, {
E7, 200}, {
D7, 200}, {
C7, 150}, {
G6, 300},
253 {
E6, 150}, {
C6, 600}, {
C7, 450}, {
G6, 450}, {
E6, 300}, {
A6, 200}, {
B6, 200}, {
A6, 200},
254 {
Gs6, 200}, {
As6, 200}, {
Gs6, 200}, {
G6, 150}, {
Fs6, 150}, {
G6, 900},
261 {
E6, 160}, {
D6, 160}, {
Fs5, 320}, {
Gs5, 320}, {
Cs6, 160}, {
B5, 160}, {
D5, 320}, {
E5, 320},
262 {
B5, 160}, {
A5, 160}, {
Cs5, 320}, {
E5, 320}, {
A5, 960},
TUNE_END
267 {
E6, 150}, {
Ds6, 150}, {
E6, 150}, {
Ds6, 150}, {
E6, 150}, {
B5, 150}, {
D6, 150}, {
C6, 150},
268 {
A5, 300}, {
REST, 150}, {
C5, 150}, {
E5, 150}, {
A5, 150}, {
B5, 300}, {
REST, 150},
269 {
E5, 150}, {
Gs5, 150}, {
B5, 150}, {
C6, 300}, {
REST, 150}, {
E5, 150}, {
E6, 150}, {
Ds6, 150},
270 {
E6, 150}, {
Ds6, 150}, {
E6, 150}, {
B5, 150}, {
D6, 150}, {
C6, 150},
271 {
A5, 300}, {
REST, 150}, {
C5, 150}, {
E5, 150}, {
A5, 150}, {
B5, 300}, {
REST, 150},
277 {
C6, 150}, {
C6, 150}, {
C6, 150}, {
F6, 450}, {
A6, 300},
278 {
C6, 150}, {
C6, 150}, {
C6, 150}, {
F6, 450}, {
A6, 600},
279 {
F6, 300}, {
F6, 150}, {
E6, 150}, {
E6, 150}, {
D6, 150}, {
D6, 150}, {
C6, 600},
280 {
C6, 150}, {
C6, 150}, {
C6, 150}, {
E6, 450}, {
G6, 300},
281 {
C6, 150}, {
C6, 150}, {
C6, 150}, {
E6, 450}, {
G6, 600},
282 {
C7, 300}, {
D7, 150}, {
C7, 150}, {
As6, 150}, {
A6, 150}, {
G6, 150}, {
F6, 600},
TUNE_END
287 {
G6, 100}, {
G6, 100}, {
G6, 200}, {
G6, 100}, {
G6, 100}, {
G6, 200},
288 {
G6, 100}, {
G6, 100}, {
C7, 200}, {
D7, 200}, {
E7, 400}, {
REST, 200},
289 {
G6, 100}, {
G6, 100}, {
G6, 200}, {
G6, 100}, {
G6, 100}, {
G6, 200},
290 {
G6, 100}, {
G6, 100}, {
C7, 200}, {
D7, 200}, {
E7, 400}, {
C7, 600},
TUNE_END
295 {
C7, 150}, {
REST, 50}, {
C7, 150}, {
REST, 50}, {
C7, 150}, {
REST, 150}, {
C7, 150}, {
REST, 50},
296 {
C7, 150}, {
REST, 150}, {
C7, 80}, {
REST, 20}, {
C7, 80}, {
REST, 20}, {
C7, 150}, {
REST, 50},
297 {
B6, 150}, {
REST, 50}, {
B6, 150}, {
REST, 50}, {
B6, 150}, {
REST, 150}, {
B6, 150}, {
REST, 50},
298 {
B6, 150}, {
REST, 150}, {
B6, 150}, {
REST, 50}, {
B6, 150}, {
REST, 50}, {
C7, 150}, {
REST, 50},
299 {
C7, 150}, {
REST, 50}, {
C7, 150}, {
REST, 150}, {
C7, 150}, {
REST, 50}, {
C7, 150}, {
REST, 150},
300 {
C7, 150}, {
REST, 50}, {
C7, 150}, {
REST, 50}, {
B6, 150}, {
REST, 50}, {
B6, 150}, {
REST, 50},
301 {
B6, 150}, {
REST, 150}, {
B6, 150}, {
REST, 50}, {
B6, 150}, {
REST, 150}, {
B6, 150}, {
REST, 50},
302 {
B6, 150}, {
REST, 50}, {
C7, 150}, {
REST, 50}, {
C7, 150}, {
REST, 50}, {
C7, 150}, {
REST, 150},
303 {
C7, 150}, {
REST, 50}, {
C7, 150}, {
REST, 150}, {
C7, 150}, {
REST, 50}, {
C7, 150}, {
REST, 50},
304 {
B6, 150}, {
REST, 50}, {
B6, 150}, {
REST, 50}, {
B6, 150}, {
REST, 150}, {
B6, 150}, {
REST, 50},
305 {
B6, 150}, {
REST, 150}, {
B6, 150}, {
REST, 50}, {
B6, 150},
344#ifdef BUZZER_TUNES_ALERT
345static bool alert_active =
false;
346static bool alert_muted =
false;
348#ifdef BUZZER_TUNES_ARMED_TUNE
349static bool motors_were_on =
false;
350static bool armed_muted =
false;
358 while (**
p >=
'0' && **
p <=
'9') {
359 n = n * 10 + (*(*p)++ -
'0');
368 while (*
p && *
p !=
':') {
p++; }
369 if (*
p !=
':') {
return false; }
372 while (*
p && *
p !=
':') {
374 if (key ==
'd' || key ==
'o' || key ==
'b') {
377 if (key ==
'd' && v > 0) {
rtttl_d = v; }
378 if (key ==
'o' && v > 0) {
rtttl_o = v; }
379 if (key ==
'b' && v > 0) {
rtttl_bpm = v; }
384 if (*
p !=
':') {
return false; }
393 static const uint16_t octave4[12] = {262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494};
394 static const int8_t semitone[
'h' -
'a' + 1] = {9, 11, 0, 2, 4, 5, 7, 11};
396 while (*
p ==
' ' || *
p ==
',') {
p++; }
397 if (*
p ==
'\0') {
return false; }
401 if (c !=
'p' && (c <
'a' || c >
'h')) {
return false; }
403 int8_t semi = (c ==
'p') ? -1 : semitone[c -
'a'];
404 if (*
p ==
'#') { semi++;
p++; }
406 if (*
p ==
'.') { dotted =
true;
p++; }
408 if (*
p >=
'0' && *
p <=
'9') { o = *
p++ -
'0'; }
409 if (*
p ==
'.') { dotted =
true;
p++; }
410 while (*
p && *
p !=
',') {
p++; }
414 if (dotted) {
ms =
ms * 3 / 2; }
421 n->
freq = (oct >= 4) ? (
f << (oct - 4)) : (
f >> (4 - oct));
455#ifdef BUZZER_TUNES_ALERT
456 alert_muted = alert_active;
458#ifdef BUZZER_TUNES_ARMED_TUNE
459 armed_muted = motors_were_on;
479#ifdef BUZZER_TUNES_ALERT
480 alert_active =
false;
483#ifdef BUZZER_TUNES_ARMED_TUNE
484 motors_were_on =
false;
526 bool in_alert =
false;
527#ifdef BUZZER_TUNES_ALERT
528 bool alert = BUZZER_TUNES_ALERT;
529 if (alert && !alert_active) {
533 }
else if (!alert && alert_active) {
534 alert_active =
false;
536 }
else if (alert && !
playing && !alert_muted) {
539 in_alert = alert_active;
541#ifdef BUZZER_TUNES_ARMED_TUNE
543 if (motors_on && !motors_were_on) {
548 }
else if (!motors_on && motors_were_on &&
event_tune && !in_alert) {
550 }
else if (motors_on && !in_alert && !
playing && !armed_muted) {
553 motors_were_on = motors_on;
569 if (elapsed >=
note.ms) {
bool autopilot_get_motors_on(void)
get motors status
Core autopilot interface common to all firmwares.
void buzzer_arch_init(void)
void buzzer_arch_tone(uint16_t freq)
Play a square wave at freq Hz, 0 for silence.
Piezo buzzer tone output with a ChibiOS PWM driver.
#define BUZZER_TUNES_RTTTL_1
Custom tunes (Custom 1..3) in RTTTL format ("name:d=4,o=6,b=120:c,e,g"), set in the airframe,...
static const struct buzzer_note tune_startup[]
Short rising arpeggio.
static struct buzzer_note note
note being played
static const struct buzzer_note tune_star[]
Star Song.
#define BUZZER_TUNES_GAP_MS
Silence at the end of each note, so repeated notes are heard separately [ms].
static const struct buzzer_note tune_twinkle[]
Twinkle Twinkle Little Star, full song (public domain).
static const struct buzzer_note tune_william_tell[]
Rossini, William Tell Overture, galop opening, played twice (public domain).
#define BUZZER_TUNES_ALERT_END_TUNE
Tune played once when BUZZER_TUNES_ALERT becomes false (stopped if the motors are disarmed).
void buzzer_tunes_init(void)
static const struct buzzer_note tune_anthem_netherlands[]
void buzzer_tunes_set_events(uint8_t on)
Settings handler: enable or disable the armed and alert tunes.
static bool note_gap
in the silent gap at the end of the note
#define BUZZER_TUNES_EVENTS_ON
Optional header needed by the alert condition.
#define FR_BPM
France, La Marseillaise, opening to "l'étendard sanglant est levé" (Rouget de Lisle 1792,...
#define BUZZER_TUNES_RTTTL_3
static const struct buzzer_note tune_la_cucaracha[]
La Cucaracha, chorus (traditional, public domain).
static const char * rtttl
next note of a RTTTL tune
#define NL_BPM
Netherlands, Wilhelmus, first verse (16th century, public domain).
static const char *const buzzer_tunes_custom[]
Custom tunes, RTTTL strings.
void buzzer_tunes_periodic(void)
static void event_update(void)
Event tunes: alert tune in a loop while the alert condition is true, armed tune in a loop while the m...
static void event_start(uint8_t tune)
Start a tune from an event.
static const struct buzzer_note tune_ode_to_joy[]
Beethoven, Ode to Joy, full theme (public domain).
static uint8_t rtttl_o
RTTTL default duration and octave.
static uint32_t note_start_ms
start time of the note
static const struct buzzer_note tune_gran_vals[]
Tarrega, Gran Vals, the phrase known as the Nokia ringtone (public domain).
static bool next_note(struct buzzer_note *n)
Get the next note of the tune, false at the end.
uint8_t buzzer_tunes_tune
tune being played, BUZZER_TUNES_NONE when silent
#define BUZZER_TUNES_STARTUP_TUNE
Tune played at startup, BUZZER_TUNES_NONE for silence.
#define BUZZER_TUNES_RTTTL_2
#define BUZZER_TUNES_ALERT_TUNE
Tune played in a loop while the motors are armed (optional), stopped when disarmed.
static void tune_start(uint8_t tune)
static bool rtttl_next(struct buzzer_note *n)
Parse the next RTTTL note "[duration]note[#][.][octave][.]", false at the end.
static bool event_tune
current tune was started by an event
#define IT_BPM
Italy, Il Canto degli Italiani, first verse (Novaro 1847, public domain).
static const struct buzzer_note tune_mushroom[]
Mushroom Song.
static const struct buzzer_note *const buzzer_tunes_list[BUZZER_TUNES_CUSTOM_1]
static bool rtttl_start(const char *str)
Parse the RTTTL header "name:d=4,o=6,b=120:", false if invalid.
#define BEATS(_b, _bpm)
Duration of a number of beats at a tempo [ms].
void buzzer_tunes_play(uint8_t tune)
Start a tune (BUZZER_TUNES_NONE stops), also the settings handler.
static uint16_t rtttl_bpm
RTTTL tempo.
static const struct buzzer_note tune_anthem_france[]
static uint16_t rtttl_number(const char **p)
static const struct buzzer_note tune_fur_elise[]
Beethoven, Fur Elise, first section (public domain).
static const struct buzzer_note tune_anthem_italy[]
static void start_next_note(void)
uint8_t buzzer_tunes_events_on
armed and alert tunes enabled
static const struct buzzer_note * tune_notes
next note of a built-in tune
static const struct buzzer_note tune_happy_birthday[]
Happy Birthday (public domain).
uint16_t freq
[Hz], REST for silence
#define REST
Note frequencies [Hz], s for sharp, octaves 5 to 7 sound loudest on a piezo (octave 4 is quieter).
Play tunes on a passive piezo buzzer (e.g.
@ BUZZER_TUNES_CUSTOM_1
custom RTTTL tunes, see BUZZER_TUNES_RTTTL_x
@ BUZZER_TUNES_ODE_TO_JOY
@ BUZZER_TUNES_WILLIAM_TELL
@ BUZZER_TUNES_ANTHEM_NETHERLANDS
@ BUZZER_TUNES_HAPPY_BIRTHDAY
@ BUZZER_TUNES_ANTHEM_ITALY
@ BUZZER_TUNES_ANTHEM_FRANCE
@ BUZZER_TUNES_LA_CUCARACHA
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
Architecture independent timing functions.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup).