Skip to content

Commit 396c526

Browse files
add time reset boolean
1 parent 19ece18 commit 396c526

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

DS3231_RealtimeClock/DS3231_RealtimeClock.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ DS3231_RealtimeClock::DS3231_RealtimeClock(TwoWire* wire, uint8_t eeprom_address
1616
_rtc = new RTC_DS3231();
1717
}
1818

19-
void DS3231_RealtimeClock::begin() {
19+
void DS3231_RealtimeClock::begin(bool write_time) {
2020
// initializing the rtc
2121
if (!_rtc->begin(_wire)) {
2222
Log.warning(F("Initializing DS3231... Error!" CR));
2323
}
2424

25-
if (_rtc->lostPower()) {
25+
if (write_time || _rtc->lostPower()) {
2626
// when time needs to be set on a new device, or after a battery power
2727
// loss, the following line sets the RTC to the date and time this
2828
// project was compiled

DS3231_RealtimeClock/DS3231_RealtimeClock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DS3231_RealtimeClock
1919
{
2020
public:
2121
DS3231_RealtimeClock(TwoWire* wire, uint8_t eeprom_address = 0x57);
22-
void begin();
22+
void begin(bool write_time = false);
2323
DateTime now();
2424
DateTime load(int address = 0);
2525
void save(DateTime timestamp, int address = 0);

SystemClock/SystemClock.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ SystemClock::SystemClock(
2020
_clock = new DS3231_RealtimeClock(wire);
2121
}
2222

23-
void SystemClock::begin() {
24-
_clock->begin();
23+
void SystemClock::begin(bool write_time) {
24+
_clock->begin(write_time);
2525

2626
startupTime = _clock->startupTime;
2727
}

SystemClock/SystemClock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class SystemClock
2121
int daylightOffset_sec = 3600
2222
);
2323
void sync();
24-
void begin();
24+
void begin(bool write_time = false);
2525
void setLocalTime();
2626
float getStartupTemperature();
2727
DateTime now();

0 commit comments

Comments
 (0)