I have made some experiments with Timer with a step / dir driver (like TM2130)
https://github.com/pidou46/ustepper/blo ... stepper.py
The general idea is to setup a PWM output and stop it with a Timer.
You just need to compute the Timer delay to achieve the desired stroke.
This solution is quite efficient, you can run the stepper at high speed (esp32 PWM can run at 40Mhz)
The code is non-blocking, so you can drive several steppers concurrently.
There are some drawbacks:
The position precision depends on Timer precision, I have found that delay of the Timer (in fact the callback function) is quite consistent to about 1300_us.
As the Timer can't be set in _us but only in _ms, you can compensate this delay by removing 1_ms to the Timer, the time precision would be around 300_us (the angular precision will depends of the stepper and the speed)
To achieve smooth rotation and high speed, it could be necessary to implement a speed ramp up (limited acceleration)
I do it by changing the microstepping setup on the fly.
I haven't made precision / repeatability test as of now, but it's in my todo list...
Hope this can help