Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / traffic_navigation / lineFollow.h @ 1846

History | View | Annotate | Download (1.26 KB)

1
#include <dragonfly_lib.h>
2

    
3
 #ifndef _LINEFOLLOW_H_
4
 #define _LINEFOLLOW_H_
5

    
6
#define CENTER                        3
7
#define NOLINE                        -42
8
#define SPEED                        170
9
#define LINELOST                -1
10

    
11
/*         lineFollow_init
12
        Must call before lineFollow
13
        Turns analog loop off
14
*/ 
15
void lineFollow_init();
16

    
17
/*        lineFollow
18
        Must call lineFollow first
19
        Must be called inside a loop
20
*/
21
int lineFollow();
22

    
23
/*        assignColor
24
        Converts an analog color to WHITE or BLACK
25
*/
26
int assignColor(int port, int analog);
27

    
28
/*        updateIR
29
        Gets the value of the nth line sensor
30
*/
31
int updateIR(int n);
32

    
33
/*        updateLine
34
        Fills the given array with WHITE
35
        or BLACK representing the line
36
*/
37
void updateLine(int* values); 
38

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

    
46
//Not implemented yet, returns ???
47
void updateBarCode();
48

    
49
/*        min
50
        returns the minimum of two values
51
*/
52
int min(int x, int y);
53

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

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

    
70
/*        lost
71
        Internal counter to detect if the line was lost
72
*/
73
int lost;
74

    
75
#endif