Skip to content

Commit

Permalink
Made communication with DFPlayer more robust so it works with both MH…
Browse files Browse the repository at this point in the history
…2024K-24SS and YX5200
  • Loading branch information
ghmartin77 committed Nov 3, 2018
1 parent 609a597 commit abe87ec
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions KidsMP3Player/KidsMP3Player.ino
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ int readPlayerCurrentFileNumber(int retries) {
int ret = -1;
while (--retries >= 0 && ret == -1) {
ret = player.readCurrentFileNumber(DFPLAYER_DEVICE_SD);

if (ret == -1) {
if (softSerial.overflow()) {
softSerial.flush();
}
delay(250);
}
}
return ret;
}
Expand Down Expand Up @@ -350,6 +357,12 @@ void loop() {
// might occur multiple times within 1 second and you don't want to move
// on more than exactly one track.
delay(1000);
if (softSerial.overflow()) {
softSerial.flush();
}
while (player.available()) {
player.read();
}
}

if (oldTrack == curTrack) {
Expand All @@ -362,3 +375,4 @@ void loop() {
}



0 comments on commit abe87ec

Please sign in to comment.