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