Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Printing values to user messages box (http://www.chiefdelphi.com/forums/showthread.php?t=113718)

omsahmad 16-02-2013 20:40

Printing values to user messages box
 
Very simple question, whose answer I cannot figure out. I am using a CAN bus system to control the speed of my motors. I think it is working but I want to display the value of the encoder in the user messages box. How exactly do I accomplish this? Currently only text is showing up in the messages box.

DriverStationLCD is lcd

my code:

lcd->Printf(DriverStationLCD::kUser_Line3, 1, "Rate: ", shooterOne->GetSpeed);
lcd->UpdateLCD();

Thanks

Kevin Sevcik 16-02-2013 22:34

Re: Printing values to user messages box
 
You need to use standard printf formatting.

Your line should be something like:
lcd->Printf(DriverStationLCD::kUser_Line3, 1, "Rate: %f", shooterOne->GetSpeed());

Also, calling the Clear() method first tends to prevent weird overwriting problems that muddle the output.

omsahmad 16-02-2013 23:59

Re: Printing values to user messages box
 
Quote:

Originally Posted by Kevin Sevcik (Post 1234702)
You need to use standard printf formatting.

Your line should be something like:
lcd->Printf(DriverStationLCD::kUser_Line3, 1, "Rate: %f", shooterOne->GetSpeed());

Also, calling the Clear() method first tends to prevent weird overwriting problems that muddle the output.

I put the parentheses after GetSpeed, I just forgot them here. I did not have %f, however. I'll try it out tomorrow.

Thank you.

EDIT: It worked perfectly, thanks


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

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