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

Added Epoch Support #3

Merged
merged 11 commits into from Dec 30, 2015
Merged

Added Epoch Support #3

merged 11 commits into from Dec 30, 2015

Conversation

GabrielNotman
Copy link
Contributor

Updated 23/11/15
Removed: [Added full H12 AM/PM support for setting the hours value (also for querying).]

Previously the RTC_MODE2_CTRL_CLKREP bit was not being set correctly (inverted).

Added the ability to get or set the time and date using either a Epoch or Y2K timestamp.
Epoch timestamps are clamped to Y2K lower bound.

Removed: [A few other modifications including renaming the function pointer type to avoid possible
conflicts and moving the __time24 into the class.]

Also added a one second delay in the begin() method.
This is because the clock reading appears to be off until
the first tick has elapsed.
Note in set hours the am_pm parameter is ignored
if the hours > 12.
Also removed 1 second delay in begin().
It was unnecessary after all.
@agdl
Copy link
Member

agdl commented Nov 17, 2015

@GabrielNotman Sorry but I removed the H12/H24 time representation because was asked in an Arduino issue, so now this PR has conflicts

@agdl
Copy link
Member

agdl commented Nov 17, 2015

What can we do about this? Having two begin function prototypes?

@agdl
Copy link
Member

agdl commented Nov 18, 2015

@GabrielNotman can you please join the discussion in the referenced issue?

@GabrielNotman
Copy link
Contributor Author

I'm fine with removing the 12hr mode support. It complicates things and creates potential confusion.
It is also trivial for anyone to convert if they wish to.

One note: I'm fairly certain that the RTC_MODE2_CTRL_CLKREP bit is asserted for 12h mode. You can test by setting the hours to 13, in 12 hour mode it will adjust that to 1pm.

@agdl
Copy link
Member

agdl commented Nov 18, 2015

Nope if you set 13 you have 13! However have you seen this commit?
d67cdb1

It enables the standby mode and shows how to use it!

@GabrielNotman
Copy link
Contributor Author

The main reason I needed the alarm functionality was for a wake interrupt.
That is a nice example demonstrating this.

May I suggest adding a conditional to check if the SerialUSB is present,
and only go to sleep if it is not. This will remove any issues people may
have if they are programming it via the Native USB port.

I'm a bit confused about that mode bit. I will try and check it tonight
when I have time.

One thing, I believe if you set out of range values, it will correct them.
However, it may only do so after the next clock cycle (1 second).

On 18 November 2015 at 11:33, Arturo Guadalupi notifications@github.com
wrote:

Nope if you set 13 you have 13! However have you seen this commit?
d67cdb1
d67cdb1

It enables the standby mode and shows how to use it!


Reply to this email directly or view it on GitHub
#3 (comment)
.

Regards,

Gabriel Notman

Software Developer at SODAQ

If our environment could speak, what would it say?

Start connecting devices everywhere.

www.sodaq.com

@agdl
Copy link
Member

agdl commented Nov 18, 2015

Feel free to improve the examples and any related things as you wish ;)

@GabrielNotman
Copy link
Contributor Author

Do you need me to create a new PR using the current code, in order to
resolve
the conflicts with the existing PR?

On 18 November 2015 at 12:07, Arturo Guadalupi notifications@github.com
wrote:

Feel free to improve the examples and any related things as you wish ;)


Reply to this email directly or view it on GitHub
#3 (comment)
.

Regards,

Gabriel Notman

Software Developer at SODAQ

If our environment could speak, what would it say?

Start connecting devices everywhere.

www.sodaq.com

@agdl
Copy link
Member

agdl commented Nov 18, 2015

I don't know it depends on how you want to resolve them!

@GabrielNotman
Copy link
Contributor Author

I've removed the conflicts and you should be able to merge it now.

A few notes:
I have removed the assertion of the CLKREP bit of the CTRL register.
It should be 0 for 24 hour mode. See page 245 of the SAMD21 datasheet.
You can test this using the SimpleRTC and an initial time of 12:59.

Should the standbyMode() method be part of this clock class?

@GabrielNotman GabrielNotman changed the title Added AM/PM and Epoch Support Added Epoch Support Nov 23, 2015
@GabrielNotman
Copy link
Contributor Author

Any update on when this pull request might be processed?

This will return false even if the USB is connected. It only
returns true if the COM port has been opened.
agdl added a commit that referenced this pull request Dec 30, 2015
@agdl agdl merged commit dc2a33f into arduino-libraries:master Dec 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants