Go to Post It looks like you put a robot through a paper shredder. - Madwolvez [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 02-09-2014, 08:28 PM
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 429
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: whileHeld() Motor Program Issue

I went through the code more closely than last time...

JoystickButton inherits whileHeld from Button.
Button extends Trigger.
whileHeld calls Trigger's whileActive method

From Javadoc:
Code:
whileActive

public void whileActive(Command command)
Constantly starts the given command while the button is held. Command.start() will be called repeatedly while the trigger is active, and will be canceled when the trigger becomes inactive.

Parameters:
command - the command to start
That's as far as I went. I assumed that calling start repeatedly on a command would cause it to cancel a previous running instance of the command. What it does do:

Command.start() adds the command to a vector of command that should be added to the list of commands that the scheduler will process.

Here's the catch, the scheduler doesn't do anything with the command if the command is already in the list. See line 145.

So I agree. whileHeld should work as advertised. I know that I've had trouble with it in the past, and have always implemented commands as I outlined above. Maybe the problems I had with whileHeld were actually with something else, I haven't gone back to investigate.
__________________
http://team2168.org
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 07:32 AM.

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