für holdor

Dependencies:   Servo mbed pixy

Fork of PES by Gruppe 3

Revision:
19:2f44ecffaf30
Parent:
18:ea4671f566d4
--- a/readCamera.cpp	Tue Apr 25 13:44:12 2017 +0000
+++ b/readCamera.cpp	Mon May 01 09:43:31 2017 +0000
@@ -8,6 +8,8 @@
 static int k = 0;
 static int range = 1;           // 1: fährt strahl an, 2: fährt kegel an
 static int state = 0;
+static double distance = 0;
+static int yLimit = 155;
 int j;
 uint16_t blocks;
 
@@ -29,17 +31,23 @@
                      
         
                     // soll drehen bis in stahl, fahren bis kegel, 25 pixel links rechts kegel
-                    if(xAxis < 200 && xAxis > 120  &&  yAxis > 155 && yAxis < 190 ) {              // wenn Klotz an Position zum aufnehmen
-                        state = 4;
+                    if(xAxis < 180 && xAxis > 140  &&  yAxis > 155 && yAxis < yLimit ) {              // wenn Klotz an Position zum aufnehmen
+                        state = 400;
                         range = 1;
                     } else {
                         if (range == 1){         // fährt Strahl an
                             if (xAxis < 140){
-                                state = 1;
+                                distance = ((xAxis - 160)*(-0.625))-1;
+                                state = 100 + (int) distance;
                             } else if (xAxis > 180){
-                                state = 2;
+                                distance = ((xAxis - 160)*(0.625))-1;
+                                state = 200 + (int) distance;
                             } else{   // fährt gerade
-                                state = 3;
+                                distance = (((yAxis - yLimit)/(199-yLimit))*100);
+                                state = 300 + (int) distance;
+                                if (state == 400){
+                                    state=399;
+                                }
                                 range = 2;
                             }
                         } else {                // fährt solange bis Kegelrand
@@ -63,6 +71,6 @@
         }
         //printf("%d\n\r",state);
         //printf("%d, %d\n\r", xAxis, yAxis);
-        return state;
+        return (double) state;
     }
 }
\ No newline at end of file