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

Files at this revision

API Documentation at this revision

Comitter:
Future_FThierry
Date:
Mon Jun 24 23:23:47 2013 +0000
Child:
1:2bdcfc75ee32
Commit message:
first pub

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Mon Jun 24 23:23:47 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Future_FThierry/code/MMA8451Q/#9e6dc5a4ca82
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Mon Jun 24 23:23:47 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/TSI/#507b1f67804b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Mon Jun 24 23:23:47 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jun 24 23:23:47 2013 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "USBMouse.h"
+#include "MMA8451Q.h"
+#include "TSISensor.h"
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+USBMouse mouse;
+Serial pc(USBTX, USBRX); // tx, rx
+
+int main()
+{
+    float click =0;
+    int16_t x = 0;
+    int16_t y = 0;
+    TSISensor tsi;
+    MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+
+    while (1) {
+        x = -10*acc.getAccY();
+        y = 10*acc.getAccX();
+
+        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);
+            
+          if((click<0.30)&&(click>0))
+            
+            mouse.press(MOUSE_RIGHT);
+            else
+            mouse.release(MOUSE_RIGHT);
+            
+        wait(0.001);
+       
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jun 24 23:23:47 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17
\ No newline at end of file