|
In terms of having things run only once per button press the command based template for WPILib has a nice feature where it takes care of that for you in your OI class.
Pseudo code for OI.java
Button toggle = new JoystickButton(BUTTON-NUMBER); //put a joystick button into a var
toggle.whenPressed(new toggleConveyorCommand); //upon press run the toggle command once
Pseudo code for toggleConveyorCommand.java:
execute() { //the execute part
if(Conveyor.getInstance().isRunning()) {//if the conveyor singleton is running
Conveyor.getInstance().stop(); //stop it
} else { //if not
Conveyor.getInstance().start();// start it
}
}
|