using System; using System.Threading; using Microsoft.SPOT; using GHI.Processor; using System.Text; using Microsoft.SPOT.Hardware; namespace IMULogger { public class Real_Time_Clock { // Create stringbuilder to save data and time private static StringBuilder sbDateTime = new StringBuilder(500); // create object to read date and time from RTC private static DateTime timeNow; //---------------------------------------------------------------------------------------------------- // Setup the RTC //---------------------------------------------------------------------------------------------------- public static void setupRTC() { //DateTime DT; try { // Read the RTC timeNow = RealTimeClock.GetDateTime(); Debug.Print("Current Real-time Clock " + timeNow.ToString()); } catch // If the time is not invalid, like day of the month is 40! { Debug.Print("Bad time exception"); } Utility.SetLocalTime(RealTimeClock.GetDateTime()); Debug.Print("Time is now: " + DateTime.Now); } //---------------------------------------------------------------------------------------------------- // Read the RTC //---------------------------------------------------------------------------------------------------- public static StringBuilder readClock() { timeNow = DateTime.Now; sbDateTime.Clear(); sbDateTime.Append(timeNow.ToString("dd-MMM-yyyy")); sbDateTime.Append("\t"); sbDateTime.Append(timeNow.ToString("HH:mm:ss.fff")); //Debug.Print(sbWrite.ToString()); //Debug.Print(sbWrite.Length.ToString()); return (sbDateTime); } } }