Engleski nazivi dana u tjednu su zamijenjeni kraticama dana u tjednu na hrvatskom jeziku.
Dependents: SUSTAV_KONTROLE_PRISTUPA
Diff: Rtc_Ds1307.cpp
- Revision:
- 8:d0e66fa78e79
- Parent:
- 7:dca20be3ef38
- Child:
- 9:5627b407e097
--- a/Rtc_Ds1307.cpp Sun Jun 23 18:48:59 2013 +0000 +++ b/Rtc_Ds1307.cpp Sun Jun 23 19:24:57 2013 +0000 @@ -2,7 +2,7 @@ #include "Rtc_Ds1307.h" #ifndef DEBUG -//#define DEBUG +#define DEBUG #endif #include "debug.h" @@ -213,8 +213,9 @@ setSquareWaveOutput(true, RS1Hz); // query time getTime(t); - struct tm now = {t.sec, t.min, t.hour, t.date, t.mon, t.year}; + 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); } @@ -222,13 +223,14 @@ void RtcCls::_callback(void) { +// INFO("Tick!"); // Simply increase the number of seconds m_time++; - if (m_bAlarmEnabled && (m_time == m_alarmTime)) { - if (m_alarmfunc != NULL) - m_alarmfunc(); - m_bAlarmEnabled = false; - } +// if (m_bAlarmEnabled && (m_time == m_alarmTime)) { +// if (m_alarmfunc != NULL) +// m_alarmfunc(); +// m_bAlarmEnabled = false; +// } } time_t RtcCls::getTime() @@ -237,8 +239,12 @@ if (!m_bUseSqw) { Time_rtc t; getTime(t); - struct tm now = {t.sec, t.min, t.hour, t.date, t.mon, t.year}; + struct tm now = {t.sec, t.min, t.hour, t.date, t.mon-1, t.year-1900}; m_time = mktime(&now); + INFO("getting time %02d.%02d.%04d %02d:%02d:%02d Ticks=%08lx", t.date, t.mon, t.year, t.hour, t.min, t.sec, m_time); + } + else { + INFO("getting time Ticks=%08lx", m_time); } return m_time; } @@ -253,9 +259,10 @@ tim.min = now->tm_min; tim.hour = now->tm_hour; tim.date = now->tm_mday; - tim.mon = now->tm_mon; + tim.mon = now->tm_mon+1; tim.year = now->tm_year + 1900; tim.wday = now->tm_wday +1; setTime( tim, true, true); + set_time(t); }