rtctime.cpp: compiled time init option
This commit is contained in:
parent
6c3641fa42
commit
f8ba6e9e31
@ -24,17 +24,17 @@ uint8_t rtc_init(void) {
|
|||||||
Rtc.SetIsRunning(true);
|
Rtc.SetIsRunning(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If you want to initialize a fresh RTC to compiled time, use this code
|
#ifdef TIME_SYNC_COMPILEDATE
|
||||||
/*
|
// initialize a blank RTC without battery backup with compiled time
|
||||||
RtcDateTime tt = Rtc.GetDateTime();
|
RtcDateTime tt = Rtc.GetDateTime();
|
||||||
time_t t = tt.Epoch32Time(); // sec2000 -> epoch
|
time_t t = tt.Epoch32Time(); // sec2000 -> epoch
|
||||||
|
|
||||||
if (!Rtc.IsDateTimeValid() || !timeIsValid(t)) {
|
if (!Rtc.IsDateTimeValid() || !timeIsValid(t)) {
|
||||||
ESP_LOGW(TAG, "RTC has no recent time, setting to compilation date");
|
ESP_LOGW(TAG, "RTC has no recent time, setting to compiled time");
|
||||||
Rtc.SetDateTime(
|
Rtc.SetDateTime(
|
||||||
RtcDateTime(compiledUTC() - SECS_YR_2000)); // epoch -> sec2000
|
RtcDateTime(compiledUTC() - SECS_YR_2000)); // epoch -> sec2000
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||||
ESP_LOGI(TAG, "RTC initialized");
|
ESP_LOGI(TAG, "RTC initialized");
|
||||||
|
Loading…
Reference in New Issue
Block a user