Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RTC_DS3231::{get,set}Aging() to access the Aging Offset Register. #270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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