Printing values in PROS

My team and I recently switched to PROS. On VexCode, printing values to the brain and controller was easy, but we couldn’t find any functions to print values for PROS. We’ve tried printf, but nothing comes out. What are the right statements to use to print values to the brain and controller (or terminal)? Thanks for your help!

To print to the brain in PROS, I recommend using
pros::lcd::print(0 (the line on the brain), “the text you want %d”, an integer to replace %d); there are a couple variations of this that you can do, namely %f for doubles, and %5.4f, to specify how many numbers and decimals you want. if you want to print multiple things to one line you can simply do pros::lcd::print(0, “left:%3d right:%3d:”,leftTrack.get_value(), rightTrack.get_value());

3 Likes

Currently, there are two supported ways of printing to the screen with PROS.

The easy way is to use the Legacy LCD Emulator (LLEMU). This is that ‘green screen’ you see on many robots that are programmed with PROS. It even has 3 virtual button at the bottom that you can program too. You can see some screen captures of it in action here. On the PROS website there is a tutorial that covers the basics. As you follow the tutorial, you will notice that the default PROS project actually does the initialization for you. When you get a general idea of how it works, you can look at the full api for it here. I suggest skimming through this to see all the methods that are available to you.

If you are not familiar with format specifiers in C/C++ you can take a look at this resource too. It explains what each one is, and how to use them. This is important if you want to print values, as opposed to static text. These are really important because if you print a value with the wrong format, you might see a really strange value on your screen. Generally, %d for int and bool, %f for float and double and %s for std::string. Although if you are curious, you can experiment with other combinations.

If you dig a bit deeper into PROS, you will see that LLEMU is actually written using the LVGL graphics library. This is how teams can create custom UI’s on the brain’s screen. You should know that PROS uses LVGL 5.3.X which is now out of support on their website. Additionally, versions 6 & 7 - which are the only ones available on their website - introduce significant changes that do not make them backwards compatible. Luckily, it is still possible to find these docs without going through previous releases on their Github. Instead you will can use the waybackmachine as linked in this thread.

Some tips if you decide to use LVGL:

  • View publicly available PROS projects
  • check out this tutorial by @Codec
  • practice building UIs with their emulator
  • try out the examples in the 5.3.X documentation
5 Likes

You can also print to the terminal using either printf or std::cout, but the computer has to be plugged into the brain for the terminal to work

3 Likes