mavsdk::Tune Class Reference

#include: tune.h


Enable creating and sending a tune to be played on the system.

Data Structures

struct TuneDescription

Public Types

Type Description
enum SongElement An element of the tune.
enum Result Possible results returned for tune requests.
std::function< void(Result)> ResultCallback Callback type for asynchronous 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 (TuneDescription description, const ResultCallback callback) Send a tune to be played by the system.
Result play_tune (TuneDescription description)const Send a tune to be played by the system.
const Tune & operator= (const Tune &)=delete Equality operator (object is not copyable).

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

Member Typdef Documentation

typedef ResultCallback

using mavsdk::Tune::ResultCallback =  std::function<void(Result)>

Callback type for asynchronous Tune calls.

Member Enumeration Documentation

enum SongElement

An element of the tune.

Value Description
StyleLegato After this element, start playing legato.
StyleNormal After this element, start playing normal.
StyleStaccato After this element, start playing staccato.
Duration1 After this element, set the note duration to 1.
Duration2 After this element, set the note duration to 2.
Duration4 After this element, set the note duration to 4.
Duration8 After this element, set the note duration to 8.
Duration16 After this element, set the note duration to 16.
Duration32 After this element, set the note duration to 32.
NoteA Play note A.
NoteB Play note B.
NoteC Play note C.
NoteD Play note D.
NoteE Play note E.
NoteF Play note F.
NoteG Play note G.
NotePause Play a rest.
Sharp After this element, sharp the note (half a step up).
Flat After this element, flat the note (half a step down).
OctaveUp After this element, shift the note 1 octave up.
OctaveDown After this element, shift the note 1 octave down.

enum Result

Possible results returned for tune requests.

Value Description
Success Request succeeded.
InvalidTempo Invalid tempo (range: 32 - 255).
TuneTooLong Invalid tune: encoded string must be at most 247 chars.
Error Failed to send the request.

Member Function Documentation

play_tune_async()

void mavsdk::Tune::play_tune_async(TuneDescription description, const ResultCallback callback)

Send a tune to be played by the system.

This function is non-blocking. See 'play_tune' for the blocking counterpart.

Parameters

play_tune()

Result mavsdk::Tune::play_tune(TuneDescription description) const

Send a tune to be played by the system.

This function is blocking. See 'play_tune_async' for the non-blocking counterpart.

Parameters

Returns

Result - Result of request.

operator=()

const Tune& mavsdk::Tune::operator=(const Tune &)=delete

Equality operator (object is not copyable).

Parameters

Returns

 const Tune & -

© Dronecode 2017-2019. License: CC BY 4.0            Updated: 2020-06-05 09:10:43

results matching ""

    No results matching ""