AceTime  0.3
Date and time classes for Arduino that support timezones from the TZ Database, and a system clock that can synchronize from an NTP server or an RTC chip.
SystemClockHeartbeatCoroutine.h
1 #ifndef ACE_TIME_SYSTEM_CLOCK_HEARTBEAT_COROUTINE_H
2 #define ACE_TIME_SYSTEM_CLOCK_HEARTBEAT_COROUTINE_H
3 
4 #include <stdint.h>
5 #include "SystemClock.h"
6 
7 namespace ace_time {
8 namespace clock {
9 
16 class SystemClockHeartbeatCoroutine: public ace_routine::Coroutine {
17  public:
26  uint16_t heartbeatPeriodMillis = 5000):
27  mSystemClock(systemClock),
28  mHeartbeatPeriodMillis(heartbeatPeriodMillis) {}
29 
30  int runCoroutine() override {
31  COROUTINE_LOOP() {
32  mSystemClock.getNow();
33  COROUTINE_DELAY(mHeartbeatPeriodMillis);
34  }
35  }
36 
37  private:
38  SystemClock& mSystemClock;
39  uint16_t const mHeartbeatPeriodMillis;
40 };
41 
42 }
43 }
44 
45 #endif
acetime_t getNow() const override
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).
Definition: SystemClock.h:67
SystemClockHeartbeatCoroutine(SystemClock &systemClock, uint16_t heartbeatPeriodMillis=5000)
Constructor.
A TimeKeeper that uses the Arduino millis() function to advance the time returned to the user...
Definition: SystemClock.h:45
A coroutine that calls SystemClock.getNow() peridically.