Fix restarts on ESP devices #22
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addressing #3
The restarts only happen on ESP devices and in case a long rotation is requested. The rotation is done by invocation of
step()function in a loop, which ultimately does pin setup anddelayMicroseconds. The latter one doesn't return the control back to the system (unlikedelay()) sp the entire rotation happens in one solid execution. This is not a problem for an AVR, however on ESP (which has a network stack running in background) long runs without returning control back to the system cause watch dog to kick in and do a soft reset of the device.In order to prevent such behavior, this PR adds invocation of
yield()between performin the motor steps (gives a quick control back to the system).The motor worked 360 degrees CW and CCW without restart with this change. The rotation speed visually wasn't affected. Returning control to the system is required for a reason, so perhaps there might be situations when the system actually starts doing some work and it will affect the motor performance, but it might be a matter for a bigger change. So far this PR should provide a reasonable relief, so that the library can be used on ESP devices