This application is Gesture Keyboard, you can use gesture to control the media player. This app is made with SeeedStudio Arch and PAJ7620U2 gesture sensor.

Dependencies:   Pixart_Gesture USBDevice mbed

Fork of PAJ7620_Gesture by PixArt Imaging

Committer:
Kevin_Lee
Date:
Mon Mar 20 08:24:57 2017 +0000
Revision:
2:202734861217
Parent:
0:be97d9a1d460
This is a Gesture Keyboard, you can use gesture to control the media player. Made with seeedstudio Arch and PAJ7620U2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pixus_mbed 0:be97d9a1d460 1 /* mbed Microcontroller Library
pixus_mbed 0:be97d9a1d460 2 * Copyright (c) 2006-2013 ARM Limited
Kevin_Lee 2:202734861217 3 * This is gesture keyboard demo by Kevin Lee
pixus_mbed 0:be97d9a1d460 4 */
pixus_mbed 0:be97d9a1d460 5
pixus_mbed 0:be97d9a1d460 6 #include "mbed.h"
pixus_mbed 0:be97d9a1d460 7 #include "Gesture.h"
Kevin_Lee 2:202734861217 8 #include "USBKeyboard.h"
Kevin_Lee 2:202734861217 9
Kevin_Lee 2:202734861217 10 // #ifdef DEBUG
Kevin_Lee 2:202734861217 11 // #include "USBSerial.h" // To use USB virtual serial, a driver is needed, check http://mbed.org/handbook/USBSerial
Kevin_Lee 2:202734861217 12 // #define LOG(args...) pc.printf(args)
Kevin_Lee 2:202734861217 13 //#include "USBSerial.h"
Kevin_Lee 2:202734861217 14
Kevin_Lee 2:202734861217 15 //USBSerial pc;
Kevin_Lee 2:202734861217 16 //Serial pc(USBTX, USBRX);
Kevin_Lee 2:202734861217 17 USBKeyboard keyboard;
Kevin_Lee 2:202734861217 18 I2C i2c(P0_5, P0_4);
pixus_mbed 0:be97d9a1d460 19 Ticker ticker;
pixus_mbed 0:be97d9a1d460 20
pixus_mbed 0:be97d9a1d460 21 #define dly 100 //LED delay
pixus_mbed 0:be97d9a1d460 22
pixus_mbed 0:be97d9a1d460 23 void Gesture_LED(PIXART_GESTURE_TYPE gesture);
pixus_mbed 0:be97d9a1d460 24
pixus_mbed 0:be97d9a1d460 25 void GetGestute(PIXART_GESTURE_TYPE gesture)
pixus_mbed 0:be97d9a1d460 26 {
pixus_mbed 0:be97d9a1d460 27 //UP,DOWN,LEFT,RIGHT,PUSH,POLL,CLOCKWISE,COUNTER_CLOCKWISE,WAVE};
pixus_mbed 0:be97d9a1d460 28 switch (gesture)
pixus_mbed 0:be97d9a1d460 29 {
pixus_mbed 0:be97d9a1d460 30 case UP:
Kevin_Lee 2:202734861217 31 // pc.printf("UP \r\n");
Kevin_Lee 2:202734861217 32 keyboard.mediaControl(KEY_VOLUME_UP);
pixus_mbed 0:be97d9a1d460 33 break;
pixus_mbed 0:be97d9a1d460 34 case DOWN:
Kevin_Lee 2:202734861217 35 // pc.printf("DOWN \r\n");
Kevin_Lee 2:202734861217 36 keyboard.mediaControl(KEY_VOLUME_DOWN);
pixus_mbed 0:be97d9a1d460 37 break;
pixus_mbed 0:be97d9a1d460 38 case LEFT:
Kevin_Lee 2:202734861217 39 keyboard.mediaControl(KEY_PREVIOUS_TRACK);
Kevin_Lee 2:202734861217 40 // pc.printf("LEFT \r\n");
pixus_mbed 0:be97d9a1d460 41 break;
pixus_mbed 0:be97d9a1d460 42 case RIGHT:
Kevin_Lee 2:202734861217 43 keyboard.mediaControl(KEY_NEXT_TRACK);
Kevin_Lee 2:202734861217 44 // pc.printf("RIGHT \r\n");
pixus_mbed 0:be97d9a1d460 45 break;
pixus_mbed 0:be97d9a1d460 46 case PUSH:
Kevin_Lee 2:202734861217 47 keyboard.mediaControl(KEY_MUTE);
Kevin_Lee 2:202734861217 48 // pc.printf("PUSH \r\n");
Kevin_Lee 2:202734861217 49
pixus_mbed 0:be97d9a1d460 50 break;
pixus_mbed 0:be97d9a1d460 51 case POLL:
Kevin_Lee 2:202734861217 52 keyboard.mediaControl(KEY_MUTE);
pixus_mbed 0:be97d9a1d460 53 break;
pixus_mbed 0:be97d9a1d460 54 case CLOCKWISE:
Kevin_Lee 2:202734861217 55 keyboard.mediaControl(KEY_PLAY_PAUSE);
Kevin_Lee 2:202734861217 56 // pc.printf("CLOCKWISE \r\n");
pixus_mbed 0:be97d9a1d460 57 break;
pixus_mbed 0:be97d9a1d460 58 case COUNTER_CLOCKWISE:
Kevin_Lee 2:202734861217 59 keyboard.mediaControl(KEY_STOP);
Kevin_Lee 2:202734861217 60 // pc.printf("COUNTER_CLOCKWISE \r\n");
pixus_mbed 0:be97d9a1d460 61 break;
pixus_mbed 0:be97d9a1d460 62 case WAVE:
Kevin_Lee 2:202734861217 63 // pc.printf("WAVE \r\n");
pixus_mbed 0:be97d9a1d460 64 break;
pixus_mbed 0:be97d9a1d460 65 default:
Kevin_Lee 2:202734861217 66 // pc.printf("Nothing happen \r\n");
pixus_mbed 0:be97d9a1d460 67 }
Kevin_Lee 2:202734861217 68 //Gesture_LED(gesture);
pixus_mbed 0:be97d9a1d460 69 }
pixus_mbed 0:be97d9a1d460 70
pixus_mbed 0:be97d9a1d460 71 int main(void)
pixus_mbed 0:be97d9a1d460 72 {
Kevin_Lee 2:202734861217 73 // pc.baud (115200);
Kevin_Lee 2:202734861217 74 // pc.printf("Start Pixart Gesture demo\n\r");
pixus_mbed 0:be97d9a1d460 75
pixus_mbed 0:be97d9a1d460 76 i2c.frequency(400000);
pixus_mbed 0:be97d9a1d460 77
pixus_mbed 0:be97d9a1d460 78
pixus_mbed 0:be97d9a1d460 79 bool Result = false;
pixus_mbed 0:be97d9a1d460 80 Pixart_Gesture *m_Gesture = new Pixart_Gesture(&i2c,100,GetGestute,Result);
pixus_mbed 0:be97d9a1d460 81
Kevin_Lee 2:202734861217 82 // if(Result == true)
Kevin_Lee 2:202734861217 83 // {
Kevin_Lee 2:202734861217 84 // pc.printf("Initial Pixart Gesture successful\n\r");
Kevin_Lee 2:202734861217 85 // }
Kevin_Lee 2:202734861217 86 // else
Kevin_Lee 2:202734861217 87 // {
Kevin_Lee 2:202734861217 88 // pc.printf("Initial Pixart Gesture fail\n\r");
Kevin_Lee 2:202734861217 89 // }
Kevin_Lee 2:202734861217 90 //
pixus_mbed 0:be97d9a1d460 91
pixus_mbed 0:be97d9a1d460 92 while(true)
pixus_mbed 0:be97d9a1d460 93 ;
pixus_mbed 0:be97d9a1d460 94 }
pixus_mbed 0:be97d9a1d460 95
pixus_mbed 0:be97d9a1d460 96
pixus_mbed 0:be97d9a1d460 97
pixus_mbed 0:be97d9a1d460 98
pixus_mbed 0:be97d9a1d460 99
pixus_mbed 0:be97d9a1d460 100