Satoshi Togawa / Mbed 2 deprecated LcdClock

Dependencies:   DebouncedEdgeIn I2cLCD_cursor Rtc8564 mbed beep

Revision:
4:75ed86b78045
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mechanism/RtcMechanism.cpp	Sun Feb 23 00:16:54 2014 +0000
@@ -0,0 +1,40 @@
+#include "RtcMechanism.h"
+
+RtcMechanism::RtcMechanism()
+    :m_mode(Model::CLOCK),
+     m_clock(0),
+     m_dateTime(0),
+     m_rtc(0)
+{
+}
+
+void RtcMechanism::setClock(Model::Clock* clock)
+{
+    m_clock = clock;
+    m_dateTime = m_clock->getDateTime();
+}
+
+void RtcMechanism::setRtc(Rtc8564* rtc)
+{
+    m_rtc = rtc;
+    m_rtc->clock(this, &RtcMechanism::update);
+}
+  
+void RtcMechanism::setPresentTime()
+{
+    m_rtc->setTime(m_dateTime);
+}
+
+void RtcMechanism::mode(Model::OperationMode mode)
+{
+    m_mode = mode;
+}
+
+void RtcMechanism::update()
+{
+    if(m_mode != Model::CLOCK) return;
+
+    m_rtc->getTime(m_dateTime);
+
+    m_clock->renew();
+}