Statistics
| Revision:

root / trunk / code / projects / linefollowing / lineFollow.h @ 1845

History | View | Annotate | Download (1.31 KB)

1
#include <dragonfly_lib.h>
2

    
3
 #ifndef _LINEFOLLOW_H_
4
 #define _LINEFOLLOW_H_
5

    
6
#define WHITE                        0
7
#define GREY                        1
8
#define BLACK                         2
9
#define CENTER                        3
10
#define NOLINE                        -42
11
#define SPEED                        170
12
#define LINELOST                -1
13

    
14
/*         lineFollow_init
15
        Must call before lineFollow
16
        Turns analog loop off
17
*/ 
18
void lineFollow_init();
19

    
20
/*        lineFollow
21
        Must call lineFollow first
22
        Must be called inside a loop
23
*/
24
int lineFollow();
25

    
26
/*        assignColor
27
        Converts an analog color to WHITE or BLACK
28
*/
29
int assignColor(int port, int analog);
30

    
31
/*        updateIR
32
        Gets the value of the nth line sensor
33
*/
34
int updateIR(int n);
35

    
36
/*        updateLine
37
        Fills the given array with WHITE
38
        or BLACK representing the line
39
*/
40
void updateLine(int* values); 
41

    
42
/*        lineLocate
43
        Finds the location of the line
44
        Outputs positive for right side
45
        Negative for left, or NOLINE if a line is not found
46
*/
47
int lineLocate(int* colors);
48

    
49
//Not implemented yet, returns ???
50
void updateBarCode();
51

    
52
/*        min
53
        returns the minimum of two values
54
*/
55
int min(int x, int y);
56

    
57
/*        motorLeft
58
        Commands the left motor
59
        Cannot be used to stop
60
        0-126 are backward
61
        127-255 are forward
62
*/
63
void motorLeft(int speed);
64

    
65
/*        motorRight
66
        Commands the right motor
67
        Cannot be used to stop
68
        0-126 are backward
69
        127-255 are forward
70
*/
71
void motorRight(int speed);
72

    
73
/*        lost
74
        Internal counter to detect if the line was lost
75
*/
76
int lost;
77

    
78
#endif