View Single Post
  #2   Spotlight this post!  
Unread 08-02-2014, 17:56
Joey1939's Avatar
Joey1939 Joey1939 is offline
Registered User
AKA: Joey Holliday
FRC #1939 (Kuhnigits)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Kansas City, Missouri
Posts: 142
Joey1939 has a spectacular aura aboutJoey1939 has a spectacular aura aboutJoey1939 has a spectacular aura about
Re: Cannot turn on compressor programatically via Spike Relay

You want this command to always run on the compressor so that it will always have full pressure and so that it will automatically shut off at the right time. To do this you need to set your UpdatePressure command as the default command for the compressor.

Here is an example from my team's code:

Compressor Subsystem
Code:
public class Compressor1 extends Subsystem {

    Compressor compressor = RobotMap.compressor1compressor;

    public void initDefaultCommand() {
        setDefaultCommand(new CompressorCommand());
    }
}
CompressorCommand
Code:
public class  CompressorCommand extends Command {
    Compressor compressor;
    
    public CompressorCommand() {
        requires(Robot.compressor1);
        compressor = RobotMap.compressor1compressor;
    }

    protected void execute() {
        
        if(!compressor.getPressureSwitchValue()){
            //Compressor NOT Full
            if(!compressor.enabled()){
                compressor.start();
            }
        }else{
            //Compressor Full
            compressor.stop();
        }
    }

    protected boolean isFinished() {
        return false;
    }

}