I’ve been trying to print the temperature of a motor to the screen but it only accepts character arrays. I tried to use
Brain.Screen.printAt(100, 100, std::c_str(std::to_string(Motor.temperature(celsius)));
but neither c_str or to_string are included in the standard that the code uses. How can I accomplish this?
You could do:
Brain.Screen.setCursor(X, Y);
Brain.Screen.print(Motor.temperature(temperatureUnits::celsius));
That’s what I used for my flywheel temperature last year.
This is what I used to print 7 digits of rotation value:
Brain.Screen.print("IN: %+3.7f", brainInertial.rotation());
That prints out a value that always displays the sign (+
formatter), with three digits before the decimal (3.
) and 7 digits after the decimal (7
), in floating point format (f
).
I use this page for all things related to printf/sprintf/fprintf (which print()
looks like it wraps), and I’ve made some REALLY cool and funky printouts in my life with some of the formatting that’s able to be done. Now, to be fair, I’m not sure how much of all the standard printf
functionality works in Vex, because I know those functions can take up quite a bit of memory, but enough of it works to do the basics like I did above.