|
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"
Include dependency graph for buzzer_tunes.c:Go to the source code of this file.
Data Structures | |
| struct | buzzer_note |
Macros | |
| #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. | |
| #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) ((uint16_t)((_b) * 60000.0 / (_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 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. | |
| void | buzzer_tunes_init (void) |
| 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 *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 | |
| struct buzzer_note |
Definition at line 81 of file buzzer_tunes.c.
| Data Fields | ||
|---|---|---|
| uint16_t | freq | [Hz], REST for silence |
| uint16_t | ms | duration [ms] |
| #define A5 880 |
Definition at line 50 of file buzzer_tunes.c.
| #define A6 1760 |
Definition at line 62 of file buzzer_tunes.c.
| #define A7 3520 |
Definition at line 74 of file buzzer_tunes.c.
| #define As5 932 |
Definition at line 51 of file buzzer_tunes.c.
| #define As6 1865 |
Definition at line 63 of file buzzer_tunes.c.
| #define As7 3729 |
Definition at line 75 of file buzzer_tunes.c.
| #define B5 988 |
Definition at line 52 of file buzzer_tunes.c.
| #define B6 1976 |
Definition at line 64 of file buzzer_tunes.c.
| #define B7 3951 |
Definition at line 76 of file buzzer_tunes.c.
Duration of a number of beats at a tempo [ms].
Definition at line 79 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 37 of file buzzer_tunes.c.
| #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 90 of file buzzer_tunes.c.
| #define BUZZER_TUNES_RTTTL_2 "" |
Definition at line 93 of file buzzer_tunes.c.
| #define BUZZER_TUNES_RTTTL_3 "" |
Definition at line 96 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 33 of file buzzer_tunes.c.
| #define C5 523 |
Definition at line 41 of file buzzer_tunes.c.
| #define C6 1047 |
Definition at line 53 of file buzzer_tunes.c.
| #define C7 2093 |
Definition at line 65 of file buzzer_tunes.c.
| #define Cs5 554 |
Definition at line 42 of file buzzer_tunes.c.
| #define Cs6 1109 |
Definition at line 54 of file buzzer_tunes.c.
| #define Cs7 2217 |
Definition at line 66 of file buzzer_tunes.c.
| #define D5 587 |
Definition at line 43 of file buzzer_tunes.c.
| #define D6 1175 |
Definition at line 55 of file buzzer_tunes.c.
| #define D7 2349 |
Definition at line 67 of file buzzer_tunes.c.
| #define Ds5 622 |
Definition at line 44 of file buzzer_tunes.c.
| #define Ds6 1245 |
Definition at line 56 of file buzzer_tunes.c.
| #define Ds7 2489 |
Definition at line 68 of file buzzer_tunes.c.
| #define E5 659 |
Definition at line 45 of file buzzer_tunes.c.
| #define E6 1319 |
Definition at line 57 of file buzzer_tunes.c.
| #define E7 2637 |
Definition at line 69 of file buzzer_tunes.c.
| #define F5 698 |
Definition at line 46 of file buzzer_tunes.c.
| #define F6 1397 |
Definition at line 58 of file buzzer_tunes.c.
| #define F7 2794 |
Definition at line 70 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 163 of file buzzer_tunes.c.
| #define Fs5 740 |
Definition at line 47 of file buzzer_tunes.c.
| #define Fs6 1480 |
Definition at line 59 of file buzzer_tunes.c.
| #define Fs7 2960 |
Definition at line 71 of file buzzer_tunes.c.
| #define G5 784 |
Definition at line 48 of file buzzer_tunes.c.
| #define G6 1568 |
Definition at line 60 of file buzzer_tunes.c.
| #define G7 3136 |
Definition at line 72 of file buzzer_tunes.c.
| #define Gs5 831 |
Definition at line 49 of file buzzer_tunes.c.
| #define Gs6 1661 |
Definition at line 61 of file buzzer_tunes.c.
| #define Gs7 3322 |
Definition at line 73 of file buzzer_tunes.c.
| #define IT_BPM 112 |
Italy, Il Canto degli Italiani, first verse (Novaro 1847, public domain)
Definition at line 127 of file buzzer_tunes.c.
| #define NL_BPM 90 |
Netherlands, Wilhelmus, first verse (16th century, public domain)
Definition at line 146 of file buzzer_tunes.c.
| #define REST 0 |
Note frequencies [Hz], s for sharp, octaves 5 to 7 sound loudest on a piezo.
Definition at line 40 of file buzzer_tunes.c.
| #define TUNE_END {0, 0} |
Definition at line 86 of file buzzer_tunes.c.
Definition at line 406 of file buzzer_tunes.c.
References buzzer_arch_init(), buzzer_tunes_play(), and BUZZER_TUNES_STARTUP_TUNE.
Here is the call graph for this function:Definition at line 412 of file buzzer_tunes.c.
References buzzer_arch_tone(), BUZZER_TUNES_GAP_MS, get_sys_time_msec(), buzzer_note::ms, note, note_gap, note_start_ms, playing, and start_next_note().
Here is the call graph for this function:Start a tune (BUZZER_TUNES_NONE stops), also the settings handler.
Definition at line 384 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, foo, playing, rtttl, rtttl_start(), start_next_note(), and tune_notes.
Referenced by buzzer_tunes_init(), and start_next_note().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Get the next note of the tune, false at the end.
Definition at line 360 of file buzzer_tunes.c.
References foo, buzzer_note::ms, rtttl, rtttl_next(), and tune_notes.
Referenced by start_next_note().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Parse the next RTTTL note "[duration]note[#][.][octave][.]", false at the end.
Definition at line 323 of file buzzer_tunes.c.
References f, foo, buzzer_note::freq, Min, buzzer_note::ms, p, REST, rtttl, rtttl_bpm, rtttl_d, rtttl_number(), and rtttl_o.
Referenced by next_note().
Here is the call graph for this function:
Here is the caller graph for this function:Definition at line 288 of file buzzer_tunes.c.
References p.
Referenced by rtttl_next(), and rtttl_start().
Here is the caller graph for this function:Parse the RTTTL header "name:d=4,o=6,b=120:", false if invalid.
Definition at line 298 of file buzzer_tunes.c.
References foo, p, rtttl, rtttl_bpm, rtttl_d, rtttl_number(), and rtttl_o.
Referenced by buzzer_tunes_play().
Here is the call graph for this function:
Here is the caller graph for this function:Definition at line 373 of file buzzer_tunes.c.
References buzzer_arch_tone(), BUZZER_TUNES_NONE, buzzer_tunes_play(), buzzer_note::freq, get_sys_time_msec(), next_note(), note, note_gap, and note_start_ms.
Referenced by buzzer_tunes_periodic(), and buzzer_tunes_play().
Here is the call graph for this function:
Here is the caller graph for this function:Custom tunes, RTTTL strings.
Definition at line 273 of file buzzer_tunes.c.
Referenced by buzzer_tunes_play().
|
static |
Definition at line 256 of file buzzer_tunes.c.
Referenced by buzzer_tunes_play().
| uint8_t buzzer_tunes_tune = BUZZER_TUNES_NONE |
tune being played, BUZZER_TUNES_NONE when silent
Definition at line 277 of file buzzer_tunes.c.
Referenced by buzzer_tunes_play().
|
static |
note being played
Definition at line 283 of file buzzer_tunes.c.
Referenced by buzzer_tunes_periodic(), and start_next_note().
in the silent gap at the end of the note
Definition at line 286 of file buzzer_tunes.c.
Referenced by buzzer_tunes_periodic(), and start_next_note().
|
static |
start time of the note
Definition at line 285 of file buzzer_tunes.c.
Referenced by buzzer_tunes_periodic(), and start_next_note().
Definition at line 284 of file buzzer_tunes.c.
Referenced by buzzer_tunes_periodic(), and buzzer_tunes_play().
next note of a RTTTL tune
Definition at line 280 of file buzzer_tunes.c.
Referenced by buzzer_tunes_play(), next_note(), rtttl_next(), and rtttl_start().
|
static |
RTTTL tempo.
Definition at line 282 of file buzzer_tunes.c.
Referenced by rtttl_next(), and rtttl_start().
|
static |
Definition at line 281 of file buzzer_tunes.c.
Referenced by rtttl_next(), and rtttl_start().
|
static |
RTTTL default duration and octave.
Definition at line 281 of file buzzer_tunes.c.
Referenced by rtttl_next(), and rtttl_start().
|
static |
Definition at line 164 of file buzzer_tunes.c.
|
static |
Definition at line 128 of file buzzer_tunes.c.
|
static |
Definition at line 147 of file buzzer_tunes.c.
|
static |
Beethoven, Fur Elise, first section (public domain)
Definition at line 229 of file buzzer_tunes.c.
|
static |
Tarrega, Gran Vals, the phrase known as the Nokia ringtone (public domain)
Definition at line 223 of file buzzer_tunes.c.
|
static |
|
static |
La Cucaracha, chorus (traditional, public domain)
Definition at line 239 of file buzzer_tunes.c.
|
static |
Mushroom Song.
Definition at line 189 of file buzzer_tunes.c.
|
static |
next note of a built-in tune
Definition at line 279 of file buzzer_tunes.c.
Referenced by buzzer_tunes_play(), and next_note().
|
static |
Beethoven, Ode to Joy, full theme (public domain)
Definition at line 105 of file buzzer_tunes.c.
|
static |
|
static |
Twinkle Twinkle Little Star, full song (public domain)
Definition at line 117 of file buzzer_tunes.c.
|
static |
Rossini, William Tell Overture, galop opening, played twice (public domain)
Definition at line 249 of file buzzer_tunes.c.