
02-02-2009, 19:14
|
 |
Never too much duct-tape ;)
AKA: Patrick
FTC #0001 (Team Unlimited)
Team Role: Engineer
|
|
Join Date: Dec 2005
Rookie Year: 2001
Location: MA
Posts: 131
|
|
|
Re: [FTC]: NXT Display Code
I just figured it out...
I case anyone is interested in using this code in competition add this to your code:
Quote:
task main()
{
initializeRobot();
eraseDisplay();
bDisplayDiagnostics = false;
AutonomousChooser();
bDisplayDiagnostics = true;
waitForStart(); // Wait for the beginning of autonomous phase.
//YOUR CODE HERE
e.g.
if(sAlliance == "Blue")
{
//Blue ALLIANCE
if((sStart == "Floor") & (sScore == "12' Goal"))
{
// SCORE in the 12"
// GATHER from the Near Dispenser
// START from the Floor
}
}
}
|
just an example. Also, the AutonomousChooser was updated to this:
Quote:
int nAlliance = 0;
int nStart = 0;
int nScore = 0;
string sAlliance = "Red";
string sStart = "Floor";
string sScore = "12' Goal";
void AutonomousChooser ()
{
//////////////////////////////////////////////////////////////////////////////////////////////////////
//
// "Hi-jack" buttons for user program control.
//
nNxtButtonTask = -2; // Grab control of the buttons. '-3' is invalid for task, so no task will be
// executed when a button is pressed.
//
// Note: program cannot be terminated if we hijack the 'exit' button. So there has to be an escape sequence
// that will return buttons to system control! We'll use a triple click
//
nNxtExitClicks = 2; // Double clicking EXIT button will terminate program
//
// Do nothing. Just keep waiting
//
while (nEnterButton != 4)
{
TButtons nBtn;
while (true) // wait for button press
{
nBtn = nNxtButtonPressed;
if (nBtn != -1)
break;
}
switch (nBtn)
{
case kLeftButton: ++nLeftButton; break;
case kRightButton: ++nRightButton; break;
case kEnterButton: ++nEnterButton; break;
}
PlaySoundFile("! Click.rso");
nxtDisplayTextLine(0, "Alliance:" );
nxtDisplayTextLine(2, "Starting:" );
nxtDisplayTextLine(4, "Score:" );
nxtDisplayTextLine(6, "Double Click EXIT");
nxtDisplayTextLine(7, " to end program ");
if(nEnterButton == 0)
{
nRightButton = 0;
nLeftButton = 0;
nEnterButton = 0;
}
if(nEnterButton == 1)
{
nAlliance = abs(nLeftButton - nRightButton);
nxtDisplayTextLine(3, " ");
nxtDisplayTextLine(5, " ");
if((nAlliance == 0) || (nAlliance == 2))
{
sAlliance = "Red";
nxtDisplayTextLine(1, "%s", sAlliance); //
nRightButton = 0;
nLeftButton = 0;
}
if(nAlliance == 1)
{
sAlliance = "Blue";
nxtDisplayTextLine(1, "%s", sAlliance); //
}
}
if (nEnterButton == 2)
{
nStart = abs(nLeftButton - nRightButton);
if((nStart == 0) || (nStart == 2))
{
sStart = "Floor";
nxtDisplayTextLine(3, "%s", sStart); //
nRightButton = 0;
nLeftButton = 0;
}
if(nStart == 1)
{
sStart = "Ramp";
nxtDisplayTextLine(3, "%s", sStart); //
}
}
if (nEnterButton == 3)
{
nScore = abs(nLeftButton - nRightButton);
if((nScore == 0) || (nScore == 2))
{
sScore = "12' Goal";
nxtDisplayTextLine(5, "%s", sScore); //
nRightButton = 0;
nLeftButton = 0;
}
if(nScore == 1)
{
sScore = "20' Goal";
nxtDisplayTextLine(5, "%s", sScore); //
}
}
while (true) // wait for button release
{
nBtn = nNxtButtonPressed;
if (nBtn == -1)
break;
}
}
}
|
I will try to get this all comment out ASAP and i'll answer any questions on it in the mean time. 
|