Skip to content

Commit

Permalink
Add RTC_DS3231::{get,set}Aging() to access the Aging Offset Register.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpwe committed Jan 11, 2023
1 parent 5dde49b commit a0edd8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/RTC_DS3231.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/RTClib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit a0edd8f

Please sign in to comment.