How to control one task then another

Supporting 2.7 and 3.2+
Saylerjen73
Fresh meat
Posts: 2
Joined: Wed Nov 30, 2022 5:52 pm

How to control one task then another

Post by Saylerjen73 »

Hi, I am wondering how I can do one task, have that finish, then do another.

For example, I want to change the 'setTargetPosition' then after it finished, have it move back.
step motor example code.png
Thank you!
You do not have the required permissions to view the files attached to this post.
jdecoux
Engineering
Posts: 184
Joined: Mon Nov 13, 2017 10:20 am

Re: How to control one task then another

Post by jdecoux »

To detect when your motor is done moving, you can either poll stepper0.getIsMoving() in a loop, or you can set up the stopped event handler to handle the event asynchronously (see setOnStoppedHandler for a brief example in the API).