Engleski nazivi dana u tjednu su zamijenjeni kraticama dana u tjednu na hrvatskom jeziku.

Dependents:   SUSTAV_KONTROLE_PRISTUPA

Revision:
9:5627b407e097
Parent:
8:d0e66fa78e79
Child:
10:984b0ce5c236
--- a/Rtc_Ds1307.cpp	Sun Jun 23 19:24:57 2013 +0000
+++ b/Rtc_Ds1307.cpp	Wed Jun 26 21:05:46 2013 +0000
@@ -2,7 +2,7 @@
 #include "Rtc_Ds1307.h"
 
 #ifndef DEBUG
-#define DEBUG
+//#define DEBUG
 #endif
 #include "debug.h"
 
@@ -205,17 +205,19 @@
 RtcCls::RtcCls(PinName sda, PinName scl, PinName sqw, bool bUseSqw)
     : Rtc_Ds1307(sda, scl), m_sqw(sqw), m_bUseSqw(bUseSqw), m_bAlarmEnabled(false), m_alarmfunc(NULL)
 {
+    Time_rtc t;
+    //  query time from device
+    getTime(t);
+    //  sync the time with MBED RTC
+    struct tm now = {t.sec, t.min, t.hour, t.date, t.mon-1, t.year-1900};
+    m_time = mktime(&now);
+    set_time(m_time);
+    
     //  Only register the callback and start the SQW if requested to do so. Otherwise the system
     //  will use the MBED built-in RTC.
     if (m_bUseSqw) {
-        Time_rtc t;
         //  start the wave
         setSquareWaveOutput(true, RS1Hz);
-        //  query time
-        getTime(t);
-        struct tm now = {t.sec, t.min, t.hour, t.date, t.mon-1, t.year-1900};
-        m_time = mktime(&now);
-        set_time(m_time);
         //  register callback from now on the time will be maintained by the square wave input
         m_sqw.rise(this, &RtcCls::_callback);
     }