Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystem wave_player
Diff: main.cpp
- 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

Sparkfun RGB and Gesture Sensor APDS-9960