Quote:
Originally Posted by David Bryan
Dear GaryK or anyone willing to hear.
I took this working section out of user_routines.c and renamed part of it and placed it into user_routines_fast.c. It will not compile. I cannot find my error. The same program will compile back in user_routines.c.
Here is the program:
/************************************************** *****************************
* FUNCTION NAME: Lim_Mix
* PURPOSE: Limits the mixed value for one joystick drive.
* CALLED FROM: Default_Routine, this file
* ARGUMENTS:
* Argument Type IO Description
* -------- ---- -- -----------
* intermediate_value int I
* RETURNS: unsigned char
************************************************** *****************************/
unsigned char Lim_Mix (int intermediate_valu)
{ // < I get a compile error here.
static int limited_valu;
if (intermediate_valu < 2000)
{
limited_valu = 2000;
}
else if (intermediate_valu > 2254)
{
limited_valu = 2254;
}
else
{
limited_valu = intermediate_valu;
}
return (unsigned char) (limited_valu - 2000);
}
// when i place the cursor over the variable, limited_valu
// i get the bubble [limited_valu = Out of Scope].
// please help
// thanks - David Bryan Team 818
|
Hi, David:
I wonder also if you put this function inside another function. Did you put it where it says:
/* Add your own autonomous code here. */
?
If I put your code there I get an error on the "unsigned char" line.
Try removing all the code in question, and make sure you get a clean compile. Then, add your code at the very end of the file and I think it will compile.
The code you have is a complete function and it can't be put in the middle of another function (and I apologize if you already know this.) If it works with your code at the end of user_routines_fast.c then you can call it where you need it.
BTW, if you just need a limit_mix function for your autonomous routine, you can call the one in user_routines.c - the significance of the function is determined by
where you call it from, not which file it's in. To do so, add this
line with the other function prototypes in user_routines.h:
unsigned char Limit_Mix (int);
Make sure it compiles after you remove your own Lim_Mix(), then you can
call Limit_Mix from your autonomous routine.
Gary