Hey gang,
I’m hoping that someone here can explain to me what I’m doing wrong in my code. I’m pretty new to this and I’m sure it’s something that will be obvious to someone who knows more about coding.
I have 2 functions, named “task1” and “Task2” that both run properly individually. Task1 completes substantially quicker than Task2.
When I try to programatically call them in a loop, the robot behaves as if it’s not waiting for Task2 to finish before it starts Task1 again.
void task1(int time, power)
{
Do some stuff here
}
void task2(int encValue, power)
{
Do other stuff
}
task main()
{
while(true)
{
if(vexRT[Btn8D] == 1)
{
task1 (5,30);
task2 (1400,30);
task1 (2, -30);
task2 (2100, 50);
}
}
}
It looks like since Task2 (1400,30) takes a few seconds to finish, task1(2,-30) is starting before Task2 (1400,30) is done and we can’t figure out why.
Can anyone help please?