Check the javadocs (they can be found under your home directory at sunspotfrcsdk/doc/javadoc/index.html) for the Compressor class. I'm pretty sure the constructor expects the two parameters to be the "pressure switch digital input channel" followed by the "spike relay channel". I think you have them reversed in your code. Try:
Code:
Compressor mainCompressor = new Compressor(3, 7); // DIO, Relay
Also, once you start the Compressor object, you should not manipulate the spike by hand. The while loop you show in your teleop code continually attempts to turn the compressor on. I would recommend that your remove the spike entirely from your class (comment it out for now). I suspect allocating it will cause a stack trace once you change the order of the parameters to the compressor (the WPI library won't typically let a Relay be constructed more than once with the same channel ID).
You might also want to put the state of the pressure switch out to the dashboard periodically so you can confirm that it is working:
Code:
public void operatorControl() {
System.out.println("Telop Activated:");
mainCompressor.start();
while (isOperatorControl()) {
// Add your code
// Periodically update dashboard values
updateDashboard();
// Optional short sleep so main loop is not going full out
Timer.delay(.01)
}
}
// Time of last dashboard update
private double _LastUpdate = 0;
public void updateDashboard() {
double now = Timer.getFPGATimestamp();
// Don't need to update the dashboard values more than 5 times a second
if ((now - _LastUpdate) >= 0.2) {
SmartDashboard.putBoolean("Full Pressure", compressorMain.getPressureSwitchValue());
// Add other smart dashboard things to monitor here
}
}
Hope that helps,
Paul