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"

Dependencies:   APDS_9960 mbed

Committer:
u103060010
Date:
Mon Apr 03 15:44:37 2017 +0000
Revision:
0:55184eb43f43
Child:
1:d5115a30c51d
update code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
u103060010 0:55184eb43f43 1 #include "mbed.h"
u103060010 0:55184eb43f43 2 #include "glibr.h"
u103060010 0:55184eb43f43 3
u103060010 0:55184eb43f43 4 glibr GSensor(D14,D15);
u103060010 0:55184eb43f43 5 Serial pc(USBTX, USBRX);
u103060010 0:55184eb43f43 6
u103060010 0:55184eb43f43 7 int isr_flag = 0;
u103060010 0:55184eb43f43 8
u103060010 0:55184eb43f43 9 int main(void)
u103060010 0:55184eb43f43 10 {
u103060010 0:55184eb43f43 11
u103060010 0:55184eb43f43 12 if ( GSensor.ginit() ) {
u103060010 0:55184eb43f43 13 pc.printf("APDS-9960 initialization complete\r\n");
u103060010 0:55184eb43f43 14 } else {
u103060010 0:55184eb43f43 15 pc.printf("Something went wrong during APDS-9960 init\r\n");
u103060010 0:55184eb43f43 16 return -1;
u103060010 0:55184eb43f43 17 }
u103060010 0:55184eb43f43 18
u103060010 0:55184eb43f43 19 // Start running the APDS-9960 gesture sensor engine
u103060010 0:55184eb43f43 20 if ( GSensor.enableGestureSensor(true) ) {
u103060010 0:55184eb43f43 21 pc.printf("Gesture sensor is now running\r\n");
u103060010 0:55184eb43f43 22 } else {
u103060010 0:55184eb43f43 23 pc.printf("Something went wrong during gesture sensor init!\r\n");
u103060010 0:55184eb43f43 24 return -1;
u103060010 0:55184eb43f43 25 }
u103060010 0:55184eb43f43 26
u103060010 0:55184eb43f43 27 while(1) {
u103060010 0:55184eb43f43 28 //pc.printf(".....\r\n");
u103060010 0:55184eb43f43 29 if ( GSensor.isGestureAvailable() ) {
u103060010 0:55184eb43f43 30 switch ( GSensor.readGesture() ) {
u103060010 0:55184eb43f43 31 case DIR_UP:
u103060010 0:55184eb43f43 32 pc.printf("UP\r\n");
u103060010 0:55184eb43f43 33 break;
u103060010 0:55184eb43f43 34 case DIR_DOWN:
u103060010 0:55184eb43f43 35 pc.printf("DOWN\r\n");
u103060010 0:55184eb43f43 36 break;
u103060010 0:55184eb43f43 37 case DIR_LEFT:
u103060010 0:55184eb43f43 38 pc.printf("LEFT\r\n");
u103060010 0:55184eb43f43 39 break;
u103060010 0:55184eb43f43 40 case DIR_RIGHT:
u103060010 0:55184eb43f43 41 pc.printf("RIGHT\r\n");
u103060010 0:55184eb43f43 42 break;
u103060010 0:55184eb43f43 43 case DIR_NEAR:
u103060010 0:55184eb43f43 44 pc.printf("NEAR\r\n");
u103060010 0:55184eb43f43 45 break;
u103060010 0:55184eb43f43 46 case DIR_FAR:
u103060010 0:55184eb43f43 47 pc.printf("FAR\r\n");
u103060010 0:55184eb43f43 48 break;
u103060010 0:55184eb43f43 49 default:
u103060010 0:55184eb43f43 50 pc.printf("NONE\r\n");
u103060010 0:55184eb43f43 51 break;
u103060010 0:55184eb43f43 52 }
u103060010 0:55184eb43f43 53 }
u103060010 0:55184eb43f43 54 }
u103060010 0:55184eb43f43 55 }