Class library for the Dallas Semiconductor DS1307 RTC Basic Functionality, read and set RTC

Revision:
2:a9a0784930bd
Parent:
1:95a90bac5d6d
--- a/DS1307_RTC.cpp	Sat Nov 01 14:05:25 2014 +0000
+++ b/DS1307_RTC.cpp	Sat Nov 01 14:56:37 2014 +0000
@@ -9,9 +9,10 @@
 {
     _i2c.frequency(400000);
     
-//    *Day[] = {"","Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
-//    *Mon[] = {"","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
+/*    Day[] = {"","Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
+    Mon[] = {"","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};*/
   
+  /*
     Day[0] = "";
     Day[1] = "Sun";
     Day[2] = "Mon";
@@ -34,6 +35,7 @@
     Mon[10] = "Oct";
     Mon[11] = "Nov";
     Mon[12] = "Dec";
+    */
        
     rtc_sec = 0;
     rtc_minute = 0;
@@ -138,10 +140,15 @@
     rtc_minute = unbcd(RTC_read_reg(1));
     rtc_hours = unbcd(RTC_read_reg(2));
     rtc_day = unbcd(RTC_read_reg(3));
+    if(rtc_day > 7)
+        rtc_day = 0;
     rtc_date = unbcd(RTC_read_reg(4));
     rtc_month = unbcd(RTC_read_reg(5));
+    if(rtc_month > 12)
+        rtc_month = 0;
     rtc_year = unbcd(RTC_read_reg(6)) + YEAR_OFFSET;
     
-    sprintf(str, "%2d:%02d:%02d %s %s %d %d", rtc_hours,rtc_minute,rtc_sec,Day[rtc_day],Mon[rtc_month], rtc_date, rtc_year);
+    sprintf(str, "%2d:%02d:%02d", rtc_hours,rtc_minute,rtc_sec);
+    //sprintf(str, "%2d:%02d:%02d %s %s %d %d", rtc_hours,rtc_minute,rtc_sec,Day[rtc_day],Mon[rtc_month], rtc_date, rtc_year);
     //pc.printf("%s", str);
 }