Skip to content

stepper.startasync() and stepper.stopasync() #378

@ar055

Description

@ar055

commit e4d5059

could you please post some lua code demonstrating how these functions work?

  1. I was unable to start stepper motors with the stepper.startasync () command.
  2. the stepper.stopasync () command stops all motors.

my code:

m1.stepper =  stepper.attach(m1.dir_pin, m1.step_pin, 200, 60, 6000, 100, 100)
m2.stepper =  stepper.attach(m2.dir_pin, m2.step_pin, 200, 60, 6000, 100, 100)

function run(motor)
  function _run()
    pio.pin.setlow(motor.en_pin)
    stepper.start(motor.stepper)
--    stepper.startasync(motor.stepper)  -- does not work
  end
  if motor.stepper:getdistance() ~= 0 then
    th = thread.start(_run)
  end
end

m1.stepper:move(1000)
m2.stepper:move(1000)

run(m1)
run(m2)
tmr.sleepms(1000)

stepper.stopasync(m1.stepper)  -- all steppers stopped

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions