Unable to clear the Controller Screen

I’m currently working with the V5 controller and programming in PROS and I am unable to clear the screen using the .clear or clear_line commands. I also tried the pure c functions and nothing works. The print commands work fine just I can’t remove the text. Below is the code I am testing. Any help would be greatly appreciated.

void opcontrol() {
  pros::Controller master(pros::E_CONTROLLER_MASTER);
  master.set_text(0, 0, "Example");
  pros::delay(1000);
  master.clear();
}

1069B - Argonauts

The controller text is notoriously difficult to manage.
Each command needs to be at least 50ms apart, no matter what.
Essentially, the controller polls the robot every 50ms and the robot returns the latest command.
If you call clear but right away call something else, the clear will be ignored.

I know you are delaying in that snippet, but there might be somewhere else that causes the clear command to be overridden.
It is possible opcontrol gets restarted when it exits. Not sure, but it is worth a try to delay after the clear command.

I have had problems with the joystick, but as soon as I made a wrapper class that acted like a buffer for my write commands, that ensures a command is only sent every 50ms, it worked smoothly. I then expanded it to support two controllers and rumble commands. Everything is possible if you properly manage the timing, but that is tough to do without abstracting stuff. It is difficult to properly do the timing in arbitrary user code.

Anyways, try this code:

void opcontrol() {
  pros::delay(1000);
  pros::Controller master(pros::E_CONTROLLER_MASTER);
  pros::delay(50);
  master.set_text(0, 0, "Example");
  pros::delay(50);
  master.clear();
  pros::delay(50);
  pros::delay(5000000); //wait forever
}
1 Like

Unfortunately that code didn’t work, it still display the text but wouldn’t remove the text. I added more delays in different areas to see if that would help but I could not find a working combination. Could there be another reason for the issue?

There might be something wrong with the clearing.
Try setting a string of spaces to clear.
In my buffer class I do not call clear, and when there is no text I apply spaces to all the lines.

It is possible all lines need to be written to tell the controller that you are now in charge of the screen and it can stop showing the default display. Try writing to all the lines first.

The spaces method worked but unfortunately I can’t get the clear_line function to work either. I am also slightly confused on the controller_set_text function. When I put line 0 into the function it prints to the bottom of the screen but if I print line 1 then it bumps everything up into the proper position. I still can’t get any of the clear functions to work.