pkerspe / ESP-StepperMotor-Server

Turn your ESP32 into a complete stepper motor control server with web UI, REST API and serial control interface
MIT License
225 stars 39 forks source link

switches to trigger movement #8

Closed savehanges closed 4 years ago

savehanges commented 4 years ago

There is a future feature called "switches to trigger movement macros". is this available for beta testing ? i need to run StepperMotor-Server for custom movements trigger by sensors.

pkerspe commented 4 years ago

sorry, not yet implemented. But maybe you can describe your use case a bit further? It is actually quite simple to write your own implementation by 1.) registering an interrupt handler for the switch you want to use to trigger a movement (in your main function) 2.) in the ISR you simply get the flexy stepper instance of the stepper you want to move and call the setTargetPositionInSteps function on the flexyStepper Instance. e.g to get the flexyStepper instance of the first stepper configuration (index = 0):

ESP_FlexyStepper *stepper = stepperMotorServer->getCurrentServerConfiguration()->getConfiguredFlexySteppers()[0];
stepper->setTargetPositionInSteps(1000);

Or you can get it via the id of the stepper configuration (here just as a single line of code to set a new target for the stepper configuration with the ID 0):

stepperMotorServer->getCurrentServerConfiguration()->getStepperConfiguration(0)->getFlexyStepper()->setTargetPositionInSteps(1000);
savehanges commented 4 years ago

Thanks for quick reply. basically i want to move 3 axis. 1st one moves until it find the sensor and then move back. 2nd one move after the fist axis touch the sensor. 3rd axis just moving between limit switches with a trigger sensor regardless of other axis.