mavsdk::Tune Class Reference
#include: tune.h
The Tune class allows to send a tune to be played by the autopilot.
Public Types
Type | Description |
---|---|
enum Result | Possible results returned for tune requests. |
enum SongElement | Enum representing a song element. |
std::function< void(Result)> result_callback_t | Callback type for async tune calls. |
Public Member Functions
Type | Name | Description |
---|---|---|
Tune (System & system) | Constructor. Creates the plugin for a specific System. | |
~Tune () | Destructor (internal use only). | |
Tune (const Tune &)=delete | Copy constructor (object is not copyable). | |
void | play_tune_async (const std::vector< SongElement > & tune, const int tempo, result_callback_t callback) | Send a tune to be played by the system (asynchronous). |
const Tune & | operator= (const Tune &)=delete | Equality operator (object is not copyable). |
Static Public Member Functions
Type | Name | Description |
---|---|---|
const char * | result_str (Result result) | Gets a human-readable English string for an Tune::Result. |
Constructor & Destructor Documentation
Tune()
mavsdk::Tune::Tune(System &system)
Constructor. Creates the plugin for a specific System.
The plugin is typically created as shown below:
auto tune = std::make_shared<Tune>(system);
Parameters
- System& system - The specific system associated with this plugin.
~Tune()
mavsdk::Tune::~Tune()
Destructor (internal use only).
Tune()
mavsdk::Tune::Tune(const Tune &)=delete
Copy constructor (object is not copyable).
Parameters
- const Tune& -
Member Typdef Documentation
typedef result_callback_t
typedef std::function<void(Result)> mavsdk::Tune::result_callback_t
Callback type for async tune calls.
Member Enumeration Documentation
enum Result
Possible results returned for tune requests.
Value | Description |
---|---|
SUCCESS |
Request succeeded. |
INVALID_TEMPO |
Invalid tempo (range: 32 - 255). |
TUNE_TOO_LONG |
Invalid tune: encoded string must be at most 230 chars. |
ERROR |
Failed to send the request. |
enum SongElement
Enum representing a song element.
Value | Description |
---|---|
STYLE_LEGATO |
|
STYLE_NORMAL |
|
STYLE_STACCATO |
|
DURATION_1 |
|
DURATION_2 |
|
DURATION_4 |
|
DURATION_8 |
|
DURATION_16 |
|
DURATION_32 |
|
NOTE_A |
|
NOTE_B |
|
NOTE_C |
|
NOTE_D |
|
NOTE_E |
|
NOTE_F |
|
NOTE_G |
|
NOTE_PAUSE |
|
SHARP |
|
FLAT |
|
OCTAVE_UP |
|
OCTAVE_DOWN |
Member Function Documentation
play_tune_async()
void mavsdk::Tune::play_tune_async(const std::vector< SongElement > &tune, const int tempo, result_callback_t callback)
Send a tune to be played by the system (asynchronous).
Parameters
- const std::vector< SongElement >& tune - Reference to a vector of song elements.
- const int tempo - Tempo in quarter notes per minute (32 - 255).
- result_callback_t callback - Callback to receive result of this request.
operator=()
const Tune& mavsdk::Tune::operator=(const Tune &)=delete
Equality operator (object is not copyable).
Parameters
- const Tune& -
Returns
const Tune & -
result_str()
static const char* mavsdk::Tune::result_str(Result result)
Gets a human-readable English string for an Tune::Result.
Parameters
- Result result - Enum for which string is required.
Returns
const char * - Human readable string for the Tune::Result.