full mouse

Dependencies:   MMA8451Q TSI USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
aji052
Date:
Sun Oct 11 06:48:10 2015 +0000
Commit message:
full mouse

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
TSI.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r a72a8bb67eaf MMA8451Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Sun Oct 11 06:48:10 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
diff -r 000000000000 -r a72a8bb67eaf TSI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Sun Oct 11 06:48:10 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/emilmont/code/TSI/#507b1f67804b
diff -r 000000000000 -r a72a8bb67eaf USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Sun Oct 11 06:48:10 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/mbed_official/code/USBDevice/#2af474687369
diff -r 000000000000 -r a72a8bb67eaf main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Oct 11 06:48:10 2015 +0000
@@ -0,0 +1,74 @@
+#include "mbed.h"
+#include "USBMouse.h"
+#include "TSISensor.h"
+#include "MMA8451Q.h"
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+Serial pc(USBTX,USBRX);
+TSISensor tsi;
+USBMouse mouse;
+float value;
+int xaxis, yaxis, zaxis;
+int main()
+{while (1)
+{
+    value=tsi.readPercentage();
+    xaxis=(acc.getAccX()+1)*100;
+        yaxis=(acc.getAccY()+1)*100;
+        zaxis=(acc.getAccZ()+1)*100;
+        pc.printf("$%d %d %d;",xaxis,yaxis,zaxis);
+        
+    if( xaxis >=0 && xaxis <=50 )
+    mouse.move(0,-3);
+    
+    if( xaxis >=150 && xaxis <=200 )
+    mouse.move(0,3);
+    
+    if( xaxis >50 && xaxis <=80 )
+    mouse.move(0,-1);
+    
+    if( xaxis >=120 && xaxis <150 )
+    mouse.move(0,1);
+    
+    
+    
+    if( yaxis >50 && yaxis <=80 )
+    mouse.move(1,0);
+    
+    if( yaxis >=120 && yaxis <150 )
+    mouse.move(-1,0);
+    
+    if( yaxis >=0 && yaxis <=50 )
+    mouse.move(3,0);
+    
+    if( yaxis >=150 && yaxis <=200 )
+    mouse.move(-3,0);
+    
+    if( xaxis >=0 && xaxis <=80 && yaxis >=0 && yaxis <=80 )
+    mouse.move(2,-2);
+    
+    if( xaxis >=120 && xaxis <=200 && yaxis >=0 && yaxis <=80 )
+    mouse.move(2,2);
+    
+    if( xaxis >=0 && xaxis <=80 && yaxis >=120 && yaxis <=200 )
+    mouse.move(-2,-2);
+    
+    if( xaxis >=120 && xaxis <=200 && yaxis >=120 && yaxis <=200)
+    mouse.move(-2,2);
+    
+    if(value>0.5)
+    {mouse.press(MOUSE_LEFT);
+     wait(0.1);
+     mouse.release(MOUSE_LEFT);
+    }
+    
+    if(value<0.5 && value>0)
+    {mouse.press(MOUSE_RIGHT);
+     wait(0.1);
+     mouse.release(MOUSE_RIGHT);
+    }
+    else
+     mouse.move(0,0);
+    
+     }
+}
diff -r 000000000000 -r a72a8bb67eaf mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Oct 11 06:48:10 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file