Test application for Freedom KL25Z, mouse driven by accelerometer and click with TSI interface

Dependencies:   MMA8451Q TSI USBDevice mbed

Fork of Airmouse by Frederic Thierry

Revision:
1:12a34d982118
Parent:
0:a7df8e8cc00c
--- a/main.cpp	Mon Jun 24 23:23:47 2013 +0000
+++ b/main.cpp	Thu Jun 16 01:07:53 2016 +0000
@@ -1,11 +1,13 @@
 #include "mbed.h"
 #include "USBMouse.h"
+#include "USBKeyboard.h"
 #include "MMA8451Q.h"
 #include "TSISensor.h"
 
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
 
-USBMouse mouse;
+//USBMouse mouse;
+USBKeyboard tecla;
 Serial pc(USBTX, USBRX); // tx, rx
 
 int main()
@@ -20,22 +22,33 @@
         x = -10*acc.getAccY();
         y = 10*acc.getAccX();
 
-        mouse.move(x, y);
+        //mouse.move(x, y);
     
         click=tsi.readPercentage();
-        //pc.printf("%f\n",click);
-        if (click>0.70)
-            mouse.press(MOUSE_LEFT);
-            else
-            mouse.release(MOUSE_LEFT);
+        //pc.printf("%f\n",y);
+        if (y==10){
+        if (click>0.69)
+            tecla._putc(97);
+
+        if((click<0.33)&&(click>0))
+            tecla._putc(99);
             
-          if((click<0.30)&&(click>0))
+        if((click<0.69)&&(click>0.33))
+            tecla._putc(98);
+        }
+        
+        if (y==0){
+        if (click>0.69)
+            tecla._putc(100);
+
+        if((click<0.33)&&(click>0))
+            tecla._putc(102);
             
-            mouse.press(MOUSE_RIGHT);
-            else
-            mouse.release(MOUSE_RIGHT);
-            
-        wait(0.001);
+        if((click<0.69)&&(click>0.33))
+            tecla._putc(101);
+        }
+        
+        wait(0.5);
        
     }
 }
\ No newline at end of file