Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ddda99d

Browse files
author
Cefn Hoile
committed
Changed examples to correspond to new classes, method names and invocation metaphors.
1 parent 4bd0c54 commit ddda99d

File tree

3 files changed

+47
-26
lines changed

3 files changed

+47
-26
lines changed

rtttl/examples/ProgmemSong/ProgmemSong.ino

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const char song_P[] PROGMEM = "Tetris:d=4,o=5,b=200:e6,8b,8c6,8d6,16e6,16d6,8c6,
1111
unsigned long printedTime = -1;
1212
unsigned long printedPeriod = 500;
1313

14-
ProgmemSong player(13);
14+
ProgmemPlayer player(13);
1515

1616
void setup(void)
1717
{
@@ -21,22 +21,29 @@ void setup(void)
2121

2222
void loop(void)
2323
{
24-
25-
//play the tune
26-
while(player.tick()){
27-
tryPrint("First Play");
24+
25+
Serial.println("First Play");
26+
27+
//play the song for the first time
28+
player.finishSong();
29+
30+
Serial.println("Song rewound automatically");
31+
32+
//play the tune again, this time blocking per note
33+
while(player.stepSong()){
34+
Serial.println("Second Play");
2835
}
2936

3037
Serial.println("Song rewound automatically");
3138

32-
//play the tune again
33-
while(player.tick()){
34-
tryPrint("Second Play");
39+
//play the tune with no blocking
40+
while(player.pollSong()){
41+
tryPrint("Third Play");
3542
}
3643

3744
Serial.println("Play has ended");
3845
while(true){
39-
//do nothing
46+
//keep the thread in this loop - circuit now silent
4047
}
4148

4249
}

rtttl/examples/RamSong/RamSong.ino

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const char song[] = "AxelF:d=4,o=5,b=125:32p,8g,8p,16a#.,8p,16g,16p,16g,8c6,8g,8
66
unsigned long printedTime = -1;
77
unsigned long printedPeriod = 500;
88

9-
RamSong player(13);
9+
RamPlayer player(13);
1010

1111
void setup(void)
1212
{
@@ -17,21 +17,28 @@ void setup(void)
1717
void loop(void)
1818
{
1919

20-
//play the tune
21-
while(player.tick()){
22-
tryPrint("First Play");
20+
Serial.println("First Play");
21+
22+
//play the song for the first time
23+
player.finishSong();
24+
25+
Serial.println("Song rewound automatically");
26+
27+
//play the tune again, this time blocking per note
28+
while(player.stepSong()){
29+
Serial.println("Second Play");
2330
}
2431

25-
Serial.println("Song auto-rewound");
32+
Serial.println("Song rewound automatically");
2633

27-
//play the tune again
28-
while(player.tick()){
29-
tryPrint("Second Play");
34+
//play the tune with no blocking
35+
while(player.pollSong()){
36+
tryPrint("Third Play");
3037
}
3138

3239
Serial.println("Play has ended");
3340
while(true){
34-
//do nothing
41+
//keep the thread in this loop - circuit now silent
3542
}
3643

3744
}

rtttl/examples/ToneSong/ToneSong.ino

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const char song_P[] PROGMEM = "PacMan:b=160:32b,32p,32b6,32p,32f#6,32p,32d#6,32p
99
unsigned long printedTime = -1;
1010
unsigned long printedPeriod = 500;
1111

12-
ProgmemSong player(13);
12+
ProgmemPlayer player(13);
1313

1414
void setup(void)
1515
{
@@ -20,21 +20,28 @@ void setup(void)
2020
void loop(void)
2121
{
2222

23-
//play the tune
24-
while(player.tick()){
25-
tryPrint("First Play");
23+
Serial.println("First Play");
24+
25+
//play the song for the first time
26+
player.finishSong();
27+
28+
Serial.println("Song rewound automatically");
29+
30+
//play the tune again, this time blocking per note
31+
while(player.stepSong()){
32+
Serial.println("Second Play");
2633
}
2734

2835
Serial.println("Song rewound automatically");
2936

30-
//play the tune again
31-
while(player.tick()){
32-
tryPrint("Second Play");
37+
//play the tune with no blocking
38+
while(player.pollSong()){
39+
tryPrint("Third Play");
3340
}
3441

3542
Serial.println("Play has ended");
3643
while(true){
37-
//do nothing
44+
//keep the thread in this loop - circuit now silent
3845
}
3946

4047
}

0 commit comments

Comments
 (0)