Instead of holding the songs on a SD card, this one is for a USB stick

Dependencies:   WavPlayer mbed C12832 MSCFileSystem WavPlayerSD

Files at this revision

API Documentation at this revision

Comitter:
JostBaus
Date:
Mon Apr 01 11:34:23 2019 +0000
Parent:
2:b090afa8d3b9
Child:
4:efd586e5c9a7
Commit message:
01.04.19; Fixed some things in func PauseSong();

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Mar 30 16:25:41 2019 +0000
+++ b/main.cpp	Mon Apr 01 11:34:23 2019 +0000
@@ -42,13 +42,13 @@
 int i = 0; //index of files from folder
 int Paused = 0; //Is the song paused?
 int Stopped = 0; //Is the song stopped?
-char* songs[5];
+char* songs[];
 
 int main()
 {
     while(sdDetect == 0) {
         lcd.locate(0,0);
-        lcd.printf("Insert SD Card!!");
+        lcd.printf("Insert SD Card!");
         wait(0.5);
     }
     menu();
@@ -124,15 +124,20 @@
 
 void PauseSong()
 {
-    if(Paused == 0) {
-        string songname = songs[m];
-        unsigned index = songname.find(".wav");
-        songname = songname.substr(0,index);
-        lcd.printf(songname.c_str());
-        dur.stop();
-        Paused = 1;
-    } else {
-        Paused = 0;
+    while(1) {
+        if(Paused == 0) {
+            string songname = songs[m];
+            unsigned index = songname.find(".wav");
+            songname = songname.substr(0,index);
+            lcd.printf(songname.c_str());
+            dur.stop();
+            Paused = 1;
+        } else if(StopBtn == 1) {
+            StopSong();
+        } else {
+            Paused = 0;
+            dur.start();
+        }
     }
 }