mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 11:59:17 +08:00
lib tunes: Add string input method
This commit is contained in:
committed by
Daniel Agar
parent
8ce57bedb7
commit
79ae413982
@@ -140,6 +140,17 @@ int Tunes::parse_cmd(struct tune_control_s &tune_control, unsigned &frequency, u
|
|||||||
return continue_sequnece;
|
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)
|
unsigned Tunes::note_to_frequency(unsigned note)
|
||||||
{
|
{
|
||||||
// compute the frequency (Hz)
|
// compute the frequency (Hz)
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public:
|
|||||||
Tunes(unsigned tempo, unsigned octave, unsigned note_length, NoteMode mode);
|
Tunes(unsigned tempo, unsigned octave, unsigned note_length, NoteMode mode);
|
||||||
~Tunes() = default;
|
~Tunes() = default;
|
||||||
int parse_cmd(tune_control_s &tune_control, unsigned &frequency, unsigned &duration, unsigned &silence);
|
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:
|
private:
|
||||||
static const unsigned _tune_max = 1024 * 8; // be reasonable about user tunes
|
static const unsigned _tune_max = 1024 * 8; // be reasonable about user tunes
|
||||||
|
|||||||
Reference in New Issue
Block a user