Enter h(high), l(low), m(medium) to change the speed of cursor

Dependencies:   mbed TSI MMA8451Q USBDevice

Files at this revision

API Documentation at this revision

Comitter:
div1104
Date:
Sat Jan 23 16:57:36 2021 +0000
Commit message:
Speed of cursor

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 99a75d66305f MMA8451Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Sat Jan 23 16:57:36 2021 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
diff -r 000000000000 -r 99a75d66305f TSI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Sat Jan 23 16:57:36 2021 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/emilmont/code/TSI/#507b1f67804b
diff -r 000000000000 -r 99a75d66305f USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Sat Jan 23 16:57:36 2021 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/USBDevice/#c5e178adb138
diff -r 000000000000 -r 99a75d66305f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jan 23 16:57:36 2021 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+#define MMA8451_I2C_ADDRESS (0x1D<<1)
+#include "TSISensor.h"
+#include "USBMouse.h"
+Serial pc(USBTX,USBRX);
+MMA8451Q acc(PTE25,PTE24,MMA8451_I2C_ADDRESS);
+TSISensor tsi;
+USBMouse mouse;
+int main() 
+{
+    float x=0;
+    float y=0;
+    int s;
+    char ch;
+    float tsival;
+    pc.printf("Enter the speed for cursor as h l m:");
+    
+       
+    while(1) 
+    {
+      if(pc.readable())
+    {
+       ch=pc.getc();
+     
+    }
+     
+      switch(ch)
+        {
+        case 'l': s=2;
+        break;
+        case 'm': s=5;
+        break;
+        case 'h': s=8;
+        break;
+        default:  s=12;
+        break;
+         }
+      x=acc.getAccX();
+      y=acc.getAccY();
+      tsival = tsi.readPercentage();
+      
+      x=x*s;
+      y=y*s;
+      mouse.move(-y,x);
+      if((tsival>0.05&&tsival<0.33))
+       {
+         mouse.press(MOUSE_RIGHT);
+       } 
+      else if((tsival>0.66&&tsival<1))
+       {
+         mouse.press(MOUSE_LEFT);
+        
+        }  
+      else
+      {
+          mouse.release(MOUSE_LEFT);
+          mouse.release(MOUSE_RIGHT);
+       }   
+    }
+}
diff -r 000000000000 -r 99a75d66305f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jan 23 16:57:36 2021 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/64910690c574
\ No newline at end of file