TCRT5000.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00034
00035
00036
00037
00038
00039
00040 #ifndef __TCRT5000_H__
00041 #define __TCRT5000_H__
00042
00043 #ifdef MIP_HOST_APPLE
00044 #include <applePatch.h>
00045 #endif
00046
00047 #include <korebot/korebot.h>
00048
00049 #include <baselib.h>
00050 #include <RangeSens.h>
00051
00052
00053 #define TCRT5000_DEBUG 1
00054 #define TCRT5000_RAW_DEBUG 1
00055
00056 using namespace std;
00057
00058 namespace MipResources{
00059
00061
00062
00068 class TCRT5000Par : public RangeSensPar{
00069 static const int _blackValue = 4000;
00070 static const int _whiteValue = 1300;
00071
00072 public:
00074 TCRT5000Par(){
00075 setLinRangeMax(_blackValue);
00076 setLinRangeMin(_whiteValue);
00077 }
00078
00080 ~TCRT5000Par(){
00081 }
00082
00083 };
00084
00085
00089 class TCRT5000 : public RangeSens{
00090 private:
00091 int in, j;
00092 bool _val;
00093 char Buffer[1000];
00094 static const ResourcePlate _plate = RS_TCRT_RES;
00095
00096 protected:
00097
00098
00099
00100 knet_dev_t* dsPic;
00101 TCRT5000Par *_tcrtPar;
00102
00103 public:
00105 ResourcePlate getPlate() const{
00106 return _plate;
00107 }
00108
00110 TCRT5000(int argc, const char* argv[]):RangeSens(argc, argv){
00111 _tcrtPar = new TCRT5000Par();
00112 _par = _tcrtPar;
00113
00114 in = 0;
00115 if(TCRT5000_DEBUG) cout << "...open dsPic " << endl;
00116 dsPic = knet_open( "Khepera3:dsPic" , KNET_BUS_I2C , 0 , NULL );
00117 if(TCRT5000_DEBUG) cout << "dsPic = " << dsPic << endl;
00118 if(TCRT5000_DEBUG) cout << "TCRT5000: Infrared sensors initialized." << endl;
00119 }
00120
00122 ~TCRT5000(){
00123 delete _tcrtPar;
00124 };
00125
00127 Scan _singleScan();
00128
00132 void _startScan(unsigned int num){
00133 cout << "TCRT5000-Warning: Continuous scanning not implemented yet." << endl;
00134 }
00135
00138 void _stopScan(){
00139 cout << "TCRT5000-Warning: Continuous scanning not implemented yet." << endl;
00140 }
00141 };
00142
00143
00144
00145 };
00146
00147
00148
00149 #endif
00150
00151