View Single Post
  #3   Spotlight this post!  
Unread 21-12-2011, 16:48
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: System.out.println help

Judging by the use of a capital in Get(), and that you posted to the C++ forum, I'm assuming you're using C++. System.out.println isn't a thing in C, the equivalent is printf(). An example:
Code:
// Top of file
#include <stdio.h>
...
// Inside your function
printf("%d\n", encoder1.Get());
The %d means we have an integer to print, and \n means to add a newline afterwards. Look here for more info

One thing to note, however, is that excessive use of printf can sometimes flood the network and if this is being called every iteration, you'll get a ton of text in netconsole. I prefer to use the DriverStationLCD class, which will put the text on the right of the Operation tab of the driver station.
Code:
void OperatorControl(void)
{
	DriverStationLCD *dslcd = DriverStationLCD::GetInstance();
	...
	while (IsOperatorControl())
	{
		dslcd->Clear();
		...
		dslcd->Printf(DriverStationLCD::kUser_Line1, 1, "Left Encoder: %d", encoder1->Get());
		...
		dslcd->UpdateLCD();
	}
}
kUser_Line1 tells it which line to go on, 1 is the column to start in (generally 1), and the rest of it is called just like the regular printf(). Make sure you include the Clear() at the top of your loop, otherwise you can get some weird stuff in the text box.
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"
Reply With Quote