Using the Print Console in VEXcode IQ with Python

The Print Console allows the user to display messages, report sensor values, or to present data from VEXcode IQ projects. The Print Console also allows users to save print outputs as a text file.

The Print Console can also be used to display process information, providing visual cues that enable the user to see what is happening in a VEXcode IQ project at a specific moment in time, thereby making a visual connection between the project and the actions of the IQ Robot.

The Print Console needs to have active communication between the VEX IQ (2nd generation) Brain and the device being used with VEXcode IQ. This can be accomplished by:

USB Connection

USB_Connection.png

Wireless Via Controller

Wireless_Via_Controller.png

Note: Bluetooth communication is unavailable.

The following article will cover:


How to Open the Print Console

Screen_Shot_2021-11-17_at_10.10.42_PM.png

The Print Console is located in the IQ Monitor Display. To open the Print Console, select the Monitor Display icon next to Help.

monitor_display_will_open_python.png

The Monitor Display will open once selected. The Print Console is at the right side.


How to Use the Print Console in a Project

Commands that Trigger the Print Console

print_console_commands.png

Print commands are located in the Look category of commands and are used in a VEXcode IQ project in order to trigger the Print Console.

These commands print words, numbers, reported values from variables, values reported from a sensor or device, or clear the console.

The Help feature in VEXcode IQ provides additional information on these and other commands.

See this article for information on how to access the Help feature.

Using Print Commands with the Print Console

python_code_for_print_example.png

Use print commands in a VEXcode IQ project to print a message, or display data in the Print Console.

To use the print commands, select the command and add it to a project.

Then, type the text to be printed inside the quotation marks within the parentheses.

Note: You can also add sensor or variable commands inside the parenthesis to print data. See examples in the 'Examples using the Print Console' section. 

Screen_Shot_2021-11-17_at_9.58.23_PM.png

Download the project to the IQ Robot Brain and Select "Run". See this article on downloading and running a Python project. 

using_print_console_example_1-1.png

Once “Run” is selected, the project will run and the colored text or programmed values will be printed to the Print Console as dictated by the VEXcode IQ project.

Note: Python creates a new line by default after each print command.

Screen_Shot_2021-11-16_at_11.52.56_AM.png

You can print multiple values on a single line by adding multiple messages or commands inside the parentheses of the print command, and separating them with commas as shown on the image on the left.

Screen_Shot_2021-11-16_at_11.54.53_AM.png

Or, you can utilize the end parameter to print multiple values to a single line, as shown in this image.


Printing in Color in the Print Console

Screen_Shot_2021-11-17_at_12.05.42_PM.png

You can set the color of the text being printed by using a color code with a print command in VEXcode IQ.

To use a color code with a print command, add the escape sequence ("\033") and the color code inside the print command, as shown on the left.

The following are a few examples of color codes.

  • [31m - Red
  • [32m - Green
  • [34m - Blue

See the complete list of color codes in the Help Feature for the print command. See this article for information on how to access the Help feature.

Screen_Shot_2021-11-17_at_9.58.23_PM.png

Download the project to the IQ Robot Brain and Select "Run". See this article on downloading and running a Python project. 

Screen_Shot_2021-11-17_at_12.06.29_PM.png

Once “Run” is selected, the project will run and the colored text or programmed values will be printed to the Print Console as dictated by the VEXcode IQ project.


Clear Rows in the Print Console

select_clear_python.png

There are two ways to clear all information from the Print Console. The first way to completely clear all text is to select the “Clear” button on the bottom left of the Print Console.

Screen_Shot_2021-11-16_at_11.58.34_AM.png

Another way to clear the Print Console is to use the Console Clear print command highlighted in the image on the left. Add this command to remove all of the lines in the Print Console.

In this project, “Hello” will print on the Print Console. After 3 seconds, the console will be cleared.


Save from the Print Console

select_save_python.png

It is easy to save information from the Print Console onto your device.

Select “Save” on the bottom of the Print Console to save all text as a .txt file.

downloaded_logs.png

Once you select the “Save” button, the file will automatically save to the Downloads folder on your device as a .txt file.

Note: The file does not save printed colors.


Example Projects Using the Print Console

Report Variable Values and Data in a Project

The Print Console can be used to report variable values at discrete moments within a project.

Screen_Shot_2021-11-17_at_11.18.54_AM.png
Screen_Shot_2021-11-17_at_11.20.19_AM.png

Use the Print Console to print the value of “myVariable."

In the project on the left, the Print Console displays variable values when the Brain buttons are pressed. The variable increases when the 'left' button is pressed, and decreases when the 'right' button is pressed.


Report Sensing Values and Data in a Project

The Print Console can be used to report sensor data at discrete moments within a project.

python_project.png
python._sensor_project.png

The data captured by the Print Console allows the user to see valuable information about project processes including IQ Robot sensor information. When the print command is triggered, it can be programmed to display information captured in the moment.

In the project on the left, the Print Console displays information reported by the Inertial Sensor built into the IQ Brain (2nd gen) as prescribed by the Look and Sensing commands within the project. This information includes changes that the Inertial Sensor captures at discrete moments while the project is running: time in seconds and the rotation of the IQ BaseBot in degrees.

Note: The project in this example uses the BaseBot (Drivetrain, 2-motor) template.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus