f

Dependencies:   SDFileSystem VS1053 keypad mbed-rtos mbed

Revision:
0:6b577ee3ce76
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 06 07:25:35 2016 +0000
@@ -0,0 +1,80 @@
+#include"mbed.h"
+#include"player.h"
+#include "rtos.h"
+#include "Keypad.h"
+#include<time.h>
+#include<stdlib.h>
+#include<string.h>
+ 
+Serial bt(PA_15,PB_7);
+Player player;
+Ticker t;
+Timer timer;
+extern Serial pc;
+extern playerStatetype  playerState;
+
+extern char listName[50][100];         //song name list
+char listData[50][3];           //song data [0->like, 1->dislike, 2->skip]
+char flag = 0;
+char serial[50];
+char playListName[][50] = {
+    "Sad/Gravity.mp3", "Sad/TaTerMaiRuseuk.mp3", "Sad/NumTaTeHai.mp3", "Sad/MaTanWeLaPord.mp3", "Sad/YaSaeJaiKonDrew.mp3",
+    "Stress/PerJer.mp3", "Stress/YenDTMaiRuJak.mp3", "Stress/Y_Rai.mp3", "Stress/LorLey.mp3", "Stress/NuaGenPaiRuePow.mp3",
+    "Angry/9_Nariga.mp3", "Angry/GluptuaGlupJai.mp3", "Angry/MaiTumMaDa.mp3", "Angry/LaugPee4G.mp3", "Angry/CeakWeeSert.mp3",
+    "Happy/PerJer.mp3", "Happy/Jeep.mp3", "Happy/PoodTumMai.mp3", "Happy/RumSeTow.mp3", "Happy/AO.mp3"
+};
+// Define your own keypad values
+ char Keytable[] = { '1', '2', '3', 'A',   // r0
+                     '4', '5', '6', 'B',   // r1
+                     '7', '8', '9', 'C',   // r2
+                     '*', '0', '#', 'D'    // r3
+                   };
+                  // c0   c1   c2   c3
+//interrupt 
+int num;
+uint32_t buttonIndex;
+uint32_t interruptButton(uint32_t index) {                      //  swap with cbAfterInput() function from keypad.
+    buttonIndex = index;
+    flag = 1;
+    if(buttonIndex == 4) playerState = PS_STOP;     //skip music button
+    return 0;
+    
+}
+
+void buttonFunction(){
+    //input main function in keypad and change something that resonable.
+    
+     Keypad keypad(A5, A4, D2,D3, D4, D5, D6, D7);
+     keypad.attach(&interruptButton);
+     keypad.start();  // energize the keypad via c0-c3  
+    
+}
+
+ 
+int main() {
+     pc.printf("go\n");
+     // player.begin();
+    int i=1; 
+    while(1)
+    {
+        buttonFunction();
+        num=rand()%20;
+        pc.printf("%d\n",num);
+        if(buttonIndex==1||buttonIndex==2||buttonIndex==5||buttonIndex==6){
+            if(i==1){
+                if(buttonIndex==1 ||buttonIndex==2||buttonIndex==5||buttonIndex==6){
+                player.playFile("Angry/9_Nariga.mp3");
+                i=0;pc.printf("hu\n");break;
+                }
+            }
+         if(buttonIndex!=buttonIndex) player.playFile(playListName[0]);
+    }
+        if(flag){
+            //buttonFunction(buttonIndex);
+            pc.printf("next song");
+            flag = 0;
+            
+        }
+        
+    }
+}
\ No newline at end of file