WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

attach

Attach a callback function that is called when the current tone has stopped playing.
Syntax
TonePlayer. attach(callback)
Where TonePlayer is the name you have given to the device in Project Designer.
Parameters
TypeNameDescription
'callback'
The function you want WebbotLib to call when the current tone has stopped playing.
Returns
None
Example
Assuming you have called your tone player 'tone' in Project Designer:-
void callback(TonePlayer& player){
    // The current tone has stopped
    // Play another note
    player.play(NOTE_F6,1000);
 
    // Don't notify me again
    player.detach();
}
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
    // Register my callback routine
    tone.attach(&callback);
 
    // Play the note of A in octave 4 (440Hz) for 2 seconds
    // after that time then 'callback' will be called
    tone.play(NOTE_A4, 2000);
 
    return 0;
}
See Also
detach

 

 

Valid XHTML 1.0 Transitional