Use IR Gesture Click which is based on 'APDS-9960' To learn more about IR Gesture key, please refer to "https://shop.mikroe.com/click/hmi/ir-gesture"
main.cpp
- Committer:
- u103060010
- Date:
- 2017-04-03
- Revision:
- 0:55184eb43f43
- Child:
- 1:d5115a30c51d
File content as of revision 0:55184eb43f43:
#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; } } } }