Go to Post A problematic dynamic and culture becomes apparent when failure persists for such a duration and reoccurs so frequently that students begin to accept it as the norm, and never learn the proper way to do things. - sanddrag [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-02-2013, 18:09
wickzam wickzam is offline
Registered User
FRC #4591
 
Join Date: Feb 2013
Location: Canada
Posts: 2
wickzam is an unknown quantity at this point
Re: Help programming joystick buttons

Quote:
Originally Posted by Joe Ross View Post
You can use the getRawButton method of the joystick class to get whether a button is being pressed or not.
We tried to use getRawButton in our code but every time we use it there is a problem.
if you could show us an example of a code using getRawButton that would be very helpful.
Reply With Quote
  #2   Spotlight this post!  
Unread 07-02-2013, 18:32
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Help programming joystick buttons

Quote:
Originally Posted by wickzam View Post
We tried to use getRawButton in our code but every time we use it there is a problem.
if you could show us an example of a code using getRawButton that would be very helpful.
i dont get it. whats your problem

Joystick j = new Joystick(1);
JoystickButton a = new JoystickButton(j,1);
a.whileHeld(new YourCommand());

in command based or

Joystick j = new Joystick(1)
if(j.getRawButton(1)){
do stuff
}

in iterative. both will run when A is pressed
Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2013, 18:38
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Help programming joystick buttons

Quote:
Originally Posted by wickzam View Post
We tried to use getRawButton in our code but every time we use it there is a problem.
What kind of problem?

Here is an example of using getRawButton to switch between tank drive and arcade drive when the trigger (button one) on the left joystick is pressed.

Code:
    public void operatorControl() {
        chassis.setSafetyEnabled(true);
        
        if (leftStick.getRawButton(1))
        {
            chassis.tankDrive(leftStick, rightStick);
            Timer.delay(0.01);
        }
        else 
        {
            chassis.arcadeDrive(leftStick);
        }
    }
Also, in your original code, your autonomous code won't run because autonomous is misspelled.
Reply With Quote
  #4   Spotlight this post!  
Unread 11-02-2013, 02:06
arithehun arithehun is offline
Registered User
AKA: Ari Falkner
FRC #3024
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Ashland, Oregon
Posts: 27
arithehun is an unknown quantity at this point
Re: Help programming joystick buttons

Have you heard about command based programming? It is a lot cleaner and will help you avoid creating hundreds (okay, not hundreds) of "else if" blocks and actually set up a polymorphic structure and abstracting your code. It's a specifically tailored design pattern. It's probably too late now, but it's something you should consider next year: http://firstforge.wpi.edu/sf/docman/...tation/doc1297

Last edited by arithehun : 11-02-2013 at 02:27.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:11.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi