Hello! I am messing around with PROS and I wanted to recreate my team’s screen GUI however the standard lcd::initialize()
wasn’t working so we ended up using the screen functions (i.e. screen::print()
or screen::draw_rect()
. We made the GUI and it works, however, there is a flicker due to the screen updating in a task. I know in Vex Code Pro there is a function called render()
that got rid of this. Is there any equivalent in PROS, specifically with the screen functions?
Relevant code
// Main.cpp
LCD_Menu menu;
void printMenu(){
while(!menu.isDeconstructed){
if(screen::touch_status().y <= 26) checkPressedTab(screen::touch_status().x, menu);
if(menu.enableAuton){
autonID = checkPressedAuton(menu, screen::touch_status().x, screen::touch_status().y);
}
ctrl.print(0, 2, "%c", autonID);
delay(250);
}
}
void initialize() {
Task printGUI(printMenu);
}
// LCD_Main.cpp
void LCD_Menu::printAuton(pros::Color color, std::vector<char> autoNum){
this->screenClear(); // Clears screen to draw shapes
// Draw boxes
this->makeAutonButtons(16, 32, 130, 93.75);
// First row buttons
LCD::set_pen(pros::Color::dark_orange); // set text color orange
LCD::print(pros::text_format_e_t::E_TEXT_MEDIUM, 55, 53, "None"); // print none in box
this->printAutonNumber(130, 93.75, '0'); // Prints 0 in the bottom right corner of the box
LCD::set_pen(pros::Color::green); // set text color green
LCD::print(pros::text_format_e_t::E_TEXT_MEDIUM, 166, 53, "Skills"); // print skills in box
this->printAutonNumber(251, 93.75, autoNum[0]); // Prints the first char
// Second row buttons
LCD::set_pen(color);
LCD::print(pros::text_format_e_t::E_TEXT_MEDIUM, 54, 126, "AWP1"); // print AWP1 in box
this->printAutonNumber(130, 162.75, autoNum[1]); // Prints the second char
LCD::set_pen(color);
LCD::print(pros::text_format_e_t::E_TEXT_MEDIUM, 175, 126, "AWP2"); // print AWP2 in box
this->printAutonNumber(251, 162.75, autoNum[2]); // Prints the third char
// Third row buttons
LCD::set_pen(color);
LCD::print(pros::text_format_e_t::E_TEXT_MEDIUM, 28, 194.5, "Goal Rush"); // print goal rush in box
this->printAutonNumber(130, 231.75, autoNum[3]); // Prints the fourth char
LCD::set_pen(color);
LCD::print(pros::text_format_e_t::E_TEXT_MEDIUM, 149.25, 194.5, "Ring Rush"); // print ring rush in box
this->printAutonNumber(251, 231.75, autoNum[4]); // Prints the fifth char
LCD::set_pen(pros::Color::white);
}
void checkPressedTab(int32_t pressed_X,LCD_Menu& Menu){
Menu.enableAuton = false; // Toggles auton buttons functionality to on
Menu.isBlue = false;
//Menu.enableFile = false; // Toggles file buttons functionality to off
// Checks if a pressed x value is where the Tabs are
if(pressed_X <= 96){
Menu.printAuton(pros::Color::red); // Prints the autonomous selection page
Menu.enableAuton = true; // Toggles auton buttons functionality to on
} else if (pressed_X > 96 && pressed_X <= 192){
Menu.enableAuton = true; // Toggles auton buttons functionality to off
Menu.isBlue = true;// Prints the System information page
Menu.printAuton(pros::Color::blue, {'A', 'B', 'C', 'D', 'E'});
}
}
// Checks if a pressed x and y value is where the autonomous selection are
char checkPressedAuton(LCD_Menu &Menu, int16_t pressed_X, int16_t pressed_Y){
char checkout; // Helper variable that holds values for the return statement
// Refresh the screen and print the tab's autons
if(Menu.isBlue) Menu.printAuton(pros::Color::blue, {'A', 'B', 'C', 'D', 'E'});
else Menu.printAuton(pros::Color::red);
LCD::set_eraser(BLUE); // Set the text background color to the default
// Check for selection of autonomous programs in the first column
if (pressed_X >= 15.99 && pressed_X <= 130.01) {
// Check for selection of None
if (pressed_Y >= 31.99 && pressed_Y <= 93.76) {
LCD::print(pros::E_TEXT_MEDIUM, 286, 50, "Selected:None");
return 0;
}
// Check for selection of AWP1
else if (pressed_Y >= 100.99 && pressed_Y <= 162.76) {
LCD::print(pros::E_TEXT_MEDIUM, 286, 50, "Selected:AWP1");
checkout = 2;
}
// Check for selection of Goal Rush
else if(pressed_Y >= 169.99 && pressed_Y <= 231.76){
LCD::print(pros::E_TEXT_MEDIUM, 286, 50, "Selected:Goal Rush");
checkout = 4;
}
}
// Check for selection of autonomous programs in the second column
else if (pressed_X >= 136.99 && pressed_X <= 251.01) {
// Check for selection of Skills
if (pressed_Y >= 31.99 && pressed_Y <= 93.76) {
LCD::print(pros::E_TEXT_MEDIUM, 286, 50, "Selected:Skills");
checkout = 1;
}
// Check for selection of AWP2
else if (pressed_Y >= 100.99 && pressed_Y <= 162.76) {
LCD::print(pros::E_TEXT_MEDIUM, 286, 50, "Selected:AWP2");
checkout = 3;
}
// Check for selection of Ring Rush
else if(pressed_Y >= 169.99 && pressed_Y <= 231.76){
LCD::print(pros::E_TEXT_MEDIUM, 286, 50, "Selected:Ring Rush");
checkout = 5;
}
} else return 0;
// Return the ASCII representation of the char
return Menu.isBlue ? checkout+64 : checkout+48;
}
Side note: I know LVGL is far better than doing a GUI this way however again, the screen doesn’t initialize