My teams have created a lot of user defined functions. My question is where do they insert them into the competition template so that they can be used during autonomous and driver control? They are currently placed directly after the initial #pragma statements.
That would probably be ok, the code would look something like this.
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
//-------------------------------
// User functions here
void
myFunction()
{
// some magic code
}
//-------------------------------
void pre_auton()
{
bStopTasksBetweenModes = true;
// Code that needs to happen when the cortext is turned on
}
task autonomous()
{
// your autonomous code
}
task usercontrol()
{
while (true)
{
// your driver control code
}
}
A better way is to place all your user defined functions in their own file, perhaps call that file functions.c, and include that in your competition template. Make sure you save the competition template code and the file with the functions in the same directory, you can then include those functions like this.
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
//-------------------------------
// User functions here
#include "functions.c"
//-------------------------------
void pre_auton()
{
bStopTasksBetweenModes = true;
// Code that needs to happen when the cortext is turned on
}
task autonomous()
{
// your autonomous code
}
task usercontrol()
{
while (true)
{
// your driver control code
}
}
The file functions.c would have the following.
void
myFunction()
{
// some magic code
}