Repository navigation
Expand file tree
/
Copy pathLineShield.h
More file actions
81 lines (56 loc) · 2.38 KB
/
Copy pathLineShield.h
File metadata and controls
81 lines (56 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*Written by Jacob Smith and Matthew Millendorf for Brandeis Robotics club
Provides wrapper functions for the Zumo32U4LineShieldShieldSensors class
April 4 2018
*/
//set up the LineShieldShield header file
#ifndef LineShield_h
#define LineShield_h
//only compile this class if the board is correct
#ifdef ARDUINO_AVR_UNO
#define NUM_SENSORS 6
//include all the libraries necessary to make this one work
#include <Arduino.h>
#include <Wire.h>
#include <ZumoReflectanceSensorArray.h>
class LineShield {
private:
ZumoReflectanceSensorArray lineReader;
//an array to store the LineShieldShield sensor readings
//declared at an arbitrary size and then actually used with numSensors
unsigned int reflections[10];
//an array to store the number of sensors for convenineve
int numSensors;
//finds the minimum and maximums reflections from last reading
void findMinMax();
//the minimum and maximum brightness values in one read
int min;
int max;
int minThresh;
int maxThresh;
int lastRegion;
public:
//creates a new LineShieldShield object with defualt sensor reading
LineShield();
//creates a new LineShieldShield object with provided thresholds
LineShield(int minThresh, int maxThresh);
//initializes all the variables that this class needs, like a constructor
void initializeVars(int minThresh, int maxThresh);
//returns the minimum sensor value from alst reading
int getMin();
//returns the maximum sensor value from alst reading
int getMax();
//prints all of the sensor readings to the lcd
void printAllSensors();
//modify an array of line sensor values
void getReflections(unsigned int clientArray []);
//returns whether robot is on gray region
bool isOnWhite();
//return the region the robot is on, gray, white or black
int getRegion();
};
#elif defined (DONT_NEED_LINE)
#warning : May lead to "error: 'LineShield' does not name a type" ; Program to Board Incompatibility ; One of the libraries you are using will not work with your board ; For more information, go to cse230.artifice.cc/lecture/splitting-code.html
#else
#error : Program to Board Incompatibility ; One of the libraries you are using will not work with your board ; Quick fix: add <#define DONT_NEED_LINE> to top ; For more information, go to cse230.artifice.cc/lecture/splitting-code.html
#endif
#endif