fix timesync from RTC

This commit is contained in:
cyberman54 committed 2022-03-05 19:08:35 +01:00
1 parent f74f103e80
commit fbb1878807
2 files changed
+10 -2

No files matched your search

+7 -1
View File
@@ -65,7 +65,13 @@ time_t get_rtctime(uint16_t *msec) {
// if we have a RTC pulse, we calculate msec
#ifdef RTC_INT
*msec = lastRTCpulse % 1000;
uint16_t ppsDiff = millis() - lastRTCpulse;
if (ppsDiff < 1000)
*msec = ppsDiff;
else {
ESP_LOGD(TAG, "no pulse from RTC");
return 0;
}
#endif
return t;
+3 -1
View File
@@ -203,8 +203,10 @@ void timepulse_init(void) {
#endif
// get time if we don't have one
if (timeSource != _set)
if (timeSource != _set) {
delay(1000); // wait for first PPS time stamp to arrive
setTimeSyncIRQ(); // init systime by RTC or GPS or LORA
}
// start cyclic time sync
timesyncer.attach(TIME_SYNC_INTERVAL * 60, setTimeSyncIRQ);