1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00

Selecting the melody to play when alarm goes off

This commit is contained in:
Rhys Weatherley
2012-05-23 15:06:54 +10:00
parent 23c98820f7
commit 4ac487fe05
7 changed files with 164 additions and 4 deletions

View File

@@ -137,7 +137,7 @@ void Melody::setLoopDuration(unsigned long ms)
/**
* \brief Starts playing the melody, or restarts it if already playing.
*
* \sa setMelody(), stop(), loopCount()
* \sa playOnce(), setMelody(), stop(), loopCount()
*/
void Melody::play()
{
@@ -150,6 +150,22 @@ void Melody::play()
nextNote();
}
/**
* \brief Plays the melody once and then stops.
*
* \sa play(), stop()
*/
void Melody::playOnce()
{
stop();
if (size == 0)
return; // No melody to play.
loopsLeft = 1;
posn = 0;
playing = true;
nextNote();
}
/**
* \brief Stops playing the melody.
*

View File

@@ -131,6 +131,7 @@ public:
void setLoopDuration(unsigned long ms);
void play();
void playOnce();
void stop();
void setMelody(const int *notes, const uint8_t *lengths, unsigned int size);