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: Pixart_Gesture USBDevice mbed
Fork of PAJ7620_Gesture by
main.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * This is gesture keyboard demo by Kevin Lee 00004 */ 00005 00006 #include "mbed.h" 00007 #include "Gesture.h" 00008 #include "USBKeyboard.h" 00009 00010 // #ifdef DEBUG 00011 // #include "USBSerial.h" // To use USB virtual serial, a driver is needed, check http://mbed.org/handbook/USBSerial 00012 // #define LOG(args...) pc.printf(args) 00013 //#include "USBSerial.h" 00014 00015 //USBSerial pc; 00016 //Serial pc(USBTX, USBRX); 00017 USBKeyboard keyboard; 00018 I2C i2c(P0_5, P0_4); 00019 Ticker ticker; 00020 00021 #define dly 100 //LED delay 00022 00023 void Gesture_LED(PIXART_GESTURE_TYPE gesture); 00024 00025 void GetGestute(PIXART_GESTURE_TYPE gesture) 00026 { 00027 //UP,DOWN,LEFT,RIGHT,PUSH,POLL,CLOCKWISE,COUNTER_CLOCKWISE,WAVE}; 00028 switch (gesture) 00029 { 00030 case UP: 00031 // pc.printf("UP \r\n"); 00032 keyboard.mediaControl(KEY_VOLUME_UP); 00033 break; 00034 case DOWN: 00035 // pc.printf("DOWN \r\n"); 00036 keyboard.mediaControl(KEY_VOLUME_DOWN); 00037 break; 00038 case LEFT: 00039 keyboard.mediaControl(KEY_PREVIOUS_TRACK); 00040 // pc.printf("LEFT \r\n"); 00041 break; 00042 case RIGHT: 00043 keyboard.mediaControl(KEY_NEXT_TRACK); 00044 // pc.printf("RIGHT \r\n"); 00045 break; 00046 case PUSH: 00047 keyboard.mediaControl(KEY_MUTE); 00048 // pc.printf("PUSH \r\n"); 00049 00050 break; 00051 case POLL: 00052 keyboard.mediaControl(KEY_MUTE); 00053 break; 00054 case CLOCKWISE: 00055 keyboard.mediaControl(KEY_PLAY_PAUSE); 00056 // pc.printf("CLOCKWISE \r\n"); 00057 break; 00058 case COUNTER_CLOCKWISE: 00059 keyboard.mediaControl(KEY_STOP); 00060 // pc.printf("COUNTER_CLOCKWISE \r\n"); 00061 break; 00062 case WAVE: 00063 // pc.printf("WAVE \r\n"); 00064 break; 00065 default: 00066 // pc.printf("Nothing happen \r\n"); 00067 } 00068 //Gesture_LED(gesture); 00069 } 00070 00071 int main(void) 00072 { 00073 // pc.baud (115200); 00074 // pc.printf("Start Pixart Gesture demo\n\r"); 00075 00076 i2c.frequency(400000); 00077 00078 00079 bool Result = false; 00080 Pixart_Gesture *m_Gesture = new Pixart_Gesture(&i2c,100,GetGestute,Result); 00081 00082 // if(Result == true) 00083 // { 00084 // pc.printf("Initial Pixart Gesture successful\n\r"); 00085 // } 00086 // else 00087 // { 00088 // pc.printf("Initial Pixart Gesture fail\n\r"); 00089 // } 00090 // 00091 00092 while(true) 00093 ; 00094 } 00095 00096 00097 00098 00099 00100
Generated on Tue Jul 19 2022 15:31:01 by
1.7.2
