Simple RTC class based on DS1307. Emphasis on simple. Allows you to run at 100k or 400k Hz (for newer DS1307 capable devices). MapTime() allows you to set the time() service to the same as the RTC. Uses struct tm throughout so you can use traditional time functions for manipulation.

Dependents:   AdaFruit_RGBLCD

Revision:
4:04a51e4dbf4c
Parent:
3:ed1628b05d37
Child:
5:d71d6e5a7eee
--- a/RTclock.cpp	Sat Aug 09 09:59:38 2014 +0000
+++ b/RTclock.cpp	Sat Aug 09 11:46:08 2014 +0000
@@ -32,14 +32,15 @@
     if (!read(0, aBuffer, 7)) return false;
 
     b12hour = ((aBuffer[2] & 64) == 64);
+    
     out_sTM.tm_sec = BcdToDecimal(aBuffer[0] & 0x7F);
     out_sTM.tm_min = BcdToDecimal(aBuffer[1]);
     
     if (b12hour)
     {
-        // add 12 hours if PM bit is set
+        // remove 12 hours if PM bit is set and past midday
         out_sTM.tm_hour = BcdToDecimal(aBuffer[2] & 31);
-        if (aBuffer[2] & 32) out_sTM.tm_hour += 12;
+        if ((aBuffer[2] & 32) && out_sTM.tm_hour > 12) out_sTM.tm_hour -= 12;
     }
     else
     {