Skip to content

Commit

Permalink
Issue #24 correction
Browse files Browse the repository at this point in the history
Corrected logic for isAlarm() method
  • Loading branch information
SV-Zanshin authored May 15, 2023
1 parent 81829f4 commit 6ee982d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/DS3231M.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,9 @@ bool DS3231M_Class::isAlarm() {
@brief return whether either of the two alarms has been triggered
@return true if either of the 2 alarms is triggered, otherwise false
*/
uint8_t controlByte = readByte(DS3231M_CONTROL);
uint8_t statusByte = readByte(DS3231M_STATUS);
return ((controlByte & 0xFE) && (statusByte & 0xFE)) |
((controlByte & 0xFD) && (statusByte & 0xFD));
uint8_t controlByte = readByte(DS3231M_CONTROL) & 0xFC; // Mask out all but last 2 bits for ALM1&2
uint8_t statusByte = readByte(DS3231M_STATUS) & 0xFC; // Mask out all but last 2 bits for ALM1&2
return (controlByte & statusByte); // Nonzero when alarm and switch bits set
} // of method isAlarm()
void DS3231M_Class::clearAlarm() {
/*!
Expand Down

0 comments on commit 6ee982d

Please sign in to comment.