-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWalnutServo.java
More file actions
56 lines (51 loc) · 1.6 KB
/
Copy pathWalnutServo.java
File metadata and controls
56 lines (51 loc) · 1.6 KB
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
package com.walnuthillseagles.walnutlibrary;
import com.qualcomm.robotcore.hardware.Servo;
import java.util.ArrayList;
/**
* Created by Yan Vologzhanin on 1/4/2016.
*/
public class WalnutServo implements Drivable, Auto {
private Servo servo;
private ArrayList<ButtonEvent> buttons;
private double startPos;
private boolean isToggle;
public WalnutServo(Servo myServo, double myStartPos, boolean myToggle){
servo = myServo;
startPos = myStartPos;
buttons = new ArrayList<ButtonEvent>();
isToggle=myToggle;
//Reset Servo
stop();
}
public void addButton(String daButton, double myPos){
ButtonEvent newButton = new ButtonEvent(daButton, myPos);
buttons.add(newButton);
}
public void operate(){
ButtonEvent temp;
for(int i = 0;i<buttons.size();i++){
temp = buttons.get(i);
if(VirtualGamepad.boolValues[temp.getPos()]){
//@TODO Change method name here to make more sense
servo.setPosition(temp.getVal());
}
else if(!isToggle&&!VirtualGamepad.boolValues[temp.getPos()]){
this.stop();
}
}
}
public void stop(){
servo.setPosition(startPos);
}
//Auto Stuff
public void operate(double pos){
servo.setPosition(pos);
}
public Servo getServo(){
return servo;
}
//@TODO Figure out how to make this more useful.
public void waitForCompletion() throws InterruptedException{
return;
}
}