True leaf photo frame,gesture sensing APDS9960,motor fan,color LED

Dependencies:   SFE_APDS9960 mbed

Revision:
1:d16891627cd3
Parent:
0:9b48e23879b3
Child:
2:6b5764a79ccf
--- a/main.cpp	Tue Apr 19 08:04:51 2016 +0000
+++ b/main.cpp	Tue Apr 19 14:15:00 2016 +0000
@@ -4,16 +4,19 @@
 
 Serial pc(P0_23,P0_25);   // TX Pin, RX Pin
 I2C i2c(P0_8, P0_9); 
-SparkFun_APDS9960 apds(&i2c);
+SparkFun_APDS9960 apds(i2c);
+DigitalIn interrupt(P0_10);
+
+ void handleGesture();
 
  int main()
  {
      pc.printf("Hello world!\n"); 
      
-     if(apds.init(10000))
+     if(apds.init(400000))
         pc.printf("APDS-9960 initialization complete\n");
      else
-        pc.printf("Something went wrong during APDS-9960 init!");
+        pc.printf("Something went wrong during APDS-9960 init!\n");
         
      if (apds.enableGestureSensor(true) ) 
         printf("Gesture sensor is now running\n");
@@ -23,6 +26,39 @@
         
      while(1)
      {
-         Led_Blink();     
+         Led_Blink();  
+         if(!interrupt) 
+         {
+            wait_ms(10);
+            if(!interrupt) 
+                handleGesture();
+         }  
     }
- }
\ No newline at end of file
+ }
+ 
+ void handleGesture() {
+    if ( apds.isGestureAvailable() ) {
+    switch ( apds.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");
+    }
+  }
+}
\ No newline at end of file