Ghost Mouse / Mbed 2 deprecated ghost_mouse

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jennabarton
Date:
Fri Mar 31 23:40:20 2017 +0000
Parent:
6:4ade0e1a3723
Child:
8:d27efcac2dd7
Commit message:
printing A/B depending on direction of movement

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Mar 31 23:32:30 2017 +0000
+++ b/main.cpp	Fri Mar 31 23:40:20 2017 +0000
@@ -13,6 +13,12 @@
 int i;
 
 
+//previous point values
+int prevX = 1023;
+int prevY = 1023;
+
+
+
 //point variables
 int point1x = 0;
 int point1y = 0;
@@ -107,6 +113,7 @@
    
        
     
+    
     //POINT 1
     //get data
     point1x = data_buf[1];
@@ -116,6 +123,20 @@
     onex[0] = point1x + ((s & 0x30) << 4);
     oney[0] = point1y + ((s & 0xC0) << 2);
     
+    if(prevX != 1023 || prevY != 1023){
+        if(onex[0] - prevX > 5){
+            keyOut.putc(0x41);
+        } else if ((onex[0] - prevX) < -5){
+            keyOut.putc(0x42);
+            
+        }
+    }
+    
+    //update prev values
+    prevX = onex[0];
+    prevY = oney[0];
+    
+    
     //POINT 2
     //get data
     point2x = data_buf[4];
@@ -156,9 +177,10 @@
         //y coordinate
         pc.printf(" %d\t", y);  
         
-        if(x < 800 ){
-            keyOut.putc(0x41);
-        } 
+        //print A if x is less than 800
+       // if(x < 800 ){
+//            keyOut.putc(0x41);
+//        } 
     }
     
     //new line and delay
@@ -186,7 +208,7 @@
     
     
     while(1) {
-        wait(0.01);
+        wait(0.04);
         myled = 1 - myled;
         
         //get the camera data