Go to Post The great thing about FIRST is that there actually are 3,000 ways to win. Find yours, and leverage it. - Siri [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
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 01-02-2010, 00:14
buddyb's Avatar
buddyb buddyb is offline
Registered User
FRC #1885 (ILITE)
Team Role: Programmer
 
Join Date: Dec 2009
Rookie Year: 2008
Location: Haymarket, VA
Posts: 65
buddyb has a spectacular aura aboutbuddyb has a spectacular aura aboutbuddyb has a spectacular aura about
Re: [FTC]: Java in RobotC for TeleOp

Quote:
Originally Posted by rzoeller View Post
The problem is the button commands you are using. "joystick.joy1_Buttons" doesn't work like Joy1Btn, where it outputs the actual button number. Instead, it outputs numbers to the power of 2, like this:

button 1 = 1
button 2 = 2
button 3 = 4
button 4 = 8
button 5 = 16
button 6 = 32
etc...

This is useful to allow for commands where multiple buttons are pressed at once, but can be a pain otherwise. In your script, button 3 should activate case 4, with button 4 activating case 8. Case 3 currently displays when 1 and 2 are pressed togethor, and case 4 displays when button 3 is pressed.
^^Truth.

In addition, the joy1_buttons int adds the numbers together if multiple buttons are pressed at once (ex if button 3 (button 3 is 4) and button 4 (button 4 is 8) were pressed at the same time, the result in joy1_buttons would be 12).

Also, your code would only check to see if a single button is pressed each time the loop runs, because you're using a single switch statement. So, if you had buttons 3 and 4 pressed, the program would only see button 3 as pressed.

You may want to try a loop that checks each button, something like...
Code:
for(int i=1;i<=12;i++) {
  if(joy1Btn(i)) {
    switch(i) {
      case 1: /* Button 1 code */ break;
      //...
    }
  if(joy2Btn(i)) {
    switch(i) {
      case 1: /* Button 1 code */ break;
      //...
    }
}
Good job, though. ^^
__________________
FRC - Team 1885 - Programmer.

Last edited by buddyb : 01-02-2010 at 00:19. Reason: Elaboration.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FTC]: Buttons RobotC JohnFogarty FIRST Tech Challenge 2 25-11-2009 19:13
[FTC]: Programming Clarification [RobotC] basicxman FIRST Tech Challenge 3 11-02-2009 20:21
[FTC]: [FTC]: RobotC Template Problem (causing an FMS issue) and Potential Servo Prob PackersFan FIRST Tech Challenge 11 26-01-2009 21:25
[FTC]: RobotC Template gdo FIRST Tech Challenge 14 10-11-2008 06:26


All times are GMT -5. The time now is 13:03.

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