-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoShooting.c
45 lines (38 loc) · 888 Bytes
/
AutoShooting.c
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
#define STOPPED 0
#define READY_TO_SHOOT 1
#define RECOVERY 2
#define NORMAL 3
int ShooterMode = STOPPED;
bool leftHitStable = false;
bool rightHitStable = false;
bool hipshot = false;
int ballsFiredCount = 0;
bool isShooterReady (int greencounts,int loopcounts){
if (ShooterMode == READY_TO_SHOOT)
return true;
else if (leftHitStable && rightHitStable)
return true;
else if ((greencounts >= (.75 * loopcounts)) && (loopcounts > 8))
return true;
else
return false;
}
void ballFireDetected(){
ballsFiredCount = ballsFiredCount + 1;
ShooterMode = RECOVERY;
writeDebugStreamLine("Ball Fired Detected: Ball #%d", ballsFiredCount);
}
void setIntakeSpeed(int speed){
motor[Intake] = speed;
}
task AutoIntake(){
while (true){
if ((ShooterMode == READY_TO_SHOOT) || (hipshot == true)){
setIntakeSpeed(100);
}
else{
setIntakeSpeed(0);
}
delay (50);
}
}