Coder Social home page Coder Social logo

Picking up on an event about eztime HOT 2 CLOSED

malbrook avatar malbrook commented on May 26, 2024
Picking up on an event

from eztime.

Comments (2)

ropg avatar ropg commented on May 26, 2024

I guess you could turn off NTP updates with setInterval(0) and then from your own event call queryNTP (which doesn't actually set the time) and then setTime and whatever else you want to do. How about something like this. (Untested...)

[...]

void setup() {
    [...]
    setInterval(0);
    timeSyncEvent();
}

void timeSyncEvent() {
    time_t t;
    unsigned long measured_at;
    if (queryNTP("pool.ntp.org", t, measured_at)) {
        setTime(t, millis() - measured_at);

        // Insert whatever you want to with the received time here

        // run again in an hour
        UTC.setEvent(timeSyncEvent, now() + 3600;
    } else {
        UTC.setEvent(timeSyncEvent, now() + 5;
    }
}

 

I do plan for some future version to make the time updates such that time only goes forward (monotonous time) and corrections are done by adding or subtracting a few milliseconds here or there.

I'll also think about how to support RTC clocks, GPS receivers and the like.

from eztime.

malbrook avatar malbrook commented on May 26, 2024

Thanks for the ideas, excellent software library.

from eztime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.