Karkhana Makerspace / Mbed 2 deprecated USBMouse

Dependencies:   MMA8451Q TSI USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
mrbhatter
Date:
Thu Nov 30 11:06:46 2017 +0000
Commit message:
Check USB Mouse Code

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
TSIslider.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
code.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	Thu Nov 30 11:06:46 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSIslider.lib	Thu Nov 30 11:06:46 2017 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/mbed_official/code/TSI/#1a60ef257879
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Thu Nov 30 11:06:46 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#53949e6131f6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/code.cpp	Thu Nov 30 11:06:46 2017 +0000
@@ -0,0 +1,65 @@
+/*Air mouse using USB HID with Sensitivity adjustment.
+4 values of sensitivity and option is taken from user through serial.*/
+
+#include "mbed.h"
+#include "USBMouse.h"
+#include "MMA8451Q.h"
+#include "TSISensor.h"
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); 
+Serial pc(USBTX, USBRX); // tx, rx
+TSISensor tsi;
+USBMouse mouse;
+
+int main()
+{
+    int16_t x = 0;
+    int16_t y = 0;
+    int s=10;
+    char c='b';
+    pc.printf("Enter level of sensitivity (a-d) : "); 
+        
+    while(1)
+    {
+        if (pc.readable())
+        {
+            c = pc.getc();
+    
+            switch(c)
+            {
+                case 'a': s = 20; break;
+                case 'b': s = 40; break;
+                case 'c': s = 80; break;
+                case 'd': s = 100; break;
+                default: s = 10; break;
+            }
+        }
+        
+        x = -s*(acc.getAccX());   
+        y = s*acc.getAccY();
+        
+        mouse.move(x,y);
+        
+        //left click
+        if (tsi.readPercentage() > 0.7)
+        {
+            mouse.press(MOUSE_LEFT);
+        }
+        else
+        {
+            mouse.release(MOUSE_LEFT);
+        }
+        
+        //right click
+        if (tsi.readPercentage() < 0.3 && tsi.readPercentage() > 0)
+        {
+            mouse.press(MOUSE_RIGHT);
+        }
+        else
+        {
+            mouse.release(MOUSE_RIGHT);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 30 11:06:46 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600
\ No newline at end of file