I was going around, and I know that people make classes/interfaces for doing the bizzare things that are used frequently on their robots.
For me is was getting DigitalInputs working, to do that, I made this class:
Code:
package com.shadowh511.mayor.inputs;
import edu.wpi.first.wpilibj.DigitalInput;
public class Switch {
private DigitalInput source;
public Switch(int channel) {
this.source = new DigitalInput(4,channel);
}
public Switch(int slot, int channel) {
this.source = new DigitalInput(slot,channel);
}
public boolean oldGet() {
return this.source.get();
}
public boolean get() {
if(!this.source.get()) {
return true;
} else {
return false;
}
}
}
what you use to call this is:
Code:
Switch ballSwitch = new Switch(4);
or
Code:
Switch ballSwitch = new Switch(4,4);
I recommend the bottom one just to be on the safe side.