Uses the APDS_9960 Digital Proximity, Ambient Light, RGB and Gesture Sensor library to play detected gesture sounds on a speaker from the SDcard

Dependencies:   mbed SDFileSystem wave_player

Files at this revision

API Documentation at this revision

Comitter:
kbhagat6
Date:
Wed Mar 11 14:56:59 2015 +0000
Parent:
10:e8adab2fb829
Child:
12:63c81930b5d9
Commit message:
speaker stuff added

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
glibr.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
wave_player.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Wed Mar 11 14:56:59 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
--- a/glibr.cpp	Mon Mar 09 21:17:34 2015 +0000
+++ b/glibr.cpp	Wed Mar 11 14:56:59 2015 +0000
@@ -915,17 +915,13 @@
         }
     }
     
-/* #if DEBUG
-    Serial.print("UD_CT: ");
-    Serial.print(gesture_ud_count_);
-    Serial.print(" LR_CT: ");
-    Serial.print(gesture_lr_count_);
-    Serial.print(" NEAR_CT: ");
-    Serial.print(gesture_near_count_);
-    Serial.print(" FAR_CT: ");
-    Serial.println(gesture_far_count_);
-    Serial.println("----------");
-#endif */
+// #if DEBUG
+      printf("UD_CT: %d\n",gesture_ud_count_);
+      printf("LR_CT: %d\n",gesture_lr_count_);
+      printf("NEAR_CT: %d\n",gesture_near_count_);
+      printf(" FAR_CT: %d\n",gesture_far_count_);
+      printf("----------");
+//#endif */
     
     return false;
 }
--- a/main.cpp	Mon Mar 09 21:17:34 2015 +0000
+++ b/main.cpp	Wed Mar 11 14:56:59 2015 +0000
@@ -1,15 +1,12 @@
 #include "mbed.h"
 #include "glibr.h"
-//#include <Wire.h>
-//#include <SparkFun_APDS9960.h>
+#include "SDFileSystem.h"
+#include "wave_player.h"
 
-// Pins
-//#define APDS9960_INT    2 // Needs to be an interrupt pin
-
-// Constants
-
-// Global Variables
 glibr test(p9,p10);
+SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
+AnalogOut DACout(p18);
+wave_player waver(&DACout);
 //SparkFun_APDS9960 apds = SparkFun_APDS9960();
 int isr_flag = 0;
 DigitalOut myled(LED1);
@@ -36,6 +33,20 @@
         pc.printf("Something went wrong during gesture sensor init!\n\r");
     }
 
+    FILE *Up;
+    FILE *Down;
+    FILE *Left;
+    FILE *Right;
+    FILE *Far;
+    FILE *Near;
+
+    Up=fopen("/sd/myMusic/up.wav","r");
+    Down=fopen("/sd/myMusic/down.wav","r");
+    Left=fopen("/sd/myMusic/left.wav","r");
+    Right=fopen("/sd/myMusic/right.wav","r");
+    Far=fopen("/sd/myMusic/far.wav","r");
+    Near=fopen("/sd/myMusic/near.wav","r");
+    //   waver.play(wave_file);
     while(1) {
         /* ret = test.isGestureAvailable();
          pc.printf("Is Gesture Available?: %d\n", ret);
@@ -46,28 +57,44 @@
             switch ( test.readGesture() ) {
                 case DIR_UP:
                     pc.printf("UP\n");
+                    waver.play(Up);
                     break;
                 case DIR_DOWN:
                     pc.printf("DOWN\n");
+                    waver.play(Down);
                     break;
                 case DIR_LEFT:
                     pc.printf("LEFT\n");
+                    waver.play(Left);
                     break;
                 case DIR_RIGHT:
                     pc.printf("RIGHT\n");
+                    waver.play(Right);
                     break;
                 case DIR_NEAR:
                     pc.printf("NEAR\n");
+                    waver.play(Near);
                     break;
                 case DIR_FAR:
                     pc.printf("FAR\n");
+                    waver.play(Far);
                     break;
                 default:
                     pc.printf("NONE\n");
             }
         }
 
-        wait(1);
+
+        //   wait(1);
 
     }
+     fclose(Up);
+     fclose(Down);
+     fclose(Left);
+     fclose(Right);
+     fclose(Near);
+     fclose(Far);
+     fclose(Left);
+     
+
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wave_player.lib	Wed Mar 11 14:56:59 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/sravet/code/wave_player/#acc3e18e77ad