From 07dd8f02bf8e807b5274b80914b19afc890f4ae2 Mon Sep 17 00:00:00 2001 From: JChristensen Date: Mon, 21 Feb 2022 18:24:28 -0500 Subject: [PATCH] Add a constructor to improve backwards compatibility. --- README.md | 4 ++-- src/DS3232RTC.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a52257c..fe7f151 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License along with thi The 2.0.0 version of the library has some significant changes and is not completely backwards compatible with earlier versions. These changes provide a more consistent API and reduce the possibility of name collisions. While sketches using this library will likely require changes as a result, these should be mostly straightforward. - - The library no longer defines a `DS3232RTC` object, therefore each sketch needs to define one. Previous versions of the library defined a DS3232RTC object named `RTC`, only for AVR architectures. (Consider using a name other than `RTC` as this can cause a name collision on some architectures.) - - The constructor no longer has the capability to initialize the I2C bus, therefore, the sketch needs to call `DS3232RTC::begin()` in the `setup()` function or elsewhere as appropriate. + - The library no longer defines a `DS3232RTC` object, therefore each sketch needs to define one. (Previous versions of the library defined a DS3232RTC object named `RTC`, although only for AVR architecture. Consider using a name other than `RTC` as this can cause a name collision on some architectures.) + - The constructor no longer has the capability to initialize the I2C bus and no longer accepts an optional parameter. Therefore, the sketch needs to call `DS3232RTC::begin()` in the `setup()` function or elsewhere as appropriate. - To reduce the possibility of name collisions, the enumerations as well as register addresses, etc. are now defined in the header file within the DS3232RTC class. Therefore, when using any of these names, it will be necessary to include the DS3232RTC scope, e.g. `myRTC.alarm(DS3232RTC::ALARM_1);` - Also to reduce collisions, register address names and bit names have been prefixed with `DS32_` (see the header file.) - The example sketches and documentation have been updated to reflect these changes. diff --git a/src/DS3232RTC.h b/src/DS3232RTC.h index 3e80d97..ea6ae95 100644 --- a/src/DS3232RTC.h +++ b/src/DS3232RTC.h @@ -132,6 +132,7 @@ class DS3232RTC DS32_DYDT {6}; // Day/Date flag bit in alarm Day/Date registers DS3232RTC() {}; + DS3232RTC(bool initI2C) { (void)initI2C; } // undocumented for backward compatibility void begin(); static time_t get(); // static needed to work with setSyncProvider() in the Time library uint8_t set(time_t t);