-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
PolledTimeout Class for wrapping millis() loops (WIP) #5198
Conversation
Does it make sense to add such extenders for ease of use,
I would call this the glue between perfect c++ and the arduino world which is primarily aimed at beginners. edit: we could even do this (with trivial iterator emulation like there)
|
The API looks good. |
@d-a-v I've been thinking about your iterator emulation. My original thought was that it doesn't make sense, because iterators are meant for going over a range of items in a container.
A use case for doStuff() could be sampling something, like the ADC, so the above would sample the ADC for a specific amount of time. There are other cases where you want to do something in a time-aware manner while waiting for a timeout to expire. |
Merging this as-is given that it's needed in many places. |
Class to wrap typical polled timing constructs:
Classes are declared inside namespace esp8266. Use model is meant for stack declaration (declaration initializes, i.e.: RAII) with one exception: do something in the loop every n ms. In that last case, declaration must be global and the global must be reset() at the end of setup().
I expect to add a device test as soon as I figure out htf they work.
Usage is something like this: