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

DS3231: Add support for fetching alarm enabled status #269

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
8 changes: 6 additions & 2 deletions examples/DS3231_alarm/DS3231_alarm.ino
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ void loop() {
Serial.print("] SQW: ");
Serial.print(digitalRead(CLOCK_INTERRUPT_PIN));

// whether a alarm fired
Serial.print(" Fired: ");
// indicates if alarm 1 is enabled
Serial.print(", Enabled: ");
Serial.print(rtc.alarmEnabled(1));

// whether alarm 1 fired
Serial.print(", Fired: ");
Serial.print(rtc.alarmFired(1));

// Serial.print(" Alarm2: ");
Expand Down
15 changes: 13 additions & 2 deletions src/RTC_DS3231.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,19 @@ void RTC_DS3231::clearAlarm(uint8_t alarm_num) {

/**************************************************************************/
/*!
@brief Get status of alarm
@param alarm_num Alarm number to check status of
@brief Get enabled status of alarm
@param alarm_num Alarm number to check enabled status of
@return True if alarm is enabled otherwise false
*/
/**************************************************************************/
bool RTC_DS3231::alarmEnabled(uint8_t alarm_num) {
return (read_register(DS3231_CONTROL) >> (alarm_num - 1)) & 0x1;
}

/**************************************************************************/
/*!
@brief Get fired status of alarm
@param alarm_num Alarm number to check fired status of
@return True if alarm has been fired otherwise false
*/
/**************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/RTClib.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ class RTC_DS3231 : RTC_I2C {
Ds3231Alarm2Mode getAlarm2Mode();
void disableAlarm(uint8_t alarm_num);
void clearAlarm(uint8_t alarm_num);
bool alarmEnabled(uint8_t alarm_num);
bool alarmFired(uint8_t alarm_num);
void enable32K(void);
void disable32K(void);
Expand Down