View Single Post
  #14   Spotlight this post!  
Unread 27-02-2006, 00:06
Dillon Compton Dillon Compton is offline
Jack-Of-All-Trades
FRC #1391 (Metal Moose)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Malvern, PA
Posts: 186
Dillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud of
Send a message via AIM to Dillon Compton
Re: EasyC autonomous modes

Quote:
Originally Posted by TubaMorg
I was thinking that, too, which will certainly get you out of Initialize(). The only problem with that, though, is that the mode counter increments 1 more, taking you off the program you set. I'm thinking my original sample is the answer, although if you like the %= (which is pretty slick) you could substitute that for my way of counting.
Yea...you are probably right on this one, i'll give you that.

But for the sake of argument (and because I like the way Brad's code is layed out more[no offense]), I think this might work...

Code:
// code sample from EasyC (or WPILib)
void Initialize ( void )
{
      unsigned char mode = 0; 

      while ( !IsEnabled() )
      {
            while ( GetOIDInput(1,1) == 0 && !IsEnabled() ) 
            // wait for the trigger, but only if the field is disabled.
            {
            }

	    if ( !IsEnabled() )
	    {
           	 mode++;      // increment mode  
            }
         
            while ( GetOIDInput(1,1) == 1 )     // wait for trigger release
            {
            }

            mode %= 5 ;                         // make sure mode < 5
            SetUserDisplay ( mode ) ;           // put mode in LED for feedback
      }
}
__________________
www.metalmoose.com