-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCameraSwitch.java
More file actions
82 lines (63 loc) · 2.57 KB
/
CameraSwitch.java
File metadata and controls
82 lines (63 loc) · 2.57 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
/*************************************
* @author Chris Lane | FRC 2791 | 2020
*
* API for a multiplexer camera switch.
*
* The switch should plug into the relay
* port on the RoboRIO given in the
* constructor. Each relay value
* corresponds to a pin on the port being
* driven hi or lo (1/0).
*
* This API essentially utilizes the
* relay port as two DI/O ports right
* next to each other
* kforward = pin1 high/pin 2 low,
* kReverse = pin 1 low/pin 2 high,
* kON = pin 1 high/pin2 high,
* kOff = pin 1 low/pin 2 low.
*
**************************************/
package edu.wpi.first.wpilibj;
import edu.wpi.first.wpilibj.RelayPortDevice;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Relay.Value;
public class CameraSwitch implements RelayPortDevice{
public Relay camrelay;
public CameraSwitch(int port){
camrelay = new Relay(port);
}//Constructor for a CameraSwitch on a single relay port
public void select(String camSelected){
/* enter the constant strings for the switch into this method to select cameras
constants for cameras are- "kcamera(camera#)" (these can be changed in the switch statment)
This switch has four possible ports. */
switch (camSelected) {
case "kcamera1":
camrelay.set(Value.kForward);
break;
case "kcamera2" :
camrelay.set(Value.kReverse);
break;
case "kcamera3" :
camrelay.set(Value.kOn);
case "kcamera4" :
camrelay.set(Value.kOff);
break;
default:
camrelay.set(Value.kForward);
System.err.print("Camera not properly selected, setting to case 1,Camera1");
break;
}//This switch statement is what actually writes to the relay port
}//Use this method to select the desired camera to connect to the RoboRIO
public void rawSetRelay(Relay.Value kvalue){
camrelay.set(kvalue);
}//Use this method to set the relay port to a regular relay value
public void setDirection(Relay.Direction direction){
camrelay.setDirection(direction);
}//Use this method to set valid directions for the local relay used in this class
public void setLocalRelay(Relay.Value klocalValue) {
//unused function
System.err.println("setLocalRelay(Relay.Value klocalValue); method not utilized in CameraSwitch.java");
}//DO NOT USE THIS METHOD
}
//end of file-----------------------------------------------------------------------