private static void Button_OnInterrupt(uint data1, uint data2, DateTime time)
time, does equate to 1/1/2009 and the time since the Netduino was powered up (perhaps reset).
How can the date and time be set?
  | ||||||||||||||
Real Time Clock
Started by Joe Griffith, Sep 06 2010 06:07 PM
11 replies to this topic
#1Posted 06 September 2010 - 06:07 PM
The standard handler for the button pushed includes a time-stamp:
private static void Button_OnInterrupt(uint data1, uint data2, DateTime time) time, does equate to 1/1/2009 and the time since the Netduino was powered up (perhaps reset). How can the date and time be set? #2Posted 06 September 2010 - 06:18 PM
Great question. I haven't played with this myself, but I believe you use the Utility.SetLocalTime function.
Does that work for you? If not, I can pull together a sample... If you're using an external battery-backed RTC, it's really useful to set the .NET MF's time clock when your Netduino app starts up. Chris #3Posted 06 September 2010 - 06:21 PM Utility.SetLocalTime(...) affects the time passed to interrupt handlers. Edit: Too late. Hard to beat Chris. Edited by CW2, 06 September 2010 - 06:22 PM. #4Posted 06 September 2010 - 06:44 PM
Utility.SetLocalTime does the job!
I'm running with the Netduino connected to a computer so I can just send the datetime over from the computer.
Can't see any way to get at the local time other than as a parameter on an interupt handler.
#5Posted 06 September 2010 - 06:45 PM
Does DateTime.Now give you the local time? #6Posted 06 September 2010 - 07:37 PM
Yes DateTime.Now works as does DateTime.Today
#7Posted 06 September 2010 - 10:30 PM
It doesn't persist between loading apps though. #8Posted 06 September 2010 - 10:32 PM
True. Perhaps it persists when using SoftReboot (v4.1.0.3 beta) vs. HardReboot (v4.1.1 alpha 1) firmware... Which one are you using? Maybe that's a good reason to enable the user to configure their Netduino for SoftReboot vs. HardReboot... Chris #9Posted 07 September 2010 - 12:04 AM
And of course, if you're using the DS1307, check out my post w/code here: DS1307 Real Time Clock.
This clock is pretty inexpensive and works well. I'm sure that there are better ones out there with alarms, etc. #10Posted 03 May 2011 - 12:19 AM
I know this is a late thread to pull up, but I'm having a heck of a time figuring this out.
I want to call Utility.SetLocalTime during my debug sessions as I'm powering everything from usb through PC right now.
How on earth do I SetLocalTime using the PC time in a debug session?
Is it even possible?
I've got a DS1307 on order, so that will alleviate the problem, but in the mean time....I'd really like to figure this out.
Cheers,
#11Posted 03 May 2011 - 01:10 AM
Hi,
The .NET Micro Framework on your Netduino doesn't pull the time from your PC. If you have a comm channel between them, you could push it over manually--or you could retrieve it off the Internet if you're using a Netduino Plus.
Of course, adding an external RTC solves all that...you'd just set the time once and be good to go.
Chris
#12Posted 03 May 2011 - 11:34 AM Ah, ok. Thanks. the RTC I ordered should arrive in the next couple days. 0 user(s) are reading this topic0 members, 0 guests, 0 anonymous users | ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||