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.
This adds a way to sleep in a non-busy way so different threads could sleep simoultaniously and execute actions on different intervals.
Added an example that toggles the Arduino One led every second, and writes to the serial console every 3.5s.
I checked this on my device and things seems to have been relatively accurate.
Note since the tick counter is limted to a
u16
and a tick occurs at least once every 0.064 ms the maximum delay that is possible is approx 4100 ms. If you want longer delays these need to be chained.Faster than 1 ms delays are also not supported. In principle this is possible but I feel those won't be accurate so I rather have them not supported.
A ``TimeReader` needs to be provided for the specific board and configured to be 16Mhz and prescaled at 1024.
I am not sure what would be the best cross-hardware way to distribute them (I am not sure if TC1 is always a 16bit timer that can prescale)
A possible addition would be to pass the Hz so the user can choose between precision and range.
I also wrapped the user provider
TimeReader
in a RefCell to prevent issues when trying to use this from multiple async handlers. Not sure what the cleanest Rust way would be (relatively new to rust)