I use update-to-date PROS and V5 firmware.
I try to print three lines to the controller screen. However only the first line printed. Thank you for your help.
void opcontrol() {
pros::Controller master(CONTROLLER_MASTER);
master.clear();
while (true) {
master.print(0, 0, "Vex");
master.print(1, 0, "girl");
master.print(2, 0, "arm:%8.2f", arm.get_position());
pros::delay(100);
}
}
rpm
February 1, 2020, 4:26pm
#2
You to wait 50ms between updates.
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 w…
1 Like
Thanks.
I already have pros::delay(100)
at the end of code which should delay 100 ms. Or should I add pros::delay
after each print command?
3038922
February 1, 2020, 4:56pm
#4
void opcontrol() {
pros::Controller master(CONTROLLER_MASTER);
master.print(0, 0, "Vex");
auto timeFlag=pros::millis();
while (true) {
if(pros::millis()-timeFlag>=1000)
{
master.print(1, 0, "arm:%8.2f", arm.get_position());
timeFlag=pros::millis();
}
pros::Task::delay_until(&timeFlag, 10);
}
}
You can ask me directly via wechat
He can only display two lines in my previous version test.
I don’t need Pros:: delay(), which is 10ms at most. It can’t be 100ms.
2 Likes
Thanks. It works. I guess each print command should be 50 ms apart.
1 Like