1 #ifndef ACE_TIME_SYSTEM_CLOCK_HEARTBEAT_LOOP_H 2 #define ACE_TIME_SYSTEM_CLOCK_HEARTBEAT_LOOP_H 5 #include "SystemClock.h" 24 uint16_t heartbeatPeriodMillis = 5000):
25 mSystemClock(systemClock),
26 mHeartbeatPeriodMillis(heartbeatPeriodMillis) {}
33 unsigned long nowMillis = millis();
34 uint16_t timeSinceLastSync = nowMillis - mLastSyncMillis;
37 if (timeSinceLastSync >= mHeartbeatPeriodMillis) {
39 mLastSyncMillis = nowMillis;
45 uint16_t
const mHeartbeatPeriodMillis;
47 unsigned long mLastSyncMillis = 0;
acetime_t getNow() const override
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).
A TimeKeeper that uses the Arduino millis() function to advance the time returned to the user...
A class that peridically freshens the SystemClock using the heartbeat call to getNow().
SystemClockHeartbeatLoop(SystemClock &systemClock, uint16_t heartbeatPeriodMillis=5000)
Constructor.
void loop()
Call this from the global loop() method to make SystemClock keep in sync with the system millis()...