Demo Team / Mbed 2 deprecated bluefruit

Dependencies:   mbed

Revision:
7:af2244bedcac
Parent:
5:9af1305f7779
--- a/main.cpp	Mon Apr 13 08:31:37 2015 +0000
+++ b/main.cpp	Mon Apr 20 09:58:04 2015 +0000
@@ -32,24 +32,39 @@
 #include "Play.h"
 #include "stdio.h"
 
+int reset = 0;
+
 int main()
 {
     pc.printf("\n\r *****");
     pc.printf("\n\r START");
-    pc.printf("\n\r ***** \n");
+    pc.printf("\n\r ***** \n\r");
     setup(0);
     
+    playI.rise(&play); //Play button configured as interrupt
+    
     while(1) {
         
-        if(two_pressed == 0) {
+        if(two_pressed == 0 && one_pressed == 0) {
             wait_time.start();
         }
-        playI.rise(&play); //Play button configured as interrupt
         
-        if (bluefruit.readable() && flag == 0) {
+        if (bluefruit.readable()) {
             bluefruit.gets(key_ID, 9);
             //pc.puts(key_ID);  //displays string value sent from Bluefruit E-Z Key to LPC1768
-            string_comparator(key_ID);
+
+            if (playflag == 0) {
+                string_comparator(key_ID);
+            } else {
+                // if the play button was pressed do nothing with next key
+                if (reset < 2) {
+                    reset++;
+                } else {
+                    playflag = 0;
+                    reset = 0;
+                }
+            }
+            
         }
     }
 }
\ No newline at end of file