-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWinch.java
More file actions
96 lines (82 loc) · 1.88 KB
/
Copy pathWinch.java
File metadata and controls
96 lines (82 loc) · 1.88 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package demoman;
import edu.wpi.first.wpilibj.*;
/*
* Team 3181 Robotics
* Project: Breakaway
* Codename: Demoman
* (The Chargin Scottsman)
* Filename: Winch.java
*/
/**
* Control the winch.
*
* @author eric
*
*/
public class Winch {
private static boolean locked = false;
// If true, we can't lock or unlock
private static boolean stateLocked = false;
private static Timer llt = new Timer();
/**
* Move up move up move up! Still need to figure out when to stop though....
*
*/
public static void lift(double speed) {
// 0 - 1023
// need channel verification
System.out.println("Lifting the winch. The requested speed is " + speed);
Hardware.winchMotor.set(speed);
}
/**
* Stop the winch.
*
*/
public static void stop() {
Hardware.winchMotor.set(0);
}
/** Is the winch locked? */
public static boolean isLocked() {
return locked;
}
/** Change the lock state, and wait half a second before allowing the state to change. */
public static void changeLockState() {
if (stateLocked) {
// Timer expired?
if (llt.get() > .5) {
llt.stop();
llt.reset();
stateLocked = false;
changeLockState();
}
}
else {
if (locked) {
locked = false;
} else {
locked = true;
}
llt.start();
}
}
public static void overrideLock()
{
locked = false;
actOnLockState();
}
public static void overrideUnlock()
{
locked = true;
actOnLockState();
}
/** Act on our current state */
public static void actOnLockState() {
// If locking, make sure it's stopped
if (locked) {
stop();
Hardware.solenoids[5].set(true);
} else {
Hardware.solenoids[5].set(false);
}
}
}