-
Notifications
You must be signed in to change notification settings - Fork 13.3k
polledTimeout: add option to use CPU count instead of millis() #5870
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some way to check for an overflow timeout when using CPU cycles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general question: what is the use case? I see two slight advantages and one big disadvantage of the enhancement:
Pros:
- better precision for detection of expiration (1 cycle is a fraction of a ns, vs. 1ms for millis)
- faster polling (the code is lighter, so a for() or while() loop will run faster and hence poll at a higher frequency
Con:
- Rollover time is drastically reduced from something like several days to a minute or so for 80MHz, and half that for 160MHz.
Neither Pro nor Con:
- CPU busy waiting will be more or less the same
- Power usage will be more or less the same
- Usage is the same
libraries/esp8266/examples/BlinkPolledTimeout/BlinkPolledTimeout.ino
Outdated
Show resolved
Hide resolved
I'm afraid not. rollover is 26 seconds @160Mhz. Misleading type names are removed (YieldOrSkip).
Yes, comments are added to use it only when it is known to be checked often
Yes, it is not intended for busy waiting but for periodic testing only. Maybe I should remove
This is a Pro :) About performance, |
also removed printed message, add YieldAndDelay, simplify calculations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That off-by-one is the last thing, but I'm not sure how to fix it.
…eset(), getTimeout() is invalid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Great job :)
No description provided.