NXShield  v1.07
NXShield Library Reference by OpenElectrons.com
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
LineLeader.h
1 
2 // LineLeader.h
3 //
4 // This is a class for reading from LineLeader Sensor made by Mindsensors.
5 // See http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=111
6 
7 // Initial version: 2010-06-15 by Andrew Sylvester
8 // Large parts of the code is ported from the NXC library for the device,
9 // written by Deepak Patil.
10 
11 /*
12  This library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU Lesser General Public
14  License as published by the Free Software Foundation; either
15  version 2.1 of the License, or (at your option) any later version.
16 
17  This library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  Lesser General Public License for more details.
21 
22  You should have received a copy of the GNU Lesser General Public
23  License along with this library; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26 
27 
28 #ifndef LineLeader_H
29 #define LineLeader_H
30 
31 #define LineLeader_Raw_Calibrated 0x49
32 #define LineLeader_Raw_Uncalibrated 0x74
33 #define LineLeader_White_Limit 0x51
34 #define LineLeader_Black_Limit 0x59
35 #define LineLeader_White_Calibration 0x64
36 #define LineLeader_Black_Calibration 0x6C
37 
38 
39 #define LineLeader_Command 0x41
40 #define LineLeader_Steering 0x42
41 #define LineLeader_Average 0x43
42 #define LineLeader_Result 0x44
43 #define LineLeader_SetPoint 0x45
44 #define LineLeader_Kp 0x46
45 #define LineLeader_Ki 0x47
46 #define LineLeader_Kd 0x48
47 #define LineLeader_Kp_Factor 0x61
48 #define LineLeader_Ki_Factor 0x62
49 #define LineLeader_Kd_Factor 0x63
50 
51 #include "NXShieldI2C.h"
52 
56 class LineLeader : public NXShieldI2C
57 {
58 public:
60  LineLeader(uint8_t i2c_address = 0x02);
61 
63  uint8_t issueCommand(char command);
64 
66  bool calibrateWhite();
67 
69  bool calibrateBlack();
70 
72  bool sleep();
73 
75  bool wakeUp();
76 
80 
83  bool resetColorInversion();
84 
88  bool takeSnapshot();
89 
92  bool configureUS();
93 
96  bool configureEurope();
97 
100  bool configureUniversal();
101 
103  uint8_t getSetPoint();
104 
106  bool setSetPoint(uint8_t spoint);
107 
109  uint8_t getKp(uint8_t kp);
110 
112  bool setKp(uint8_t kp);
113 
115  uint8_t getKi(uint8_t ki);
116 
118  bool setKi(uint8_t ki);
119 
121  uint8_t getKd(uint8_t kd);
122 
124  bool setKd(uint8_t kd);
125 
130  uint8_t getKpFactor(uint8_t kpfact);
131 
135  bool setKpFactor(uint8_t kpfact);
136 
141  uint8_t getKiFactor(uint8_t kifact);
142 
146  bool setKiFactor(uint8_t kifact);
147 
152  uint8_t getKdFactor(uint8_t kdfact);
153 
157  bool setKdFactor(uint8_t kdfact);
158 
160  int getSteering();
161 
163  unsigned char getAverage();
164 
166  unsigned char getResult();
167 
172  uint8_t* getRawCalibrated();
173 
177  uint8_t* getRawUncalibrated();
178 
180  uint8_t* getWhiteLimit();
181 
183  uint8_t* getBlackLimit();
184 
186  uint8_t* getWhiteCalibration();
187 
189  uint8_t* getBlackCalibration();
190 
191 };
192 
193 #endif /* LineLeader_H_ */
This class implements I2C interfaces used by NXShield.
Definition: NXShieldI2C.h:32
bool invertLineColorToWhite()
Definition: LineLeader.cpp:61
uint8_t * getBlackCalibration()
Definition: LineLeader.cpp:201
bool setKp(uint8_t kp)
Definition: LineLeader.cpp:106
uint8_t * getRawUncalibrated()
Definition: LineLeader.cpp:181
uint8_t getSetPoint()
Definition: LineLeader.cpp:91
uint8_t * getWhiteCalibration()
Definition: LineLeader.cpp:196
bool takeSnapshot()
Definition: LineLeader.cpp:71
uint8_t getKd(uint8_t kd)
Definition: LineLeader.cpp:121
uint8_t * getRawCalibrated()
Definition: LineLeader.cpp:176
LineLeader(uint8_t i2c_address=0x02)
Definition: LineLeader.cpp:31
bool setKi(uint8_t ki)
Definition: LineLeader.cpp:116
bool sleep()
Definition: LineLeader.cpp:51
bool setSetPoint(uint8_t spoint)
Definition: LineLeader.cpp:96
uint8_t getKp(uint8_t kp)
Definition: LineLeader.cpp:101
bool setKpFactor(uint8_t kpfact)
Definition: LineLeader.cpp:136
unsigned char getResult()
Definition: LineLeader.cpp:171
This class interfaces with NXTLineLeader sensor attached to NXShield.
Definition: LineLeader.h:56
bool wakeUp()
Definition: LineLeader.cpp:56
bool calibrateBlack()
Definition: LineLeader.cpp:46
bool configureUS()
Definition: LineLeader.cpp:76
uint8_t getKpFactor(uint8_t kpfact)
Definition: LineLeader.cpp:131
unsigned char getAverage()
Definition: LineLeader.cpp:166
uint8_t * getBlackLimit()
Definition: LineLeader.cpp:191
bool configureEurope()
Definition: LineLeader.cpp:81
bool configureUniversal()
Definition: LineLeader.cpp:86
bool setKiFactor(uint8_t kifact)
Definition: LineLeader.cpp:146
uint8_t issueCommand(char command)
Definition: LineLeader.cpp:36
bool resetColorInversion()
Definition: LineLeader.cpp:66
bool calibrateWhite()
Definition: LineLeader.cpp:41
uint8_t * getWhiteLimit()
Definition: LineLeader.cpp:186
int getSteering()
Definition: LineLeader.cpp:161
bool setKdFactor(uint8_t kdfact)
Definition: LineLeader.cpp:156
bool setKd(uint8_t kd)
Definition: LineLeader.cpp:126
uint8_t getKiFactor(uint8_t kifact)
Definition: LineLeader.cpp:141
uint8_t getKdFactor(uint8_t kdfact)
Definition: LineLeader.cpp:151
uint8_t getKi(uint8_t ki)
Definition: LineLeader.cpp:111