Go to Post The mediocre do the minimum, then exclaim how easy it is. The exceptional never stop to gloat... they're too busy figuring out new ways to make it even better... - Mr. Lim [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 21-01-2013, 19:23
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: 543
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
Command-based while button presed

I want to run a specific command but i only want to run it when the button is pressed but i cant find the specific function for that

Code:
            OI.controlDriver.buttonA.whenPressed(RobotMap.intakeIn);
            OI.controlDriver.buttonA.whenReleased(RobotMap.intakeIn);
            OI.controlDriver.buttonB.whileHeld(RobotMap.intakeOut);
they just continually run the command
Reply With Quote
  #2   Spotlight this post!  
Unread 21-01-2013, 19:34
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Command-based while button presed

Quote:
Originally Posted by Arhowk View Post
I want to run a specific command but i only want to run it when the button is pressed but i cant find the specific function for that

Code:
            OI.controlDriver.buttonA.whenPressed(RobotMap.intakeIn);
            OI.controlDriver.buttonA.whenReleased(RobotMap.intakeIn);
            OI.controlDriver.buttonB.whileHeld(RobotMap.intakeOut);
they just continually run the command
The problem isn't in the button call itself. You need to set the isFinished() method in your command to something other than "false," otherwise it will never complete.

Psuedocode:

Code:
isFinished() {
      when (frisbeeIsLoaded)
              return true;
}
or

Code:
isFinished() {
       return isTimedOut();
}
When isFinished() returns true, it calls end() and stops the command. If it never returns true, end() is never called.
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional

Last edited by F22Rapture : 21-01-2013 at 19:42.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-01-2013, 19:44
Mastonevich's Avatar
Mastonevich Mastonevich is offline
Andrew
AKA: Andrew Elsen
FRC #1987 (BroncoBots)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Missouri
Posts: 221
Mastonevich is a jewel in the roughMastonevich is a jewel in the roughMastonevich is a jewel in the rough
We found somewhere in the documentation where u need to put it in the interrupted function and it worked for us.
__________________
~Andrew

Regional Chairman's: 2013-Alamo, 2010-Oklahoma, 2009-Colorado
Engineering Inspiration: 2016-Hub City, 2012-St. Louis, 2008-Minnesota
Regional Wins: 2010-Oklahoma
Reply With Quote
  #4   Spotlight this post!  
Unread 21-01-2013, 20:03
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: 543
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: Command-based while button presed

Quote:
Originally Posted by Mastonevich View Post
We found somewhere in the documentation where u need to put it in the interrupted function and it worked for us.
Yeah.... was about to say that putting the cancel functions in interrupted and not end worked.

On a slightly related topic, can I wipe the commands currently linked to a button?

i can do

button.whilePressed();

but can i do

button.releaseCommands();

so that it no longer runs the commands issued by .whilePressed()
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 11:24.

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