View Single Post
  #5   Spotlight this post!  
Unread 02-06-2012, 04:30
linuxboy linuxboy is offline
Registered User
AKA: Oliver Graff
FRC #3780
Team Role: Alumni
 
Join Date: Nov 2010
Rookie Year: 2009
Location: MI, USA
Posts: 217
linuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud of
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
}
}
Reply With Quote