eLab Team / Mbed 2 deprecated LaLaBox

Dependencies:   mbed CREALIB

Revision:
18:92f4f2b44d6d
Parent:
16:8ae70f0b8fca
Child:
19:aa99c24e4ee0
diff -r 8ae70f0b8fca -r 92f4f2b44d6d main.cpp
--- a/main.cpp	Sun Mar 12 17:09:48 2017 +0000
+++ b/main.cpp	Tue Apr 11 23:03:07 2017 +0000
@@ -12,7 +12,13 @@
 // ---------------- Local global variables --------------
 
 // --- Sound ---
-Music song_happy_birthday("Happy Birthday Song:d=4,o=5,b=125:16c,32p,32c,32p,8d,32p,8c,32p,8f,32p,e,16p,16c,32p,32c,32p,8d,32p,8c,32p,8g,32p,f,8p,16c,32p,32c,32p,8c6,32p,8a,32p,8f,32p,8e,32p,8d,32p,16a#,32p,32a#,32p,8a,32p,8f,32p,8g,32p,f");
+/*Music song_happy_birthday("Happy Birthday Song:d=4,o=5,b=125:16c,32p,32c,32p,8d,32p,8c,32p,8f,32p,e,16p,16c,32p,32c,32p,8d,32p,8c,32p,8g,32p,f,8p,16c,32p,32c,32p,8c6,32p,8a,32p,8f,32p,8e,32p,8d,32p,16a#,32p,32a#,32p,8a,32p,8f,32p,8g,32p,f");
+Music song_greensleaves("Greensleaves:d=4,o=5,b=140:g,2a#,c6,d.6,8d#6,d6,2c6,a,f.,8g,a,2a#,g,g.,8f,g,2a,f,2d,g,2a#,c6,d.6,8e6,d6,2c6,a,f.,8g,a,a#.,8a,g,f#.,8e,f#,2g");
+Music song_lightmyfire("LightMyFire:d=4,o=5,b=140:8b,16g,16a,8b,8d6,8c6,8b,8a,8g,8a,16f,16a,8c6,8f6,16d6,16c6,16a#,16g,8g#,8g,8g#,16g,16a,8b,8c#6,16b,16a,16g,16f,8e,8f,1a,a");
+Music song_xfile("Xfiles:d=4,o=5,b=140:e,b,a,b,d6,2b.");
+Music song_christmas("Christmas:d=4,o=5,b=100:f#,g#,2a#,2a#,d#.,8f,f,f,2f#,2d#,2f#.6,f#,#g,8g#,g#,8a#,b,8c#,c#,2c#,8d#,8f.,8f#.,8f.,d#,f,2f#.,a#,8b.,8b.,8b.,d#,f,2c#.,a#,8b.,8b.,8b.,d#,f,f#,p,g#,g#,g#,8g#,8a#,8g#,f#.,g#,a#,p,c,c,c,8c,8c#,8c,a#.,c,c#,a#,b,a#,a,a#,b,c,");
+*/
+const char song_happy_birthday[]="Happy Birthday Song:d=4,o=5,b=125:16c,32p,32c,32p,8d,32p,8c,32p,8f,32p,e,16p,16c,32p,32c,32p,8d,32p,8c,32p,8g,32p,f,8p,16c,32p,32c,32p,8c6,32p,8a,32p,8f,32p,8e,32p,8d,32p,16a#,32p,32a#,32p,8a,32p,8f,32p,8g,32p,f";
 Music song_greensleaves("Greensleaves:d=4,o=5,b=140:g,2a#,c6,d.6,8d#6,d6,2c6,a,f.,8g,a,2a#,g,g.,8f,g,2a,f,2d,g,2a#,c6,d.6,8e6,d6,2c6,a,f.,8g,a,a#.,8a,g,f#.,8e,f#,2g");
 Music song_lightmyfire("LightMyFire:d=4,o=5,b=140:8b,16g,16a,8b,8d6,8c6,8b,8a,8g,8a,16f,16a,8c6,8f6,16d6,16c6,16a#,16g,8g#,8g,8g#,16g,16a,8b,8c#6,16b,16a,16g,16f,8e,8f,1a,a");
 Music song_xfile("Xfiles:d=4,o=5,b=140:e,b,a,b,d6,2b.");
@@ -20,7 +26,7 @@
 
 // ---------------- PIN DEFINITIONS ---------------------
 DigitalOut myled(LED1);     // Blinking LED
-InterruptIn  buttonBox(PB_1);
+InterruptIn  buttonBox(PB_1); 
 
 // --- Define the Four PINs & Time of movement used for Motor drive -----
 Motor motorBox(PA_8, PA_11, PB_5, PB_4, 5000);
@@ -31,8 +37,9 @@
 
 // --- Define PB_0 as the output of PWM use for Tones -----
 Buzzer buzzer(PB_0);
+MusicStatic myMusic(&buzzer);
 
-Note la("A#4",50);  //the sound
+//Note la("A#4",50);  //the sound
 
 void help() // Display list of Commands
 {
@@ -74,13 +81,14 @@
     buttonBox.fall(&clicked);
 
     /* Play a tone */
-    PLAY_NOTE(la, buzzer);
+ //   PLAY_NOTE(la, buzzer);
 
     wait(2);        // Some delay
     myled = 0;      // Real stuff starts here
     ledBand.SetColor(BLACK);
     DEBUG("Enter a command : \n\r");
-
+    myMusic.play(song_happy_birthday);
+ //   song_greensleaves.play(&buzzer);
     while(1) {
         char command;   // Command to execute
         DEBUG(">> ");
@@ -98,11 +106,11 @@
                 CASE('f', "Dancer Clock Wise ", motorDancer.RunInfinite(CLOCKWISE);    )
                 CASE('j', "Dancer Counter Clock Wise ", motorDancer.RunInfinite(COUNTERCLOCKWISE);    )
                 CASE('s', "STOP ", stop_all();   )
-                CASE('m', "Music 1", PLAY_MUSIC(song_xfile,buzzer);   )
-                CASE('n', "Music 2", PLAY_MUSIC(song_lightmyfire,buzzer);   )
-                CASE('p', "Music 3", PLAY_MUSIC(song_greensleaves,buzzer);   )
-                CASE('q', "Music 4", PLAY_MUSIC(song_christmas,buzzer);   )
-                CASE('r', "Music 5", PLAY_MUSIC(song_happy_birthday,buzzer);   )
+      //          CASE('m', "Music 1", PLAY_MUSIC(song_xfile,buzzer);   )
+       //         CASE('n', "Music 2", PLAY_MUSIC(song_lightmyfire,buzzer);   )
+        //        CASE('p', "Music 3", PLAY_MUSIC(song_greensleaves,buzzer);   )
+         //       CASE('q', "Music 4", PLAY_MUSIC(song_christmas,buzzer);   )
+          //      CASE('r', "Music 5", PLAY_MUSIC(song_happy_birthday,buzzer);   )
                 CASE('l', "Light ",
                      ledBand.StopRotation(); ledBand.ResetColor();
                      ledBand.InsertColorNtimes(3,YELLOW,5.0);