Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to assign a value, or add/subtract time, to millis() and micros() #139

Closed
EternityForest opened this issue Feb 3, 2021 · 3 comments

Comments

@EternityForest
Copy link

Currently there are many assorted low-power libraries, but all of them generally interfere with millis() and micros().

If an API were provided to add or subtract time to these counters, then anyone implementing deep sleep could simply add the approximate sleep duration, keeping millis() dependent applications functional, at least where precision is not needed.

In addition, more complex things like getting the sleep time from an RTC are possible, so the approach still works in precision scenarios.

Going further, applications in need of precise timing could use GPS to correct the millis() and micros count, and timekeeping libraries that use millis() to simulate an RTC could then take advantage of this.

Going even further, the ability to explicitly set the times may make certain kinds of testing and debugging easier.

The API could simply be addElapsedTime(int32_t), setMicros(uint32_t), and setMillis(uint32_t), none of which require any overhead in the interrupt handlers, or anything the optimizer can't just get rid of, if not needed.

addElapsedTime would affect both micros() and millis(), and serve as the obvious, well-defined way to inform the system that you have just woken from deep sleep for a length of time.

@facchinm facchinm transferred this issue from arduino/Arduino Feb 3, 2021
@matthijskooijman
Copy link
Collaborator

This was previously reported as #69, so I'm going ahead to close this as duplicate to keep discussion in one place. Maybe you could add some of your specific suggestions to the other issue?

@EternityForest
Copy link
Author

EternityForest commented Feb 3, 2021 via email

@matthijskooijman
Copy link
Collaborator

Will do! Can't believe I didn't see that one while I was searching before I posted!

Well, we did sneakily move your issue from the primary arduino/Arduino repository to arduino/ArduinoCore-API repo, which is where the API is now being developed, so you were probably searching in the wrong place. No worries though! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants