|
Firmware
|
Library for parsing tunes from melody-strings or dedicated tune messages. More...
#include <tunes.h>
Public Types | |
| enum | NoteMode { NORMAL, LEGATO, STACCATO } |
Public Member Functions | |
| Tunes (unsigned default_note_length=TUNE_DEFAULT_NOTE_LENGTH, NoteMode default_note_mode=NoteMode::NORMAL, unsigned default_octave=TUNE_DEFAULT_OCTAVE, unsigned default_tempo=TUNE_DEFAULT_TEMPO) | |
| Constructor with the default parameters set to: default_tempo: TUNE_DEFAULT_TEMPO default_octave: TUNE_DEFAULT_OCTAVE default_note_length: TUNE_DEFAULT_NOTE_LENGTH default_mode: NORMAL. | |
| int | set_control (const tune_control_s &tune_control) |
| Set tune to be played using the message. More... | |
| void | set_string (const char *const string, uint8_t volume) |
| Set tune to be played using a string. More... | |
| int | get_next_note (unsigned &frequency, unsigned &duration, unsigned &silence) |
| Get next note in the current tune, which has been provided by either set_control or play_string. More... | |
| int | get_next_note (unsigned &frequency, unsigned &duration, unsigned &silence, uint8_t &volume) |
| Get next note in the current tune, which has been provided by either set_control or play_string. More... | |
| unsigned int | get_default_tunes_size () const |
| Get the number of default tunes. More... | |
| unsigned int | get_maximum_update_interval () |
Library for parsing tunes from melody-strings or dedicated tune messages.
Needs to be instantiated as it keeps track of which tune is to be played next. Also handles repeated tunes.
|
inline |
Get the number of default tunes.
This is useful for when a tune is requested via its tune ID.
| int Tunes::get_next_note | ( | unsigned & | frequency, |
| unsigned & | duration, | ||
| unsigned & | silence | ||
| ) |
Get next note in the current tune, which has been provided by either set_control or play_string.
| frequency | return frequency value (Hz) |
| duration | return duration of the tone (us) |
| silence | return silence duration (us) |
| int Tunes::get_next_note | ( | unsigned & | frequency, |
| unsigned & | duration, | ||
| unsigned & | silence, | ||
| uint8_t & | volume | ||
| ) |
Get next note in the current tune, which has been provided by either set_control or play_string.
| frequency | return frequency value (Hz) |
| duration | return duration of the note (us) |
| silence | return silence duration (us) |
| volume | return the volume level of the note (between 0-100) |
| int Tunes::set_control | ( | const tune_control_s & | tune_control | ) |
Set tune to be played using the message.
If a tune is already being played the call to this function will be ignored, unless the override flag is set or the tune being already played is a repeated tune.
| tune_control | struct containig the uORB message |
| void Tunes::set_string | ( | const char *const | string, |
| uint8_t | volume | ||
| ) |
Set tune to be played using a string.
Parses a tune string, formatted with the syntax of the Microsoft GWBasic/QBasic. Ownership of the string is NOT transferred. The string has to be kept in memory for the whole duration of the melody.
| string | tune input string |
1.8.12