.

Dependencies:   SDHCFileSystem mbed

Revision:
14:ed5d2a503374
Parent:
13:544b15b00c2d
Child:
15:3ff21ce810da
--- a/main.cpp	Sun Dec 16 00:25:57 2012 +0000
+++ b/main.cpp	Sun Dec 16 16:13:22 2012 +0000
@@ -220,22 +220,17 @@
     
     timer.start() ;
     RTC_Init(); // start the RTC Interrupts that sync the timer
-    wait(1.1);  // give time to sync
- 
-    //--------------------------
-    // check for 2012 or later
 
     struct tm t; // pointer to a static tm structure
 
     seconds = time(NULL);
     t = *localtime(&seconds) ;
+    strftime(sTemp, 32, "%a %m/%d/%Y %X", &t);
+    pc.printf("\nCurrent time set to:  %s\n", sTemp); // DAY MM/DD/YYYY HH:MM:SS
+    wait(1.1);  // give time to sync
+    
+    if (PB1==0) { //set time if pb pressed
 
-    // is it a date before 2012 ?
-    if ((t.tm_year + 1900) < 2012 ) {
-        // before 2012, so the RTC probably lost power
-        // So, set a near-recent date in 2012
-
-        // enter people-values here
         pc.printf("\nEnter year (yyyy):");
         pc.scanf("%s", &sTemp);
         t.tm_year = atoi(sTemp);
@@ -259,13 +254,6 @@
         pc.printf("\nEnter seconds (ss):");
         pc.scanf("%2s", &sTemp);
         t.tm_sec = atoi(sTemp);
-        
-        //t.tm_year = 2012 ; // 28 May 2012
-        //t.tm_mon = 6 ; // 1 to 12
-        //t.tm_mday = 1;
-        //t.tm_hour = 12; // 12:59:56 PM (after noon)
-        //t.tm_min = 59;
-        //t.tm_sec = 56;
 
         // adjust for tm structure required values
         t.tm_year = t.tm_year - 1900;
@@ -275,7 +263,7 @@
         set_time(mktime(&t));
         seconds = time(NULL);
 
-        pc.printf("\n\mRTC set to:  " );
+        pc.printf("\nRTC set to:  " );
         strftime(sTemp, 32, "%a %m/%d/%Y %X", localtime(&seconds));
         pc.printf("%s\n", sTemp); // DAY MM/DD/YYYY HH:MM:SS
     }