added distance function, added turnDir function, started function that completes left turn
Fork of TFC-TEST_TXSTATE_TEAM6v2 by
Diff: main.cpp
- Revision:
- 3:04f91137660a
- Parent:
- 2:729063e39fb3
- Child:
- 4:61edb416e860
diff -r 729063e39fb3 -r 04f91137660a main.cpp --- a/main.cpp Sat Apr 04 21:55:09 2015 +0000 +++ b/main.cpp Sat Apr 04 22:21:19 2015 +0000 @@ -35,13 +35,13 @@ // finds and sets by reference the values of the left and right bounds void Bounds(int &, int &, int); - +int distance(int &, int &, int); int main() { uint32_t i,t,time = 0; - int a = 200, b = 200; + int a = 200, b = 200, d; int data[128]; @@ -64,11 +64,19 @@ switch((TFC_GetDIP_Switch()>>1)&0x03) { default: - case 0 : - - TFC_HBRIDGE_ENABLE; - TFC_SetMotorPWM(.6,.6); - + case 0 ://initilazation case + if(TFC_Ticker[0]>50 && TFC_LineScanImageReady>0) + { + TFC_Ticker[0] = 0; + TFC_LineScanImageReady=0; + if(TFC_PUSH_BUTTON_0_PRESSED) + { + black = FindBlack(); + d=distance(a,b,black); + } + } + TFC_SetServo(0,0.0); + break; case 1: @@ -287,4 +295,10 @@ { return low2; } -} \ No newline at end of file +} +int distance(int &a, int &b, int black) +{ + bounds(a,b,black); + return (a-b); +} + \ No newline at end of file