View Single Post
  #2   Spotlight this post!  
Unread 14-02-2015, 22:01
cstelter cstelter is offline
Programming Mentor
AKA: Craig Stelter
FRC #3018 (Nordic Storm)
Team Role: Mentor
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Mankato, MN
Posts: 77
cstelter will become famous soon enough
Re: Joysticks Not Working Correctly

One problem I see is in OI:

Code:
public class OI {
    ...	
	 public JoystickButton joystickButton1;
	    public static Joystick joystick1;
	    public JoystickButton joystickButton2;
	    public static Joystick joystick2;

	    public OI() {
	        // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS

	        Joystick joystick2 = new Joystick(1);
	        
	        Button joystickButton2 = new JoystickButton(joystick2, 1);
	        joystickButton2.whileHeld(new SetDown());
	        
	        Joystick joystick1 = new Joystick(0);
The red lines are problematic. You are declaring a local joystick only within the OI constructor that hides the static field definition that getJoystick() and your calls to OI.joystick1 will retrieve.

So I suspect that the default constructor for Joystick assigns 0 and you never get joystick2 assigned to 1.

Remove the red words and I suspect it may work better.
Reply With Quote