diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/OI.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/OI.java new file mode 100644 index 0000000000..16bfa8ebf4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/OI.java @@ -0,0 +1,38 @@ +package $package; + +import edu.wpi.first.wpilibj.buttons.Button; +import $package.commands.ExampleCommand; + +/** + * This class is the glue that binds the controls on the physical operator + * interface to the commands and command groups that allow control of the robot. + */ +public class OI { + //// CREATING BUTTONS + // One type of button is a joystick button which is any button on a joystick. + // You create one by telling it which joystick it's on and which button + // number it is. + // Joystick stick = new Joystick(port); + // Button button = new JoystickButton(stick, buttonNumber); + + // There are a few additional built in buttons you can use. Additionally, + // by subclassing Button you can create custom triggers and bind those to + // commands the same as any other Button. + + //// TRIGGERING COMMANDS WITH BUTTONS + // Once you have a button, it's trivial to bind it to a button in one of + // three ways: + + // Start the command when the button is pressed and let it run the command + // until it is finished as determined by it's isFinished method. + // button.whenPressed(new ExampleCommand()); + + // Run the command while the button is being held down and interrupt it once + // the button is released. + // button.whileHeld(new ExampleCommand()); + + // Start the command when the button is released and let it run the command + // until it is finished as determined by it's isFinished method. + // button.whenReleased(new ExampleCommand()); +} + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Robot.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Robot.java index c11abcc0b7..511c4ad546 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Robot.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Robot.java @@ -18,6 +18,7 @@ import $package.subsystems.ExampleSubsystem; public class Robot extends IterativeRobot { public static final ExampleSubsystem exampleSubsystem = new ExampleSubsystem(); + public static OI oi; Command autonomousCommand; @@ -26,6 +27,7 @@ public class Robot extends IterativeRobot { * used for any initialization code. */ public void robotInit() { + oi = new OI(); // instantiate the command used for the autonomous period autonomousCommand = new ExampleCommand(); } diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/RobotMap.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/RobotMap.java new file mode 100644 index 0000000000..020b2b2580 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/RobotMap.java @@ -0,0 +1,18 @@ +package $package; +/** + * The RobotMap is a mapping from the ports sensors and actuators are wired into + * to a variable name. This provides flexibility changing wiring, makes checking + * the wiring easier and significantly reduces the number of magic numbers + * floating around. + */ +public class RobotMap { + // For example to map the left and right motors, you could define the + // following variables to use with your drivetrain subsystem. + // public static final int leftMotor = 1; + // public static final int rightMotor = 2; + + // If you are using multiple modules, make sure to define both the port + // number and the module. For example you with a rangefinder: + // public static final int rangefinderPort = 1; + // public static final int rangefinderModule = 1; +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/JavaProjectType.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/JavaProjectType.java index bc8740eab6..376ad57da6 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/JavaProjectType.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/JavaProjectType.java @@ -33,6 +33,8 @@ public class JavaProjectType implements ProjectType { @Override public Map getFiles(String packageName) { Map files = super.getFiles(packageName); files.put("src/"+packageName.replace(".", "/")+"/Robot.java", "command-based/Robot.java"); + files.put("src/"+packageName.replace(".", "/")+"/RobotMap.java", "command-based/RobotMap.java"); + files.put("src/"+packageName.replace(".", "/")+"/OI.java", "command-based/OI.java"); files.put("src/"+packageName.replace(".", "/")+"/commands/ExampleCommand.java", "command-based/ExampleCommand.java"); files.put("src/"+packageName.replace(".", "/")+"/subsystems/ExampleSubsystem.java", "command-based/ExampleSubsystem.java"); return files;