-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMyDefs.h
69 lines (46 loc) · 1.12 KB
/
MyDefs.h
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
#define ULTRASONIC 1
#define EYES 1
#define LIGHT 2
#define SOUND 3
#define MIC 3
#define TOUCH 4
#define None 0
int SensorTypes[]={0,0,0,0};
inline int SensorVal(int s_) {
s_=s_-1;
int t_ = SensorTypes[s_];
if (t_==None) {
return -1;
} else if (t_==ULTRASONIC) {
Wait(100);
return SensorUS(s_);
} else {
return Sensor(s_);
}
}
void DefineSensors(int s1,int s2,int s3,int s4) {
int sa[];
int i;
ArrayInit(sa,0,4);
sa[0]=s1;
sa[1]=s2;
sa[2]=s3;
sa[3]=s4;
for (i=0; i<4; i++) {
if (sa[i]==None) {
SensorTypes[i]=None;
} else if (sa[i]==ULTRASONIC) {
SetSensorLowspeed(i);
SensorTypes[i]=ULTRASONIC;
} else if (sa[i]==LIGHT) {
SetSensorLight(i);
SensorTypes[i]=LIGHT;
} else if (sa[i]==SOUND) {
SetSensorSound(i);
SensorTypes[i]=SOUND;
} else if (sa[i]==TOUCH) {
SetSensor(i,SENSOR_TOUCH);
SensorTypes[i]=TOUCH;
}
}
}