Go to Post Mentors may not be the direct focus of FIRST, but they are just as involved as students are. They play a pivotal role in the success of FIRST and of the success of every team. - Dan Petrovic [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FTC]: How to play sound from NXT gregsanCHEVY121 FIRST Tech Challenge 5 07-04-2009 10:10
[FTC]: RobotC and NXT-G (The two programming languages) craig_yates FIRST Tech Challenge 1 30-01-2009 21:47
[FTC]: Help requested, the NXT is not showing the battery as being connected. crazilyrandom1 FIRST Tech Challenge 2 17-01-2009 11:24
[FTC]: Bluetooth/NXT issues jbbjjbt FIRST Tech Challenge 5 23-10-2008 16:56
[FTC]: [FTC]: Ontario Provincial FTC Start/End Times cbhl FIRST Tech Challenge 8 16-12-2007 13:37


All times are GMT -5. The time now is 18:09.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi