// modified from https://pros.cs.purdue.edu/v5/tutorials/topical/notifications.html?highlight=task%20remove#ending-tasks-cleanly
pros::Task drive_task;
void autonomous() {
drive_task = pros::Task{ [] {
pros::Motor left_motor{ LEFT_MOTOR_PORT };
pros::Motor right_motor{ RIGHT_MOTOR_PORT };
// while the notification value remains zero for more than 20 ms
while (!pros::Task::notify_take(true, 20)) {
left_motor.move(127);
right_motor.move(127);
}
// add any cleanup code if neccesary
} };
while (true) {
pros::delay(20);
}
}
void opcontrol() {
// send a signal to the drive task so we can operate the robot manually now
drive_task.notify();
pros::Controller master{ pros::E_CONTROLLER_MASTER };
pros::Motor left_motor{ LEFT_MOTOR_PORT };
pros::Motor right_motor{ RIGHT_MOTOR_PORT };
while (true) {
left_motor.move(master.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y));
right_motor.move(master.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y));
pros::delay(20);
}
}