![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
für holdor
Fork of PES by
Diff: readCamera.cpp
- Revision:
- 21:d05dee0d1a7d
- Parent:
- 15:7e9ecc4d7217
- Child:
- 22:ffd36f07c046
--- a/readCamera.cpp Mon May 01 09:42:51 2017 +0000 +++ b/readCamera.cpp Mon May 01 09:47:45 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 < 185 && xAxis > 135 && 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 < 155){ - state = 1; - } else if (xAxis > 165){ - state = 2; + if (xAxis < 140){ + distance = ((xAxis - 160)*(-0.625))-1; + state = 100 + (int) distance; + } else if (xAxis > 180){ + 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