root / trunk / code / projects / linefollowing / lineFollow.h @ 1854
History | View | Annotate | Download (1.57 KB)
1 |
#include <dragonfly_lib.h> |
---|---|
2 |
|
3 |
#ifndef _LINEFOLLOW_H_
|
4 |
#define _LINEFOLLOW_H_
|
5 |
|
6 |
#define LWHITE 0 |
7 |
#define LGREY 1 |
8 |
#define LBLACK 2 |
9 |
#define CENTER 3 |
10 |
#define NOLINE -42 |
11 |
#define LINELOST -1 |
12 |
|
13 |
#define NOBARCODE -2 |
14 |
#define INTERSECTION -25 |
15 |
#define FULL_LINE -26 |
16 |
|
17 |
|
18 |
|
19 |
/* lineFollow_init
|
20 |
Must call before lineFollow
|
21 |
Turns analog loop off
|
22 |
*/
|
23 |
void lineFollow_init(void); |
24 |
|
25 |
/* lineFollow
|
26 |
Must call lineFollow first
|
27 |
Must be called inside a loop
|
28 |
*/
|
29 |
int lineFollow(int speed); |
30 |
|
31 |
/* turnLeft turnRight mergeLeft mergeRight
|
32 |
Must be called inside a loop
|
33 |
returns 0 when complete
|
34 |
*/
|
35 |
int turnLeft(void); |
36 |
int turnRight(void); |
37 |
int mergeLeft(void); |
38 |
int mergeRight(void); |
39 |
|
40 |
/* updateLine
|
41 |
Reads in the analog values
|
42 |
Fills the given array with WHITE
|
43 |
or BLACK representing the line
|
44 |
*/
|
45 |
void updateLine(int* values); |
46 |
|
47 |
/* lineLocate
|
48 |
Finds the location of the line
|
49 |
Outputs positive for right side
|
50 |
Negative for left, or NOLINE if a line is not found
|
51 |
*/
|
52 |
int lineLocate(int* colors); |
53 |
|
54 |
/* updatebarCode
|
55 |
Reads in and processes
|
56 |
bar code data
|
57 |
*/
|
58 |
void updateBarCode(void); |
59 |
|
60 |
/* getBarCode
|
61 |
returns a bar code, if
|
62 |
available, otherwise NOBARCODE
|
63 |
*/
|
64 |
int getBarCode(void); |
65 |
|
66 |
/* min max
|
67 |
returns the minimum/maximum of two values
|
68 |
*/
|
69 |
int min(int x, int y); |
70 |
int max(int x, int y); |
71 |
|
72 |
/* motorLeft
|
73 |
Commands the left motor
|
74 |
Cannot be used to stop
|
75 |
0-126 are backward
|
76 |
127-255 are forward
|
77 |
*/
|
78 |
void motorLeft(int speed); |
79 |
|
80 |
/* motorRight
|
81 |
Commands the right motor
|
82 |
Cannot be used to stop
|
83 |
0-126 are backward
|
84 |
127-255 are forward
|
85 |
*/
|
86 |
void motorRight(int speed); |
87 |
|
88 |
/* lost
|
89 |
Internal counter to detect if the line was lost
|
90 |
*/
|
91 |
int lost;
|
92 |
|
93 |
#endif
|