mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
lib tunes: Add string input method
This commit is contained in:
parent
8ce57bedb7
commit
79ae413982
@ -140,6 +140,17 @@ int Tunes::parse_cmd(struct tune_control_s &tune_control, unsigned &frequency, u
|
||||
return continue_sequnece;
|
||||
}
|
||||
|
||||
int Tunes::parse_string(const char *string, unsigned &frequency, unsigned &duration, unsigned &silence)
|
||||
{
|
||||
// set tune string the first time
|
||||
if (_tune == nullptr) {
|
||||
_tune = string;
|
||||
_next = _tune;
|
||||
}
|
||||
|
||||
return next_note(frequency, duration, silence);
|
||||
}
|
||||
|
||||
unsigned Tunes::note_to_frequency(unsigned note)
|
||||
{
|
||||
// compute the frequency (Hz)
|
||||
|
||||
@ -54,6 +54,7 @@ public:
|
||||
Tunes(unsigned tempo, unsigned octave, unsigned note_length, NoteMode mode);
|
||||
~Tunes() = default;
|
||||
int parse_cmd(tune_control_s &tune_control, unsigned &frequency, unsigned &duration, unsigned &silence);
|
||||
int parse_string(const char *string, unsigned &frequency, unsigned &duration, unsigned &silence);
|
||||
|
||||
private:
|
||||
static const unsigned _tune_max = 1024 * 8; // be reasonable about user tunes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user