-
Notifications
You must be signed in to change notification settings - Fork 710
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 values #257
Conversation
This commit introduces 4 new methods for DS3231 devices: - DateTime getAlarm1(); - DateTime getAlarm2(); - Ds3231Alarm1Mode getAlarm1Mode(); - Ds3231Alarm2Mode getAlarm2Mode(); The getAlarm methods assume that the alarms are stored using 24 hour format since this library doesn't support storing alarms in 12 hour format (DS3231 hardware supports this). Updated the DS3231_alarm example to fetch alarm1. Also improved the formatting of the serial logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice addition! I think I found a glitch though, in the handling of weekly alarms.
Handle edge case where the result of calling getAlarm is used to set the alarm and the mode is set to "Day" Co-authored-by: Edgar Bonet <edgar-bonet@users.noreply.github.com>
There's some minor code dupe here that could potentially be refactored. But I think OK to go ahead and merge as is for now. Thanks for the updates. |
Thanks for the updates. This library is great!!! |
Hi! |
@techniciansoft I posted a PR based on your suggestion. It might be a while before someone at Adafruit accepts it. They aren't obligated to accept it if they don't want the functionality in the lib. I suspect they will accept this one because it is useful and is a very simple change. Next time feel free to submit a PR or open a new issue rather than commenting on a merged PR 😄 |
@justinnewitter Thank you for your help! |
@techniciansoft no worries! You'll be an expert in no time 😄 |
Hi everyone, I have a question about the Why "month" field is set to |
What do you mean by an “actual month”? The alarm date and time, as stored in the DS3231, has no month field, and no year field: year and month are then meaningless in the context of these alarms. The The why May 2000 was chosen is an implementation detail. It turns out it is the first month, within the supported date/time range, where the day-of-month number matches the day-of-week number. This helps keeping the code simple. |
Thank you for the quick and clear response. Now I see. I wondered because I wanted to set up an alarm to fire only once a year on the first of January. I did not pay attention that alarm does not care about the month number. Now I cannot find a way to achieve desired behavior. Is it even possible with this library and DS3231? |
@jieggii: The DS3231 hardware cannot do that. What you can do is set the alarm to fire on the first day of every month, and ignore it except on January. |
Summary
This commit introduces 4 new methods for DS3231 devices:
The getAlarm methods assume that the alarms are stored
using 24 hour format since this library doesn't support
storing alarms in 12 hour format (DS3231 hardware supports
this).
Updated the DS3231_alarm example to fetch alarm1. Also
improved the formatting of the serial logging.
Improved logging from the example sketch
Misc
RTC_DS3231.cpp
, but not onDS3231_alarm.ino
since it ends up making a bunch of changes to existing code.