|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: CodeProblem
Quote:
As for AnnaliseDonavan, could you be more specific in your question? Also, which IDE do you use? Your code is relatively messy, so if you could show me one instance where your code does not work, you could troubleshoot through that pathway and follow example with the rest of the buttons. |
|
#2
|
|||
|
|||
|
Re: CodeProblem
I did not notice that before, thanks for pointing that out!
|
|
#3
|
|||
|
|||
|
Re: CodeProblem
As for the needing of semi colons for this set up when I place semi colons it produces an error and when I looked up the correct way to do the button control this is what I found.
And I apologist I am new to coding but no one on my team knows how to code so we are lost. For the one instance currently all I have in the implementing stage is the buttons so that is all the is and it dose not work. |
|
#4
|
||||
|
||||
|
Re: CodeProblem
Try moving this code:
Code:
Button button1 = new JoystickButton(joystick, 1), button2 = new JoystickButton(joystick, 2), button3 = new JoystickButton(joystick, 3), button4 = new JoystickButton(joystick, 4), button5 = new JoystickButton(joystick, 5), button6 = new JoystickButton(joystick, 6), button7 = new JoystickButton(joystick, 7), button8 = new JoystickButton(joystick, 8), button9 = new JoystickButton(joystick, 9), button10 = new JoystickButton(joystick, 10), button11 = new JoystickButton(joystick , 11); |
|
#5
|
|||
|
|||
|
Re: CodeProblem
This may not solve much, but I suggest moving your button code into teleopInit(), otherwise you are creating buttons in a loop during teleop.
Also, have you tested your commands without the buttons? The issue may be that your commands are not working, not the buttons. To do this in Java, you can add Code:
SmartDashboard.putData(new Command()); |
|
#6
|
|||||
|
|||||
|
Re: CodeProblem
This is one of the important reasons to follow programming style conventions - that is, make your code look like programmers expect. In this case, the usual convention for objects is that the commas are only used if they are not being set. It's also common to keep columns aligned as you go down parallel code; this is why code is traditionally displayed in a fixed-width font. The usual style conventions would look like:
Code:
Button button1 = new JoystickButton(joystick, 1); Button button2 = new JoystickButton(joystick, 2); Button button3 = new JoystickButton(joystick, 3); Button button4 = new JoystickButton(joystick, 4); Button button5 = new JoystickButton(joystick, 5); Button button6 = new JoystickButton(joystick, 6); Button button7 = new JoystickButton(joystick, 7); Button button8 = new JoystickButton(joystick, 8); Button button9 = new JoystickButton(joystick, 9); Button button10 = new JoystickButton(joystick, 10); Button button11 = new JoystickButton(joystick, 11); |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|