Log in

View Full Version : Reading Pan Angle from terminal.c


marccenter
08-02-2007, 19:17
I am confused as to how to properly read Pan Angle in the terminal.c file inside of auto user_routines.c. Do I define
the Pan_Angle parameter inside of terminal.c or
inside of user_routines.c Do I use an extern static unsigned int statement inside of terminal.c and still
use another statement in user_routines.c? I tried to look
through the code and did not find examples.

1) I have added a statement right below where Kevin is outputting Pan Angle in the print statement to calculate
Pan_Angle.

printf(" Pan Angle (degrees) = %d\r\n", (((int)N_SERVO - 124) * 65)/124);
(Pan_Angle= (((int)PAN_SERVO - 124) * 65)/124);

2) Inside of terminal.c I have added
static unsigned int Pan_Angle = 0;

3) What about inside user_routines.c where I actually
want to be able to read the Pan Angle?

A little confused with C-coding standards,

DanDon
08-02-2007, 20:48
If you are declaring the variable outside of a function in terminal.c, make it an unsigned char.

In order to be able to access the variable in user_routines.c, put a
extern unsigned char Pan_Angle;

at the top of the file, outside the functions.

marccenter
09-02-2007, 09:11
So, I have done the following and received the following error message.

Inside of terminal.c I have placed
1) unsigned char Pan_Angle

Inside of user_routines.c I have placed

2) extern unsigned char Pan_Angle

and I received the following error message.

user_routines.c:566:Fatal [151] -internal p:rolleyes: opulateExternalReferences() - symbol 'Pan_Angle' is not an external reference.

mgurgol
09-02-2007, 14:58
Do you have the definition of Pan_Angle defined within a function? Defining it outside of any function in terminal.c will make it global. Define it after the #include statements.