Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.59 KB)

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