Project

General

Profile

Revision 1931

Added by Dan Jacobs about 13 years ago

fixed ??? trunk

View differences:

lineFollow.h
1 1
#include <dragonfly_lib.h>
2 2

  
3
 #ifndef _LINEFOLLOW_H_
4
 #define _LINEFOLLOW_H_
3
#ifndef _LINEFOLLOW_H_
4
#define _LINEFOLLOW_H_
5 5

  
6 6
#define LWHITE			0
7 7
#define LGREY			1
8 8
#define LBLACK	 		2
9 9
#define CENTER			3
10
#define NOLINE			-42
11 10
#define LINELOST		-1
12 11

  
13 12
#define NOBARCODE 		-2
14
#define INTERSECTION 		-25
15
#define FULL_LINE 		-26
13
#define INTERSECTION 	-25
16 14

  
15
#define NOLINE			-50
16
#define FULL_LINE 		-51
17 17

  
18

  
19
/* 	lineFollow_init
20
	Must call before lineFollow
21
	Turns analog loop off
22
*/ 
18
/**
19
 * @brief Initializes line following.
20
 * 
21
 * Must be called before line following will work.
22
 * Turns the analog loop off.
23
 */
23 24
void lineFollow_init(void);
24 25

  
25
/*	lineFollow
26
	Must call lineFollow first
27
	Must be called inside a loop
28
*/
26
/**	lineFollow
27
 *	Must call lineFollow_init first
28
 *	Must be called inside a loop
29
 */
29 30
int lineFollow(int speed);
30 31

  
31
/*	turnLeft turnRight mergeLeft mergeRight
32
	Must be called inside a loop
33
	returns 0 when complete
34
*/
32
/**	turnLeft turnRight mergeLeft mergeRight
33
 *	Must be called inside a loop
34
 *	returns 0 when complete
35
 */
35 36
int turnLeft(void);
36 37
int turnRight(void);
37 38
int mergeLeft(void);
38 39
int mergeRight(void);
39 40

  
40
/*	updateLine
41
	Reads in the analog values
42
	Fills the given array with WHITE
43
	or BLACK representing the line
44
*/
41
/**
42
 * @brief Updates the values stored in the array to white or black based on
43
 * current sensor readings.
44
 *
45
 * @param values The array of five integers to be updated. 
46
 */
45 47
void updateLine(int* values); 
46 48

  
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
*/
49
/**
50
 * @brief Returns an index of the middle of the line based on line readings.
51
 *
52
 * Two special return values are possible:
53
 *   NOLINE if none of the sensors holds a black value, and
54
 *   FULL_LINE if all of the sensors see black.
55
 *
56
 * Otherwise, returns a value from -4 (farthest left) to 4 (farthest right), with
57
 * 0 the line being centered in the middle.
58
 *
59
 * @param colors The array of 5 readings from the line sensor.  Must be either
60
 *    LWHITE or LBLACK.
61
 * @return Either a special value or an index from -4 to 4.
62
 *
63
 */
52 64
int lineLocate(int* colors);
53 65

  
54
/*	updatebarCode
55
	Reads in and processes
56
	bar code data
57
*/
66
/**	updatebarCode
67
 *	Reads in and processes
68
 *	bar code data
69
 */
58 70
void updateBarCode(void);
59 71

  
60
/*	getBarCode
61
	returns a bar code, if
62
	available, otherwise NOBARCODE
63
*/
72
/**
73
 * @brief Gets the completed value read by the barcode reader, or NOBARCODE.
74
 *
75
 * Returns a bar code if available (if at the end of a barcode) and resets the
76
 * barcodePosition to 0. Otherwise, return NOBARCODE.  *
77
 * @return The value of the barcode if a complete barcode, else NOBARCODE.
78
 */
64 79
int getBarCode(void);
65 80

  
66
/*	min max
67
	returns the minimum/maximum of two values
68
*/
81

  
82
//! A simple function to return the minimum of two integers.
69 83
int min(int x, int y);
84
//! A simple function to return the maximum of two integers.
70 85
int max(int x, int y);
71 86

  
72
/*	motorLeft
73
	Commands the left motor
74
	Cannot be used to stop
75
	0-126 are backward
76
	127-255 are forward
77
*/
87
/** @todo Alex: I hate these functions, but I'm keeping them so code will still work. But we should delete them sometime. */
88

  
89
/**	motorLeft
90
 *	Commands the left motor
91
 *	Cannot be used to stop
92
 *	0-126 are backward
93
 *	127-255 are forward
94
 */
78 95
void motorLeft(int speed);
79 96

  
80
/*	motorRight
81
	Commands the right motor
82
	Cannot be used to stop
83
	0-126 are backward
84
	127-255 are forward
85
*/
97
/**	motorRight
98
 *	Commands the right motor
99
 *	Cannot be used to stop
100
 *	0-126 are backward
101
 *	127-255 are forward
102
 */
86 103
void motorRight(int speed);
87 104

  
88
/*	lost
89
	Internal counter to detect if the line was lost
90
*/
105
/**	lost
106
 *	Internal counter to detect if the line was lost
107
 */
91 108
int lost;
92 109

  
110
int onLine(void);
111

  
93 112
#endif

Also available in: Unified diff