mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 23:07:17 +00:00
Add RTC time save
This commit is contained in:
parent
dca2837285
commit
6a0c4b281e
@ -125,8 +125,7 @@ typedef struct {
|
||||
int32_t energy_kWhtoday_ph[3]; // 2D8
|
||||
int32_t energy_kWhtotal_ph[3]; // 2E4
|
||||
int32_t energy_kWhexport_ph[3]; // 2F0
|
||||
|
||||
uint8_t free_2fc[4]; // 2FC
|
||||
uint32_t utc_time; // 2FC
|
||||
} TRtcSettings;
|
||||
TRtcSettings RtcSettings;
|
||||
#ifdef ESP32
|
||||
|
@ -37,6 +37,9 @@ uint32_t GetRtcSettingsCrc(void) {
|
||||
|
||||
void RtcSettingsSave(void) {
|
||||
RtcSettings.baudrate = Settings->baudrate * 300;
|
||||
if (UtcTime() > START_VALID_TIME) { // 2016-01-01
|
||||
RtcSettings.utc_time = UtcTime();
|
||||
}
|
||||
if (GetRtcSettingsCrc() != rtc_settings_crc) {
|
||||
|
||||
if (RTC_MEM_VALID != RtcSettings.valid) {
|
||||
|
@ -489,10 +489,15 @@ void RtcInit(void) {
|
||||
|
||||
if (Settings->cfg_timestamp > START_VALID_TIME) {
|
||||
// Fix file timestamp while utctime is not synced
|
||||
uint32_t local_time = Settings->cfg_timestamp +1;
|
||||
RtcGetDaylightSavingTimes(local_time);
|
||||
local_time += RtcTimeZoneOffset(local_time);
|
||||
uint32_t utc_time = Settings->cfg_timestamp;
|
||||
if (RtcSettings.utc_time > utc_time) {
|
||||
utc_time = RtcSettings.utc_time;
|
||||
}
|
||||
utc_time++;
|
||||
RtcGetDaylightSavingTimes(utc_time);
|
||||
uint32_t local_time = utc_time + RtcTimeZoneOffset(utc_time);
|
||||
RtcSetTimeOfDay(local_time);
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("RTC: Timestamp %s"), GetDT(local_time).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user