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

main.cpp

Committer:
kbhagat6
Date:
2015-03-09
Revision:
10:e8adab2fb829
Parent:
0:437ae08befe3
Child:
11:ea43b0b83222

File content as of revision 10:e8adab2fb829:

#include "mbed.h"
#include "glibr.h"
//#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;

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");
    }

    // 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");
            }
        }

        wait(1);

    }
}