Emulating a mouse

Dependencies:   MMA7660 USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
cohenr
Date:
Thu Mar 24 17:19:03 2016 +0000
Commit message:
Emulating a mouse.

Changed in this revision

MMA7660.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/MMA7660.lib	Thu Mar 24 17:19:03 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MMA7660/#36a163511e34
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Thu Mar 24 17:19:03 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/sparkfun/code/USBDevice/#2af474687369
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Mar 24 17:19:03 2016 +0000
@@ -0,0 +1,40 @@
+// USB Device demo - control mouse pointer with buttons
+
+#include "mbed.h"
+#include "USBMouse.h"
+#include "MMA7660.h"
+ 
+MMA7660 MMA(p28, p27);
+
+
+// USB Mouse object
+USBMouse mouse;
+
+DigitalOut myled(LED1);
+
+int main() {
+    
+    if (MMA.testConnection())myled = 1;
+    int x = 0;
+    int y = 0;
+
+
+   while (1) {
+
+
+        // Move mouse
+        if (MMA.x()>0.3) x = 1;
+        else if (MMA.x()<-0.3) x = -1;
+        else x = 0;
+        
+        if (MMA.y()>0.3) y = 1;
+        else if (MMA.y()<-0.3) y = -1;
+        else y = 0;
+        
+        
+        mouse.move(x, y);
+
+        // Wait for next cycle
+        wait(0.001);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Mar 24 17:19:03 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file