Quote:
Originally Posted by Gamer930
For reference the following code DOES work :-)
Code:
char line_buffer[22];
sprintf(line_buffer, "Y: %.2f", driveController->GetY());
dsLCD->Printf(DriverStationLCD::kUser_Line2, 1, line_buffer);
Thanks for everyones help. Note: just like every language there is 100 ways to do every problem. . . I just really couldn't get anything to work. . . Not saying this is the best way but it works to test out values
|
That is most definitely NOT the best way to call DriverStationLCD:: Printf(). If you are not careful, you can easily overrun the end of your line_buffer, and most likely corrupt other memory, making for a very hard to debug problem.
The best way is to use the Printf() method as it was intended: put the format string in the argument list, followed by your variable(s):
Code:
dsLCD->Printf(DriverStationLCD::kUser_Line2, 1, "Y: %.2f", driveController->GetY());
If you take a look at the source code for the Printf() method, you will see that it goes to great pains to make sure it does not write more than 21 bytes to its internal line buffer.
HTH.