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

milli seconds #45

Open
KarlZeilhofer opened this issue Jul 23, 2016 · 2 comments
Open

milli seconds #45

KarlZeilhofer opened this issue Jul 23, 2016 · 2 comments

Comments

@KarlZeilhofer
Copy link

to synchronize millis() with the second(), I used following workaround:

while(millis()%1000); // wait for milli seconds to be zero before setting new time. setTime(hour, minute, second, day, month, year);

hope this helps someone.
now you can print the time with milli seconds resolution.

@bojh
Copy link

bojh commented Apr 27, 2017

... for an exact given second at time, second should be incremented by +1 before setTime().

@PaulStoffregen an alternative would be to enhance API by a additional method.
Proposal:

time_t milliSec() { now(); return(millis()-prevMillis); }

Pro: exact (no offset!) and everybody can find and use it.
Con: more computation! ... vs. delayed sync and simple millis().

@cyberman54
Copy link

cyberman54 commented Feb 11, 2019

while(millis()%1000); // wait for milli seconds to be zero before setting new time.

@KarlZeilhofer What happenes on a multitasking RTOS system, where we can miss the one moment when millis()%1000 = 0 ?

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

No branches or pull requests

3 participants