View Single Post
  #1   Spotlight this post!  
Unread 02-02-2009, 17:52
gdo's Avatar
gdo gdo is offline
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
gdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to behold
Send a message via AIM to gdo Send a message via MSN to gdo
[FTC]: NXT Display Code

I was working on an autonomous program chooser to work locally on the NXT. the problem lies when you use the #included "JoystickDrive.c" command (which we have to use...) there is a included file in this drive to display information about battery voltage and important information like that. The problem is that it covers the screen when I want to display information over it for my program selecter.

Here's the code: (BTW, I removed user specific code to make the post not too long, all it did was use the strings and user functions to compile the wanted autonomous).

Quote:


#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.

int nAlliance = 0;
int nStart = 0;
int nScore = 0;
string sAlliance = "Red";
string sStart = "Floor";
string sScore = "12' Goal";


int nLeftButton = 0;
int nRightButton = 0;
int nEnterButton = 0;


void AutonomousChooser()
{
// Place code here to sinitialize servos to starting positions.
// Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize.


//////////////////////////////////////////////////////////////////////////////////////////////////////
//
// "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);
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;
}
}
return;
}
I was just wonder if it would be legal to edit the JoystickDrive.c file to remove the dianogstic code or is there some way to clear the screen of this data for as long as I am using this routine. I tried using the EraseDisplay routine, but it doesn't erase all lines, any ideas or suggestions?

Thanks in advance guys!
~GDO, Team Unlimited (FTC #1)

This routine does work 100% without the template right now, so if any one has any questions about it or wants to use it, I will explain it and show you the complete code.

Inside the "JoystickDriver.c" file, the problem source is here:

Quote:
task displayDiagnostics()
{
string sFileName;

getUserControlProgram(sFileName);
nxtDisplayTextLine(6, "Teleop FileName:");
nxtDisplayTextLine(7, sFileName);
bNxtLCDStatusDisplay = true;
while (true)
{
if (bDisplayDiagnostics)
{
getJoystickSettings(joystick); //Update variables with current joystick values

if (joystick.StopPgm)
nxtDisplayCenteredTextLine(1, "Wait for Start");
else if (joystick.UserMode)
nxtDisplayCenteredTextLine(1, "TeleOp Running");
else
nxtDisplayCenteredTextLine(1, "Auton Running");

if ( externalBatteryAvg < 0)
nxtDisplayTextLine(3, "Ext Batt: OFF"); //External battery is off or not connected
else
nxtDisplayTextLine(3, "Ext Batt:%4.1f V", externalBatteryAvg / (float) 1000);

nxtDisplayTextLine(4, "NXT Batt:%4.1f V", nAvgBatteryLevel / (float) 1000); // Display NXT Battery Voltage

nxtDisplayTextLine(5, "FMS Msgs: %d", nMessageCount); // Display Count of FMS messages
}

wait1Msec(200);
}
}
From what I see, its purely cosmetic and shouldn't interfer w/ anything if removed.
__________________



FTC #1: http://unlimited.syraweb.org

Got any question for me; AIM, MSN or PM me

Last edited by gdo : 02-02-2009 at 18:15.
Reply With Quote