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