Auton/Drive Switch Issue

Ok, lot of issues with this code. However, the most fundamental issue that stopping driver from running after auton is the “old_drive” function that is mostly a blocking function, you need to add a sleep_for in that while loop. Add a sleep here.
I don’t have time to explain reson right now, except know that calling position() on a motor is treated differently from many other API calls and will not allow an automatic task stop.

          while (Continue) {
              this_thread::sleep_for(10);
              double currentAverage =   (LF.position(deg) +LR.position(deg)  + RF.position(deg) + RR.position(deg))/4;
              if (direction == fwd) {

But you have issue with events and tasks. using the code I posted here.

We can look at how tasks are being allocated in your code.

When first run in a disabled state we have this.
disabled_1

Run auton
auton_1

One more thread as expected.
Back to disabled.
auton_2
The auton thread is still running, that’s because you set this flag in main.
(edit: if that flag was true, the thread would still exist but be in a stopped state so the display would still show 15)

    Competition.bStopTasksBetweenModes = false;

edit: see my subsequent comments in a later post.

Now run driver.
driver_1
Lots more threads because of all the event registration.

but if I disable and re-enable driver.
driver_2
even more threads because you register events a second time.

so yea, some issues to solve.