Blank Pages
What is it?​
EZ-Template's autonomous selector takes over the emulated lcd display on the brain screen, making it very difficult to use the screen for debugging.
Blank pages are an easy solution for this, allowing you to add your own pages to the autonomous selector carousel that are blank.
Introduction​
Hello World!​
We have to make a Hello World! screen appear, right?
To create a blank page, you just have to check what page you're on. This will simultaneously check what page you're on and create the page if it doesn't exist.
if (ez::as::page_blank_is_on(0)) {
}
To print to the page, you can use ez::screen_print(). This is wrapper that makes printing to the screen much ezier.
if (ez::as::page_blank_is_on(0)) {
ez::screen_print("Hello World!", 1); // Print "Hello World!" on the second line
}
Putting this in opcontrol() will run it! Now if you turn the robot on and go one page to the left, you'll see this new page!
void opcontrol() {
// This is preference to what you like to drive on
chassis.drive_brake_set(MOTOR_BRAKE_COAST);
while (true) {
// Gives you some extras to make EZ-Template ezier
ez_template_extras();
chassis.opcontrol_tank(); // Tank control
// chassis.opcontrol_arcade_standard(ez::SPLIT); // Standard split arcade
// chassis.opcontrol_arcade_standard(ez::SINGLE); // Standard single arcade
// chassis.opcontrol_arcade_flipped(ez::SPLIT); // Flipped split arcade
// chassis.opcontrol_arcade_flipped(ez::SINGLE); // Flipped single arcade
// . . .
// Put more user control code here!
// . . .
// Print "Hello World!" on the second line
if (ez::as::page_blank_is_on(0)) {
ez::screen_print("Hello World!", 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
Multiple Pages​
Having multiple pages is just adding more to the if/else block! In this example, we create a second page that will display Hello Mars!.
if (ez::as::page_blank_is_on(0)) {
ez::screen_print("Hello World!", 1); // Print "Hello World!" on the second line
}
else if (ez::as::page_blank_is_on(1)) {
ez::screen_print("Hello Mars!", 2); // Print "Hello World!" on the third line
}
Putting this in opcontrol() will run it! Now if you turn the robot on and go one page to the left, you'll see Hello Mars!. If you go another page to the left, you'll see Hello World!.
void opcontrol() {
// This is preference to what you like to drive on
chassis.drive_brake_set(MOTOR_BRAKE_COAST);
while (true) {
// Gives you some extras to make EZ-Template ezier
ez_template_extras();
chassis.opcontrol_tank(); // Tank control
// chassis.opcontrol_arcade_standard(ez::SPLIT); // Standard split arcade
// chassis.opcontrol_arcade_standard(ez::SINGLE); // Standard single arcade
// chassis.opcontrol_arcade_flipped(ez::SPLIT); // Flipped split arcade
// chassis.opcontrol_arcade_flipped(ez::SINGLE); // Flipped single arcade
// . . .
// Put more user control code here!
// . . .
// Print "Hello World!" on the second line
if (ez::as::page_blank_is_on(0)) {
ez::screen_print("Hello World!", 1);
}
// Print "Hello World!" on the third line
else if (ez::as::page_blank_is_on(1)) {
ez::screen_print("Hello Mars!", 2);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
Variables​
ez::screen_print expects a string, so you can't just give it a double or a float and have it work.
You can use util::to_string_with_precision to convert variables to strings. This code will print test_variable to the blank page.
void opcontrol() {
// This is preference to what you like to drive on
chassis.drive_brake_set(MOTOR_BRAKE_COAST);
double test_variable = 0.0;
while (true) {
// Gives you some extras to make EZ-Template ezier
ez_template_extras();
chassis.opcontrol_tank(); // Tank control
// chassis.opcontrol_arcade_standard(ez::SPLIT); // Standard split arcade
// chassis.opcontrol_arcade_standard(ez::SINGLE); // Standard single arcade
// chassis.opcontrol_arcade_flipped(ez::SPLIT); // Flipped split arcade
// chassis.opcontrol_arcade_flipped(ez::SINGLE); // Flipped single arcade
// . . .
// Put more user control code here!
// . . .
test_variable += 0.01;
// Print test_variable to the second line
if (ez::as::page_blank_is_on(0)) {
ez::screen_print("test_variable: " + util::to_string_with_precision(test_variable), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
Multiple Lines​
There are two options for printing on multiple lines.
The first option is to just print to multiple lines.
// Print "Hello World!" on the second line and "Hello Mars!" on the third line
if (ez::as::page_blank_is_on(0)) {
ez::screen_print("Hello World!", 1);
ez::screen_print("Hello Mars!", 2);
}
The second option is to print ones but use \n in the string. This will do the same thing as the code above.
// Print "Hello World!" on the second line and "Hello Mars!" on the third line
if (ez::as::page_blank_is_on(0)) {
ez::screen_print("Hello World!\nHello Mars!", 1);
}
Screen Task​
You might want to view data on the screen during user control and during autonomous. For this, we'll need to create a task (code that always runs in the background) that displays to the screen.
First we need to make the task. This is the structure for making tasks, anything that goes in the while loop will always run in the background.
void ez_screen_task() {
while (true) {
// Code goes here
pros::delay(ez::util::DELAY_TIME);
}
}
pros::Task ezScreenTask(ez_screen_task);
We can fill this in with code that prints to the brain screen and code that constantly updates test_variable. This code can be placed anywhere outside of a function in main.cpp, it's above opcontrol() in the example project. With this you'll be able to see test_variable update if you're in user control or autonomous!
// Make test_variable a global variable
double test_variable = 0.0;
void ez_screen_task() {
while (true) {
// Print test_variable to the second line
if (ez::as::page_blank_is_on(0)) {
ez::screen_print("test_variable: " + util::to_string_with_precision(test_variable), 1);
}
// Constantly update test_variable
test_variable += 0.01;
pros::delay(ez::util::DELAY_TIME);
}
}
pros::Task ezScreenTask(ez_screen_task);