Extend SoftwareTimer with option to make it non-repeating, add reset function & ISR-safe functions. #260
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.
The SoftwareTimer provided by the library is missing a function for resetting it.
Also, I want to reset this timer from an ISR attached by attachInterrupt. Based on the documentation at https://www.freertos.org/FreeRTOS-timers-xTimerResetFromISR.html, I figured it was necessary to use the ISR-safe functions, so there's ISR-safe equivalents included. I'm not quite certain about their name, though; I used ISR because that was what was in my head at the time but it might be more appropriate to name them more in line with Arduino-style "attachInterrupt" thus becoming "resetFromInterrupt" etc.
Finally, the timer I want must be non-repeating, only getting started when an interrupt tells it to start. So I added a begin()-function that adds a boolean to its signature to specify whether the timer repeats if it ticks over or suspends.
See
https://github.com/MacGyverNL/bluepedal/blob/02213ee9dcc495ccdc47f572892f7388aac09a55/bluepedal/bluepedal.ino#L190
and
https://github.com/MacGyverNL/bluepedal/blob/02213ee9dcc495ccdc47f572892f7388aac09a55/bluepedal/bluepedal.ino#L281
for context of how I'm using them to implement a loopless HID.