Getting multiple Tasks to work

I’m trying to get two tasks working. The code compiles ok, but only one task works.
I declared both in declarations.h

task User_Control();
task ShooterSpeed ();

and main.cpp includes
#include “declarations.h”

Then, outside of a while loop, in main.cpp I have:

vex::task task1(User_Control ());
vex::task task2(ShooterSpeed());

Only the User_Control task runs. If I comment out the first line calling User_Control, then ShooterSpeed works, so I know I have the tasks properly configured with their own while loop and task::sleep(20); and they can function by themselves.

I suspect I am missing some trigger to start multitasking?

Should I be declaring task1 and task2 somewhere? How, since they are not actually tasks.

don’t pass with the (), all you are doing is calling User_Control() directly with those added.
should be along the lines of.

vex::task task1( User_Control );
vex::task task2( ShooterSpeed );

User_Control and ShooterSpeed should be functions,

int
User_Control() {
  // code
  return 0;
}

so the prototype would be

int  User_Control();
7 Likes

Creating a Constructor that way got multiple tasks working. Thanks!