Go to Post I believe with every fiber of my being that Engineering is an Art. It is a beautiful, wonderful, delightful art. - Joe Johnson [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 22-01-2004, 03:09
lasindi lasindi is offline
Registered User
FRC #1164 (Project Neo)
Team Role: College Student
 
Join Date: Jan 2004
Rookie Year: 2004
Location: New Mexico
Posts: 11
lasindi is an unknown quantity at this point
bool Variables, Autonomous Mode

First off, can you declare bool variables? I tried to compile a boolean variable, just because 1 bit is more efficient than wasting a whole byte on a char or 2 on a short.
Second, I looked at ifi_aliases.h in the default code. At the bottom it uses a #define compiler directive to define the macro autonomous_mode. Could anyone show me how to use this? Would you use code like
if(autonomous_mode)
{
/* Do whatever I want the robot to do during autonomous mode. */
}
in the Process_Data_From_Local_IO() function user_routines_fast.c?
Thanks for the help.

lasindi
  #2   Spotlight this post!  
Unread 22-01-2004, 07:35
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: bool Variables, Autonomous Mode

First off, you can't just use 1 bit. it has to be in a structure with 7 others. If you want just 1 bool, I would use char and set it to 0 or 255
  #3   Spotlight this post!  
Unread 22-01-2004, 07:49
Travis Hoffman's Avatar Unsung FIRST Hero
Travis Hoffman Travis Hoffman is offline
O-H
FRC #0048 (Delphi E.L.I.T.E.)
Team Role: Engineer
 
Join Date: Sep 2001
Rookie Year: 2001
Location: Warren, Ohio USA
Posts: 4,047
Travis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond repute
Re: bool Variables, Autonomous Mode

IFI set up a type structure called "bitid" for defining 1-bit variables:

Declare your variable:

bitid statusbyte

Define your macros:

#define gearstatus statusbyte.bit0
#define wingstatus statusbyte.bit1
.
.
.
#define wheeliestatus statusbyte.bit7

Seems to work fine.

Hope this helps.
__________________

Travis Hoffman, Enginerd, FRC Team 48 Delphi E.L.I.T.E.
Encouraging Learning in Technology and Engineering - www.delphielite.com
NEOFRA - Northeast Ohio FIRST Robotics Alliance - www.neofra.com
NEOFRA / Delphi E.L.I.T.E. FLL Regional Partner
  #4   Spotlight this post!  
Unread 22-01-2004, 10:00
Guest
 
Posts: n/a
Re: bool Variables, Autonomous Mode

By default, if you use a char to store "boolean" values, 0 is false and everything else is true. However if you have:
Code:
char boolVal=0;
boolVal=!boolVal;
// boolVal is now 255
Hence, you probably want to #define the following:
Code:
// Put this in a header file that every .c file accesses
typedef char bool;
#define true (char)(255)
#define false (char)(0)
Be sure to watch out for automatic cast of anything below above -1 and below 256 to an unsigned char.
  #5   Spotlight this post!  
Unread 22-01-2004, 10:02
Guest
 
Posts: n/a
Re: bool Variables, Autonomous Mode

And, there's no such thing as a real boolean variable in C, only in C++.
  #6   Spotlight this post!  
Unread 22-01-2004, 20:36
lasindi lasindi is offline
Registered User
FRC #1164 (Project Neo)
Team Role: College Student
 
Join Date: Jan 2004
Rookie Year: 2004
Location: New Mexico
Posts: 11
lasindi is an unknown quantity at this point
Re: bool Variables, Autonomous Mode

Thanks a lot for the help with the boolean variables. Could someone answer my question about using the autonomous_mode macro?
  #7   Spotlight this post!  
Unread 22-01-2004, 22:26
Guest
 
Posts: n/a
Re: bool Variables, Autonomous Mode

Quote:
Originally Posted by lasindi
Thanks a lot for the help with the boolean variables. Could someone answer my question about using the autonomous_mode macro?
Where to put your auto code:
Code:
/*******************************************************************************
*
* FUNCTION:  User_Autonomous_Code()
*
* PURPOSE:  Executes user's code during autonomous robot operation.
* 	 You should modify this routine by adding code which you
*	 wish to run in autonomous mode. This executes every 26.2ms.
*
* CALLED FROM: main.c/main()
*
* PARAMETERS:  None
*
* RETURNS:  Nothing
* 
*******************************************************************************/
void User_Autonomous_Code(void)
{
  while(autonomous_mode)
  {
	if(statusflag.NEW_SPI_DATA)
	{
		Getdata(&rxdata);   // bad things will happen if you move or delete this
		// autonomous code goes here
		Putdata(&txdata);   //even more bad things will happen if you mess with this
	}
  }
}
Closed Thread


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
how can you use a gyro in autonomous mode magical hands Programming 3 02-01-2004 13:31
Help On Coding 2K1 Controller GregTheGreat Programming 9 05-12-2003 18:35
Programming Autonomous mode Jared Stofflett Programming 3 11-11-2003 09:32
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11
autonomous mode timer Don Programming 6 09-02-2003 22:16


All times are GMT -5. The time now is 19:56.

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