Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.57 KB)

1 1846 bwasserm
#include <dragonfly_lib.h>
2
3
 #ifndef _LINEFOLLOW_H_
4
 #define _LINEFOLLOW_H_
5
6 1858 mjmckay
#define LWHITE                        0
7
#define LGREY                        1
8
#define LBLACK                         2
9 1846 bwasserm
#define CENTER                        3
10
#define NOLINE                        -42
11
#define LINELOST                -1
12
13 1858 mjmckay
#define NOBARCODE                 -2
14
#define INTERSECTION                 -25
15
#define FULL_LINE                 -26
16
17
18
19 1846 bwasserm
/*         lineFollow_init
20
        Must call before lineFollow
21
        Turns analog loop off
22
*/
23 1858 mjmckay
void lineFollow_init(void);
24 1846 bwasserm
25
/*        lineFollow
26
        Must call lineFollow first
27
        Must be called inside a loop
28
*/
29 1858 mjmckay
int lineFollow(int speed);
30 1846 bwasserm
31 1858 mjmckay
/*        turnLeft turnRight mergeLeft mergeRight
32
        Must be called inside a loop
33
        returns 0 when complete
34 1846 bwasserm
*/
35 1858 mjmckay
int turnLeft(void);
36
int turnRight(void);
37
int mergeLeft(void);
38
int mergeRight(void);
39 1846 bwasserm
40
/*        updateLine
41 1858 mjmckay
        Reads in the analog values
42 1846 bwasserm
        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 1858 mjmckay
/*        updatebarCode
55
        Reads in and processes
56
        bar code data
57
*/
58
void updateBarCode(void);
59 1846 bwasserm
60 1858 mjmckay
/*        getBarCode
61
        returns a bar code, if
62
        available, otherwise NOBARCODE
63 1846 bwasserm
*/
64 1858 mjmckay
int getBarCode(void);
65
66
/*        min max
67
        returns the minimum/maximum of two values
68
*/
69 1846 bwasserm
int min(int x, int y);
70 1858 mjmckay
int max(int x, int y);
71 1846 bwasserm
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