Chiang Bing-Han / Mbed 2 deprecated simple_gesture_test

Dependencies:   APDS_9960 mbed

Files at this revision

API Documentation at this revision

Comitter:
u103060010
Date:
Mon Apr 03 15:44:37 2017 +0000
Child:
1:d5115a30c51d
Commit message:
update code

Changed in this revision

APDS_9960.lib 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/APDS_9960.lib	Mon Apr 03 15:44:37 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/u103060010/code/APDS_9960/#8e5d2639d7bf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 03 15:44:37 2017 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "glibr.h"
+
+glibr GSensor(D14,D15);
+Serial pc(USBTX, USBRX);
+
+int isr_flag = 0;
+
+int main(void)
+{
+    
+    if ( GSensor.ginit() ) {
+        pc.printf("APDS-9960 initialization complete\r\n");
+    } else {
+        pc.printf("Something went wrong during APDS-9960 init\r\n");
+        return -1;
+    }
+
+    // Start running the APDS-9960 gesture sensor engine
+    if ( GSensor.enableGestureSensor(true) ) {
+        pc.printf("Gesture sensor is now running\r\n");
+    } else {
+        pc.printf("Something went wrong during gesture sensor init!\r\n");
+        return -1;
+    }
+    
+    while(1) {
+        //pc.printf(".....\r\n");
+        if ( GSensor.isGestureAvailable() ) {
+            switch ( GSensor.readGesture() ) {
+                case DIR_UP:
+                    pc.printf("UP\r\n");
+                    break;
+                case DIR_DOWN:
+                    pc.printf("DOWN\r\n");
+                    break;
+                case DIR_LEFT:
+                    pc.printf("LEFT\r\n");
+                    break;
+                case DIR_RIGHT:
+                    pc.printf("RIGHT\r\n");
+                    break;
+                case DIR_NEAR:
+                    pc.printf("NEAR\r\n");
+                    break;
+                case DIR_FAR:
+                    pc.printf("FAR\r\n");
+                    break;
+                default:
+                    pc.printf("NONE\r\n");
+                    break;
+            }
+        }
+    }    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Apr 03 15:44:37 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/093f2bd7b9eb
\ No newline at end of file