|
Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Play tunes on a passive piezo buzzer (e.g. More...
#include "modules/sound/buzzer_tunes.h"#include "modules/sound/buzzer_arch.h"#include "mcu_periph/sys_time.h"#include "generated/airframe.h"Go to the source code of this file.
Data Structures | |
| struct | buzzer_note |
Macros | |
| #define | BUZZER_TUNES_EVENTS_ON FALSE |
| Optional header needed by the alert condition. | |
| #define | BUZZER_TUNES_ALERT_TUNE BUZZER_TUNES_NONE |
| Tune played in a loop while the motors are armed (optional), stopped when disarmed. | |
| #define | BUZZER_TUNES_ALERT_END_TUNE BUZZER_TUNES_NONE |
| Tune played once when BUZZER_TUNES_ALERT becomes false (stopped if the motors are disarmed). | |
| #define | BUZZER_TUNES_STARTUP_TUNE BUZZER_TUNES_STARTUP |
| Tune played at startup, BUZZER_TUNES_NONE for silence. | |
| #define | BUZZER_TUNES_GAP_MS 30 |
| Silence at the end of each note, so repeated notes are heard separately [ms]. | |
| #define | REST 0 |
| Note frequencies [Hz], s for sharp, octaves 5 to 7 sound loudest on a piezo (octave 4 is quieter). | |
| #define | C4 262 |
| #define | Cs4 277 |
| #define | D4 294 |
| #define | Ds4 311 |
| #define | E4 330 |
| #define | F4 349 |
| #define | Fs4 370 |
| #define | G4 392 |
| #define | Gs4 415 |
| #define | A4 440 |
| #define | As4 466 |
| #define | B4 494 |
| #define | C5 523 |
| #define | Cs5 554 |
| #define | D5 587 |
| #define | Ds5 622 |
| #define | E5 659 |
| #define | F5 698 |
| #define | Fs5 740 |
| #define | G5 784 |
| #define | Gs5 831 |
| #define | A5 880 |
| #define | As5 932 |
| #define | B5 988 |
| #define | C6 1047 |
| #define | Cs6 1109 |
| #define | D6 1175 |
| #define | Ds6 1245 |
| #define | E6 1319 |
| #define | F6 1397 |
| #define | Fs6 1480 |
| #define | G6 1568 |
| #define | Gs6 1661 |
| #define | A6 1760 |
| #define | As6 1865 |
| #define | B6 1976 |
| #define | C7 2093 |
| #define | Cs7 2217 |
| #define | D7 2349 |
| #define | Ds7 2489 |
| #define | E7 2637 |
| #define | F7 2794 |
| #define | Fs7 2960 |
| #define | G7 3136 |
| #define | Gs7 3322 |
| #define | A7 3520 |
| #define | As7 3729 |
| #define | B7 3951 |
| #define | BEATS(_b, _bpm) |
| Duration of a number of beats at a tempo [ms]. | |
| #define | TUNE_END {0, 0} |
| #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, empty for none. | |
| #define | BUZZER_TUNES_RTTTL_2 "" |
| #define | BUZZER_TUNES_RTTTL_3 "" |
| #define | IT_BPM 112 |
| Italy, Il Canto degli Italiani, first verse (Novaro 1847, public domain). | |
| #define | NL_BPM 90 |
| Netherlands, Wilhelmus, first verse (16th century, public domain). | |
| #define | FR_BPM 105 |
| France, La Marseillaise, opening to "l'étendard sanglant est levé" (Rouget de Lisle 1792, public domain). | |
Functions | |
| static void | tune_start (uint8_t tune) |
| static uint16_t | rtttl_number (const char **p) |
| static bool | rtttl_start (const char *str) |
| Parse the RTTTL header "name:d=4,o=6,b=120:", false if invalid. | |
| static bool | rtttl_next (struct buzzer_note *n) |
| Parse the next RTTTL note "[duration]note[#][.][octave][.]", false at the end. | |
| static bool | next_note (struct buzzer_note *n) |
| Get the next note of the tune, false at the end. | |
| static void | start_next_note (void) |
| void | buzzer_tunes_play (uint8_t tune) |
| Start a tune (BUZZER_TUNES_NONE stops), also the settings handler. | |
| static void | event_start (uint8_t tune) |
| Start a tune from an event. | |
| void | buzzer_tunes_set_events (uint8_t on) |
| Settings handler: enable or disable the armed and alert tunes. | |
| void | buzzer_tunes_init (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 motors are armed. | |
| void | buzzer_tunes_periodic (void) |
Variables | |
| static const struct buzzer_note | tune_startup [] |
| Short rising arpeggio. | |
| static const struct buzzer_note | tune_ode_to_joy [] |
| Beethoven, Ode to Joy, full theme (public domain). | |
| static const struct buzzer_note | tune_twinkle [] |
| Twinkle Twinkle Little Star, full song (public domain). | |
| static const struct buzzer_note | tune_anthem_italy [] |
| static const struct buzzer_note | tune_anthem_netherlands [] |
| static const struct buzzer_note | tune_anthem_france [] |
| static const struct buzzer_note | tune_happy_birthday [] |
| Happy Birthday (public domain). | |
| static const struct buzzer_note | tune_mushroom [] |
| Mushroom Song. | |
| static const struct buzzer_note | tune_gran_vals [] |
| Tarrega, Gran Vals, the phrase known as the Nokia ringtone (public domain). | |
| static const struct buzzer_note | tune_fur_elise [] |
| Beethoven, Fur Elise, first section (public domain). | |
| static const struct buzzer_note | tune_la_cucaracha [] |
| La Cucaracha, chorus (traditional, public domain). | |
| static const struct buzzer_note | tune_william_tell [] |
| Rossini, William Tell Overture, galop opening, played twice (public domain). | |
| static const struct buzzer_note | tune_star [] |
| Star Song. | |
| static const struct buzzer_note *const | buzzer_tunes_list [BUZZER_TUNES_CUSTOM_1] |
| static const char *const | buzzer_tunes_custom [] |
| Custom tunes, RTTTL strings. | |
| uint8_t | buzzer_tunes_tune = BUZZER_TUNES_NONE |
| tune being played, BUZZER_TUNES_NONE when silent | |
| static const struct buzzer_note * | tune_notes = NULL |
| next note of a built-in tune | |
| static const char * | rtttl = NULL |
| next note of a RTTTL tune | |
| static uint8_t | rtttl_d = 4 |
| static uint8_t | rtttl_o = 6 |
| RTTTL default duration and octave. | |
| static uint16_t | rtttl_bpm = 63 |
| RTTTL tempo. | |
| static struct buzzer_note | note |
| note being played | |
| static bool | playing = false |
| static uint32_t | note_start_ms = 0 |
| start time of the note | |
| static bool | note_gap = false |
| in the silent gap at the end of the note | |
| uint8_t | buzzer_tunes_events_on = BUZZER_TUNES_EVENTS_ON |
| armed and alert tunes enabled | |
| static bool | event_tune = false |
| current tune was started by an event | |
| struct buzzer_note |
Definition at line 118 of file buzzer_tunes.c.
| Data Fields | ||
|---|---|---|
| uint16_t | freq | [Hz], REST for silence |
| uint16_t | ms | duration [ms] |
| #define A4 440 |
Definition at line 75 of file buzzer_tunes.c.
| #define A5 880 |
Definition at line 87 of file buzzer_tunes.c.
| #define A6 1760 |
Definition at line 99 of file buzzer_tunes.c.
| #define A7 3520 |
Definition at line 111 of file buzzer_tunes.c.
| #define As4 466 |
Definition at line 76 of file buzzer_tunes.c.
| #define As5 932 |
Definition at line 88 of file buzzer_tunes.c.
| #define As6 1865 |
Definition at line 100 of file buzzer_tunes.c.
| #define As7 3729 |
Definition at line 112 of file buzzer_tunes.c.
| #define B4 494 |
Definition at line 77 of file buzzer_tunes.c.
| #define B5 988 |
Definition at line 89 of file buzzer_tunes.c.
| #define B6 1976 |
Definition at line 101 of file buzzer_tunes.c.
| #define B7 3951 |
Definition at line 113 of file buzzer_tunes.c.
| #define BEATS | ( | _b, | |
| _bpm ) |
Duration of a number of beats at a tempo [ms].
Definition at line 116 of file buzzer_tunes.c.
| #define BUZZER_TUNES_ALERT_END_TUNE BUZZER_TUNES_NONE |
Tune played once when BUZZER_TUNES_ALERT becomes false (stopped if the motors are disarmed).
Definition at line 53 of file buzzer_tunes.c.
Referenced by event_update().
| #define BUZZER_TUNES_ALERT_TUNE BUZZER_TUNES_NONE |
Tune played in a loop while the motors are armed (optional), stopped when disarmed.
Tune played in a loop while BUZZER_TUNES_ALERT is true (optional condition)
Definition at line 48 of file buzzer_tunes.c.
Referenced by event_update().
| #define BUZZER_TUNES_EVENTS_ON FALSE |
Optional header needed by the alert condition.
Event tunes (armed and alert tunes) enabled at startup, off by default
Definition at line 38 of file buzzer_tunes.c.
| #define BUZZER_TUNES_GAP_MS 30 |
Silence at the end of each note, so repeated notes are heard separately [ms].
Definition at line 62 of file buzzer_tunes.c.
Referenced by buzzer_tunes_periodic().
| #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, empty for none.
Definition at line 127 of file buzzer_tunes.c.
| #define BUZZER_TUNES_RTTTL_2 "" |
Definition at line 130 of file buzzer_tunes.c.
| #define BUZZER_TUNES_RTTTL_3 "" |
Definition at line 133 of file buzzer_tunes.c.
| #define BUZZER_TUNES_STARTUP_TUNE BUZZER_TUNES_STARTUP |
Tune played at startup, BUZZER_TUNES_NONE for silence.
Definition at line 58 of file buzzer_tunes.c.
Referenced by buzzer_tunes_init().
| #define C4 262 |
Definition at line 66 of file buzzer_tunes.c.
| #define C5 523 |
Definition at line 78 of file buzzer_tunes.c.
| #define C6 1047 |
Definition at line 90 of file buzzer_tunes.c.
| #define C7 2093 |
Definition at line 102 of file buzzer_tunes.c.
| #define Cs4 277 |
Definition at line 67 of file buzzer_tunes.c.
| #define Cs5 554 |
Definition at line 79 of file buzzer_tunes.c.
| #define Cs6 1109 |
Definition at line 91 of file buzzer_tunes.c.
| #define Cs7 2217 |
Definition at line 103 of file buzzer_tunes.c.
| #define D4 294 |
Definition at line 68 of file buzzer_tunes.c.
| #define D5 587 |
Definition at line 80 of file buzzer_tunes.c.
| #define D6 1175 |
Definition at line 92 of file buzzer_tunes.c.
| #define D7 2349 |
Definition at line 104 of file buzzer_tunes.c.
| #define Ds4 311 |
Definition at line 69 of file buzzer_tunes.c.
| #define Ds5 622 |
Definition at line 81 of file buzzer_tunes.c.
| #define Ds6 1245 |
Definition at line 93 of file buzzer_tunes.c.
| #define Ds7 2489 |
Definition at line 105 of file buzzer_tunes.c.
| #define E4 330 |
Definition at line 70 of file buzzer_tunes.c.
| #define E5 659 |
Definition at line 82 of file buzzer_tunes.c.
| #define E6 1319 |
Definition at line 94 of file buzzer_tunes.c.
Referenced by nps_flight_gear_loop(), nps_main_loop(), and nps_sensors_loop().
| #define E7 2637 |
Definition at line 106 of file buzzer_tunes.c.
| #define F4 349 |
Definition at line 71 of file buzzer_tunes.c.
| #define F5 698 |
Definition at line 83 of file buzzer_tunes.c.
| #define F6 1397 |
Definition at line 95 of file buzzer_tunes.c.
| #define F7 2794 |
Definition at line 107 of file buzzer_tunes.c.
| #define FR_BPM 105 |
France, La Marseillaise, opening to "l'étendard sanglant est levé" (Rouget de Lisle 1792, public domain).
Definition at line 200 of file buzzer_tunes.c.
| #define Fs4 370 |
Definition at line 72 of file buzzer_tunes.c.
| #define Fs5 740 |
Definition at line 84 of file buzzer_tunes.c.
| #define Fs6 1480 |
Definition at line 96 of file buzzer_tunes.c.
| #define Fs7 2960 |
Definition at line 108 of file buzzer_tunes.c.
| #define G4 392 |
Definition at line 73 of file buzzer_tunes.c.
| #define G5 784 |
Definition at line 85 of file buzzer_tunes.c.
| #define G6 1568 |
Definition at line 97 of file buzzer_tunes.c.
| #define G7 3136 |
Definition at line 109 of file buzzer_tunes.c.
| #define Gs4 415 |
Definition at line 74 of file buzzer_tunes.c.
| #define Gs5 831 |
Definition at line 86 of file buzzer_tunes.c.
| #define Gs6 1661 |
Definition at line 98 of file buzzer_tunes.c.
| #define Gs7 3322 |
Definition at line 110 of file buzzer_tunes.c.
| #define IT_BPM 112 |
Italy, Il Canto degli Italiani, first verse (Novaro 1847, public domain).
Definition at line 164 of file buzzer_tunes.c.
| #define NL_BPM 90 |
Netherlands, Wilhelmus, first verse (16th century, public domain).
Definition at line 183 of file buzzer_tunes.c.
| #define REST 0 |
Note frequencies [Hz], s for sharp, octaves 5 to 7 sound loudest on a piezo (octave 4 is quieter).
Definition at line 65 of file buzzer_tunes.c.
Referenced by rtttl_next().
| #define TUNE_END {0, 0} |
Definition at line 123 of file buzzer_tunes.c.
| void buzzer_tunes_init | ( | void | ) |
Definition at line 512 of file buzzer_tunes.c.
References buzzer_arch_init(), buzzer_tunes_play(), and BUZZER_TUNES_STARTUP_TUNE.
| void buzzer_tunes_periodic | ( | void | ) |
Definition at line 558 of file buzzer_tunes.c.
References buzzer_arch_tone(), BUZZER_TUNES_GAP_MS, event_update(), get_sys_time_msec(), note, note_gap, note_start_ms, playing, and start_next_note().
| void buzzer_tunes_play | ( | uint8_t | tune | ) |
Start a tune (BUZZER_TUNES_NONE stops), also the settings handler.
Definition at line 451 of file buzzer_tunes.c.
References BUZZER_TUNES_NONE, and tune_start().
Referenced by buzzer_tunes_init().
| void buzzer_tunes_set_events | ( | uint8_t | on | ) |
Settings handler: enable or disable the armed and alert tunes.
Definition at line 472 of file buzzer_tunes.c.
References buzzer_tunes_events_on, BUZZER_TUNES_NONE, event_tune, and tune_start().
|
static |
Start a tune from an event.
Definition at line 466 of file buzzer_tunes.c.
References BUZZER_TUNES_NONE, buzzer_tunes_tune, event_tune, and tune_start().
Referenced by event_update().
|
static |
Event tunes: alert tune in a loop while the alert condition is true, armed tune in a loop while the motors are armed.
Definition at line 521 of file buzzer_tunes.c.
References autopilot_get_motors_on(), BUZZER_TUNES_ALERT_END_TUNE, BUZZER_TUNES_ALERT_TUNE, buzzer_tunes_events_on, BUZZER_TUNES_NONE, event_start(), event_tune, playing, and tune_start().
Referenced by buzzer_tunes_periodic().
|
static |
Get the next note of the tune, false at the end.
Definition at line 427 of file buzzer_tunes.c.
References rtttl, rtttl_next(), and tune_notes.
Referenced by start_next_note().
|
static |
Parse the next RTTTL note "[duration]note[#][.][octave][.]", false at the end.
Definition at line 390 of file buzzer_tunes.c.
References f, buzzer_note::freq, Min, buzzer_note::ms, p, REST, rtttl, rtttl_bpm, rtttl_d, rtttl_number(), and rtttl_o.
Referenced by next_note().
|
static |
Definition at line 355 of file buzzer_tunes.c.
References p.
Referenced by rtttl_next(), and rtttl_start().
|
static |
Parse the RTTTL header "name:d=4,o=6,b=120:", false if invalid.
Definition at line 365 of file buzzer_tunes.c.
References p, rtttl, rtttl_bpm, rtttl_d, rtttl_number(), and rtttl_o.
Referenced by tune_start().
|
static |
Definition at line 440 of file buzzer_tunes.c.
References buzzer_arch_tone(), BUZZER_TUNES_NONE, get_sys_time_msec(), next_note(), note, note_gap, note_start_ms, and tune_start().
Referenced by buzzer_tunes_periodic(), and tune_start().
|
static |
Definition at line 489 of file buzzer_tunes.c.
References buzzer_arch_tone(), buzzer_tunes_custom, BUZZER_TUNES_CUSTOM_1, buzzer_tunes_list, BUZZER_TUNES_NB, BUZZER_TUNES_NONE, buzzer_tunes_tune, event_tune, playing, rtttl, rtttl_start(), start_next_note(), and tune_notes.
Referenced by buzzer_tunes_play(), buzzer_tunes_set_events(), event_start(), event_update(), and start_next_note().
|
static |
Custom tunes, RTTTL strings.
Definition at line 327 of file buzzer_tunes.c.
Referenced by tune_start().
| uint8_t buzzer_tunes_events_on = BUZZER_TUNES_EVENTS_ON |
armed and alert tunes enabled
Definition at line 342 of file buzzer_tunes.c.
Referenced by buzzer_tunes_set_events(), and event_update().
|
static |
Definition at line 309 of file buzzer_tunes.c.
Referenced by tune_start().
| uint8_t buzzer_tunes_tune = BUZZER_TUNES_NONE |
tune being played, BUZZER_TUNES_NONE when silent
Definition at line 331 of file buzzer_tunes.c.
Referenced by event_start(), and tune_start().
|
static |
current tune was started by an event
Definition at line 343 of file buzzer_tunes.c.
Referenced by buzzer_tunes_set_events(), event_start(), event_update(), and tune_start().
|
static |
note being played
Definition at line 337 of file buzzer_tunes.c.
Referenced by buzzer_tunes_periodic(), and start_next_note().
|
static |
in the silent gap at the end of the note
Definition at line 340 of file buzzer_tunes.c.
Referenced by buzzer_tunes_periodic(), and start_next_note().
|
static |
start time of the note
Definition at line 339 of file buzzer_tunes.c.
Referenced by buzzer_tunes_periodic(), and start_next_note().
|
static |
Definition at line 338 of file buzzer_tunes.c.
Referenced by buzzer_tunes_periodic(), event_update(), and tune_start().
|
static |
next note of a RTTTL tune
Definition at line 334 of file buzzer_tunes.c.
Referenced by next_note(), rtttl_next(), rtttl_start(), and tune_start().
|
static |
RTTTL tempo.
Definition at line 336 of file buzzer_tunes.c.
Referenced by rtttl_next(), and rtttl_start().
|
static |
Definition at line 335 of file buzzer_tunes.c.
Referenced by rtttl_next(), and rtttl_start().
|
static |
RTTTL default duration and octave.
Definition at line 335 of file buzzer_tunes.c.
Referenced by rtttl_next(), and rtttl_start().
|
static |
Definition at line 201 of file buzzer_tunes.c.
|
static |
Definition at line 165 of file buzzer_tunes.c.
|
static |
Definition at line 184 of file buzzer_tunes.c.
|
static |
Beethoven, Fur Elise, first section (public domain).
Definition at line 266 of file buzzer_tunes.c.
|
static |
Tarrega, Gran Vals, the phrase known as the Nokia ringtone (public domain).
Definition at line 260 of file buzzer_tunes.c.
|
static |
|
static |
La Cucaracha, chorus (traditional, public domain).
Definition at line 276 of file buzzer_tunes.c.
|
static |
Mushroom Song.
Definition at line 226 of file buzzer_tunes.c.
|
static |
next note of a built-in tune
Definition at line 333 of file buzzer_tunes.c.
Referenced by next_note(), and tune_start().
|
static |
Beethoven, Ode to Joy, full theme (public domain).
Definition at line 142 of file buzzer_tunes.c.
|
static |
|
static |
|
static |
Twinkle Twinkle Little Star, full song (public domain).
Definition at line 154 of file buzzer_tunes.c.
|
static |
Rossini, William Tell Overture, galop opening, played twice (public domain).
Definition at line 286 of file buzzer_tunes.c.