-
Notifications
You must be signed in to change notification settings - Fork 0
/
TroughGate.java
50 lines (37 loc) · 1.2 KB
/
TroughGate.java
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
package org.firstinspires.ftc.teamcode.Subsystems;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.Servo;
/**
* Created by John Paul Ashour on 11/15/2016.
*/
public class TroughGate {
Servo troughGateServo;
public boolean isOpen = false;
private enum troughGateServoEnum {Open, Close}
troughGateServoEnum troughServoState = troughGateServoEnum.Close;
public TroughGate(String troughGateServo, HardwareMap hardwareMap) {
this.troughGateServo = hardwareMap.servo.get(troughGateServo);
this.closeGate();
}
public void closeGate() {
troughGateServo.setPosition(0.1);
troughServoState = troughGateServoEnum.Close;
isOpen = false;
}
public void openGate() {
troughGateServo.setPosition(0.6);
troughServoState = troughGateServoEnum.Open;
isOpen = true;
}
@Override
public String toString() {
switch (troughServoState) {
case Open:
return "Gate Open";
case Close:
return "Gate Closed";
default:
return "unknown";
}
}
}