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 15:49:34 2015 +0000
Parent:
11:ea43b0b83222
Child:
13:5930645dc5f0
Commit message:
updatedspeaker

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Mar 11 14:56:59 2015 +0000
+++ b/main.cpp	Wed Mar 11 15:49:34 2015 +0000
@@ -3,11 +3,10 @@
 #include "SDFileSystem.h"
 #include "wave_player.h"
 
-glibr test(p9,p10);
+glibr GSensor(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);
 //InterruptIn interrupt(p11);
@@ -20,14 +19,14 @@
     myled = 0;
     ret = 0;
     val = 0;
-    if ( test.ginit() ) {
+    if ( GSensor.ginit() ) {
         pc.printf("APDS-9960 initialization complete\n\r");
     } else {
         pc.printf("Something went wrong during APDS-9960 init\n\r");
     }
 
     // Start running the APDS-9960 gesture sensor engine
-    if ( test.enableGestureSensor(true) ) {
+    if ( GSensor.enableGestureSensor(true) ) {
         pc.printf("Gesture sensor is now running\n\r");
     } else {
         pc.printf("Something went wrong during gesture sensor init!\n\r");
@@ -40,21 +39,21 @@
     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");
+    Up=fopen("/sd/up.wav","r");
+    Down=fopen("/sd/down.wav","r");
+    Left=fopen("/sd/left.wav","r");
+    Right=fopen("/sd/right.wav","r");
+    Far=fopen("/sd/far.wav","r");
+    Near=fopen("/sd/near.wav","r");
     //   waver.play(wave_file);
     while(1) {
-        /* ret = test.isGestureAvailable();
+        /* ret = GSensor.isGestureAvailable();
          pc.printf("Is Gesture Available?: %d\n", ret);
          myled = ret;
-         val = test.readGesture();
+         val = GSensor.readGesture();
          */
-        if ( test.isGestureAvailable() ) {
-            switch ( test.readGesture() ) {
+        if ( GSensor.isGestureAvailable() ) {
+            switch ( GSensor.readGesture() ) {
                 case DIR_UP:
                     pc.printf("UP\n");
                     waver.play(Up);
@@ -88,13 +87,13 @@
         //   wait(1);
 
     }
-     fclose(Up);
-     fclose(Down);
-     fclose(Left);
-     fclose(Right);
-     fclose(Near);
-     fclose(Far);
-     fclose(Left);
-     
+    fclose(Up);
+    fclose(Down);
+    fclose(Left);
+    fclose(Right);
+    fclose(Near);
+    fclose(Far);
+    fclose(Left);
+
 
 }
\ No newline at end of file