Skip to content

Commit a0edd8f

Browse files
committed
Add RTC_DS3231::{get,set}Aging() to access the Aging Offset Register.
1 parent 5dde49b commit a0edd8f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/RTC_DS3231.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define DS3231_ALARM2 0x0B ///< Alarm 2 register
77
#define DS3231_CONTROL 0x0E ///< Control register
88
#define DS3231_STATUSREG 0x0F ///< Status register
9+
#define DS3231_AGING 0x10 ///< Aging offset register
910
#define DS3231_TEMPERATUREREG \
1011
0x11 ///< Temperature register (high byte - low byte is at 0x12), 10-bit
1112
///< temperature value
@@ -117,6 +118,22 @@ float RTC_DS3231::getTemperature() {
117118
return (float)buffer[0] + (buffer[1] >> 6) * 0.25f;
118119
}
119120

121+
/**************************************************************************/
122+
/*!
123+
@brief Get the current value of the aging offset register
124+
@return Aging offset (signed int8)
125+
*/
126+
/**************************************************************************/
127+
int8_t RTC_DS3231::getAging() { return read_register(DS3231_AGING); }
128+
129+
/**************************************************************************/
130+
/*!
131+
@brief Set a new value for the aging offset register
132+
@param val Aging offset
133+
*/
134+
/**************************************************************************/
135+
void RTC_DS3231::setAging(int8_t val) { write_register(DS3231_AGING, val); }
136+
120137
/**************************************************************************/
121138
/*!
122139
@brief Set alarm 1 for DS3231

src/RTClib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ class RTC_DS3231 : RTC_I2C {
388388
void disable32K(void);
389389
bool isEnabled32K(void);
390390
float getTemperature(); // in Celsius degree
391+
int8_t getAging();
392+
void setAging(int8_t val);
391393
/*!
392394
@brief Convert the day of the week to a representation suitable for
393395
storing in the DS3231: from 1 (Monday) to 7 (Sunday).

0 commit comments

Comments
 (0)