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

Revision:
10:e8adab2fb829
Parent:
0:437ae08befe3
Child:
11:ea43b0b83222
--- a/main.cpp	Fri Mar 06 22:59:40 2015 +0000
+++ b/main.cpp	Mon Mar 09 21:17:34 2015 +0000
@@ -1,15 +1,73 @@
 #include "mbed.h"
 #include "glibr.h"
-//DigitalOut myled(LED1);
+//#include <Wire.h>
+//#include <SparkFun_APDS9960.h>
+
+// Pins
+//#define APDS9960_INT    2 // Needs to be an interrupt pin
+
+// Constants
+
+// Global Variables
+glibr test(p9,p10);
+//SparkFun_APDS9960 apds = SparkFun_APDS9960();
+int isr_flag = 0;
+DigitalOut myled(LED1);
+//InterruptIn interrupt(p11);
 Serial pc(USBTX, USBRX);
+bool ret;
+int val;
 
-glibr test(p9,p10);
+int main()
+{
+    myled = 0;
+    ret = 0;
+    val = 0;
+    if ( test.ginit() ) {
+        pc.printf("APDS-9960 initialization complete\n\r");
+    } else {
+        pc.printf("Something went wrong during APDS-9960 init\n\r");
+    }
 
-int main() {
+    // Start running the APDS-9960 gesture sensor engine
+    if ( test.enableGestureSensor(true) ) {
+        pc.printf("Gesture sensor is now running\n\r");
+    } else {
+        pc.printf("Something went wrong during gesture sensor init!\n\r");
+    }
 
+    while(1) {
+        /* ret = test.isGestureAvailable();
+         pc.printf("Is Gesture Available?: %d\n", ret);
+         myled = ret;
+         val = test.readGesture();
+         */
+        if ( test.isGestureAvailable() ) {
+            switch ( test.readGesture() ) {
+                case DIR_UP:
+                    pc.printf("UP\n");
+                    break;
+                case DIR_DOWN:
+                    pc.printf("DOWN\n");
+                    break;
+                case DIR_LEFT:
+                    pc.printf("LEFT\n");
+                    break;
+                case DIR_RIGHT:
+                    pc.printf("RIGHT\n");
+                    break;
+                case DIR_NEAR:
+                    pc.printf("NEAR\n");
+                    break;
+                case DIR_FAR:
+                    pc.printf("FAR\n");
+                    break;
+                default:
+                    pc.printf("NONE\n");
+            }
+        }
 
- uint8_t  cool;
-cool=test.ginit();
-//pc.printf("cool");
-pc.printf("%u", cool);
-}
+        wait(1);
+
+    }
+}
\ No newline at end of file