Revision 1910
Updating some documentation for lineFollow
lineFollow.c | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* @file lineFollow.c |
3 |
* @defgroup lineFollwing Line Following |
|
3 | 4 |
* |
4 | 5 |
* Takes care of following a line. Running this program is done by calling the |
5 | 6 |
* init() function and then the lineFollow(speed) command. However, direct use |
... | ... | |
12 | 13 |
|
13 | 14 |
#include "lineFollow.h" |
14 | 15 |
|
16 |
//! The number of bits expected in a barcode |
|
15 | 17 |
#define CODESIZE 5 |
16 | 18 |
|
17 | 19 |
int countHi = 0; |
... | ... | |
21 | 23 |
int barCodePosition=0; |
22 | 24 |
|
23 | 25 |
int turnDistance=0; |
26 |
//! Counts the number of full line readings before we determine an intersection |
|
24 | 27 |
int intersectionFilter=0; |
25 | 28 |
int disableBarCode=0; |
26 | 29 |
|
... | ... | |
54 | 57 |
//not on line |
55 | 58 |
if(position == NOLINE) |
56 | 59 |
{ |
57 |
if(lost++>20)
|
|
60 |
if(lost++ > 20)
|
|
58 | 61 |
{ |
59 | 62 |
orb2_set_color(GREEN); |
60 | 63 |
motors_off(); |
... | ... | |
63 | 66 |
} |
64 | 67 |
else if(position == FULL_LINE) |
65 | 68 |
{ |
66 |
if(intersectionFilter++>4)
|
|
69 |
if(intersectionFilter++ > 4)
|
|
67 | 70 |
{ |
68 | 71 |
orb2_set_color(RED); |
69 | 72 |
barCodePosition=0; |
... | ... | |
202 | 205 |
|
203 | 206 |
|
204 | 207 |
|
205 |
|
|
206 | 208 |
int getBarCode() |
207 | 209 |
{ |
208 | 210 |
if(barCodePosition!=CODESIZE) return NOBARCODE ; |
209 | 211 |
int temp = 0; |
210 |
int i; |
|
211 |
for(i=0; i<CODESIZE; i++) |
|
212 |
for(int i=0; i<CODESIZE; i++) |
|
212 | 213 |
temp += (barCode[i] << i); |
213 | 214 |
barCodePosition = 0; |
214 | 215 |
return temp; |
... | ... | |
240 | 241 |
return NOLINE; |
241 | 242 |
if(count==5) |
242 | 243 |
return FULL_LINE; |
243 |
return (wsum/count)-4; |
|
244 |
return (wsum/count)-4; // Subtract 4 to center the index around the center.
|
|
244 | 245 |
} |
245 | 246 |
|
246 | 247 |
|
247 | 248 |
void updateBarCode() |
248 | 249 |
{ |
250 |
//! Note: currently only uses one of the barcode sensors. |
|
249 | 251 |
|
250 |
//NOTE: currently only uses one of the barcode sensors. |
|
251 |
|
|
252 | 252 |
//maps the sensors to the analog input ports |
253 | 253 |
int ports[2] = {8,1}; |
254 | 254 |
int current[2]; |
... | ... | |
284 | 284 |
} |
285 | 285 |
|
286 | 286 |
|
287 |
//! A simple function to return the minimum of two integers. |
|
288 | 287 |
int min(int x, int y){return x>y ? y : x;} |
289 |
//! A simple function to return the maximum of two integers. |
|
290 | 288 |
int max(int x, int y){return x<y ? y : x;} |
291 | 289 |
|
292 | 290 |
void motorLeft(int speed){ |
Also available in: Unified diff