Quote:
Originally Posted by Gamer930
I'm looking at printing the value of the joystick y axis to the screen.
Code:
DriverStation *ds;
DriverStationLCD *dsLCD;
Joystick *driveController;
RobotDemo(void)
{
ds = DriverStation::GetInstance();
dsLCD = DriverStationLCD::GetInstance();
driveController = new Joystick(1);
}
void OperatorControl(void)
{
GetWatchdog().SetEnabled(true);
while (IsOperatorControl())
{
GetWatchdog().Feed();
dsLCD->Printf(DriverStationLCD::kUser_Line4, 1, driveController->GetY());
dsLCD->UpdateLCD();
}
}
Is there something that needs to be included?? is there a ToString() like there is in java???
Also is there string concatenation that you can add two strings together?? "Left Drive: " + driverController->GetY()
|
Your ToString() comment made my day.
If you want to write a float to a string you can use some of the following methods.
Code:
float my_float = 123.456f;
char line_buffer[22];
sprintf(line_buffer, "value: %.2f", my_float);
// or
#include <sstream>
float my_float = 123.456f;
std::stringstream ss("value: ");
ss.precision(2);
ss << my_float;
std::string line_buffer = ss.str();