Telescope Control Library

Dependents:   PushToGo-F429

Revision:
0:6cb2eaf8b133
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTCClock.h	Sun Aug 19 05:21:20 2018 +0000
@@ -0,0 +1,43 @@
+#ifndef RTCCLOCK_H_
+#define RTCCLOCK_H_
+
+#include "mbed.h"
+#include "UTCClock.h"
+/**
+ * RTCClock class implements the UTCClock interface and provides time through the MBED interface to hardware RTC found on most ARM MCUs
+ */
+class RTCClock: public UTCClock
+{
+protected:
+	time_t t;
+public:
+
+	RTCClock()
+	{
+		time(&t);
+	}
+	~RTCClock()
+	{
+	}
+
+	time_t getTime()
+	{
+		time(&t);
+		return t;
+	}
+
+	void setTime(time_t newtime)
+	{
+		set_time(newtime);
+		t = newtime;
+	}
+
+	static RTCClock& getInstance()
+	{
+		static RTCClock clock;
+		return clock;
+	}
+};
+
+#endif /*RTCCLOCK_H_*/
+