diff --git a/src/RTC_DS3231.cpp b/src/RTC_DS3231.cpp index c24a65a2..8d181f49 100644 --- a/src/RTC_DS3231.cpp +++ b/src/RTC_DS3231.cpp @@ -6,6 +6,7 @@ #define DS3231_ALARM2 0x0B ///< Alarm 2 register #define DS3231_CONTROL 0x0E ///< Control register #define DS3231_STATUSREG 0x0F ///< Status register +#define DS3231_AGING 0x10 ///< Aging offset register #define DS3231_TEMPERATUREREG \ 0x11 ///< Temperature register (high byte - low byte is at 0x12), 10-bit ///< temperature value @@ -117,6 +118,22 @@ float RTC_DS3231::getTemperature() { return (float)buffer[0] + (buffer[1] >> 6) * 0.25f; } +/**************************************************************************/ +/*! + @brief Get the current value of the aging offset register + @return Aging offset (signed int8) +*/ +/**************************************************************************/ +int8_t RTC_DS3231::getAging() { return read_register(DS3231_AGING); } + +/**************************************************************************/ +/*! + @brief Set a new value for the aging offset register + @param val Aging offset +*/ +/**************************************************************************/ +void RTC_DS3231::setAging(int8_t val) { write_register(DS3231_AGING, val); } + /**************************************************************************/ /*! @brief Set alarm 1 for DS3231 diff --git a/src/RTClib.h b/src/RTClib.h index 879bb3fa..d571aa60 100644 --- a/src/RTClib.h +++ b/src/RTClib.h @@ -388,6 +388,8 @@ class RTC_DS3231 : RTC_I2C { void disable32K(void); bool isEnabled32K(void); float getTemperature(); // in Celsius degree + int8_t getAging(); + void setAging(int8_t val); /*! @brief Convert the day of the week to a representation suitable for storing in the DS3231: from 1 (Monday) to 7 (Sunday).