GR-peach and MRP121

Dependencies:   EasyPlaybackPWM MPR121 PwmOutSpeaker SDBlockDevice_GR_PEACH USBHost_custom

Fork of MPR121_GR-PEACH by Hideki Tanaka

Revision:
11:b95db1f04d7c
Parent:
10:b39c593db05a
Child:
12:3b6f4dccd101
--- a/main.cpp	Mon Oct 23 05:14:30 2017 +0000
+++ b/main.cpp	Mon Oct 23 07:08:43 2017 +0000
@@ -17,7 +17,6 @@
 DigitalOut myled(LED1);
 
 //audio
-static InterruptIn skip_btn(USER_BUTTON0);
 static EasyPlaybackPWM AudioPlayer(P4_5, P4_7);
 
 
@@ -38,9 +37,10 @@
     
     
 void attime(){
-    printf("timer");
+    //printf("timer");
     //audio check and play
     
+    /*
     if(playSE != 0){
         
         AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".wav");
@@ -95,9 +95,15 @@
         }
     }
     playSE = 0;
+    */
     
 }
 
+void play(){
+    fopen("/storage/yonda.wav");
+    AudioPlayer.play("/storage/yonda.wav");
+    fclose("/storage/yonda.wav");
+}
 
 int main()
 {
@@ -109,7 +115,7 @@
     AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".WAV");
 
     // volume control
-    //AudioPlayer.outputVolume(1);  // Volume control (min:0.0 max:1.0)
+    AudioPlayer.outputVolume(1);  // Volume control (min:0.0 max:1.0)
 
     // wait for the storage device to be connected
     printf("Finding a storage...\r\n");
@@ -119,7 +125,6 @@
             fs.mount(&sd);
             break;
         }
-        
     }
     
     printf("done\r\n");
@@ -128,21 +133,38 @@
     playSE = 4;
     timer.attach(&attime,1);
     //AudioPlayer.play("/storage/mugyu.wav");
+    play();
+    AudioPlayer.pause();
     
-    
+    bool pa = AudioPlayer.is_paused();
+    printf("%d", pa);
     //touch pad
     touch_pad.init();
     touch_pad.enable();
     //touch_pad.registerDump(pc);
     
      while(1) {
+        uint16_t button_val;
         if(touch_pad.isPressed()) {
-            uint16_t button_val = touch_pad.buttonPressed();
+            
+            printf("if");
+            button_val = touch_pad.buttonPressed();
             pc.printf("button = 0x%04x\n\r", button_val);
             myled = (button_val>0) ? 1 : 0;
             //AudioPlayer.pause(true);
+            
+        }else{
+            printf("else");
+            button_val = 0;
         }
-        wait(0.1);
+        
+        if(button_val != 0x0000){
+                play();
+                wait(0.3);
+                break;
+        }
+        
+        //wait(0.1);
     }
 
 }