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:
11:49b987f6ae26
Parent:
10:e5eabd3a1ca6
Child:
12:9e7a91c34083
diff -r e5eabd3a1ca6 -r 49b987f6ae26 RTclock.cpp
--- a/RTclock.cpp	Tue Sep 02 07:12:09 2014 +0000
+++ b/RTclock.cpp	Tue Sep 02 08:11:26 2014 +0000
@@ -72,11 +72,9 @@
     return true;
 }
 
-bool RTclock::read(int in_nAddress, char * out_pBuffer, int in_nLength)
+bool RTclock::read(uint8_t in_nAddress, char * out_pBuffer, int in_nLength)
 {
-    char aBuffer[2] = { (char)in_nAddress, 0 };
-    
-    if (0 != m_cI2C.write(0xd0, aBuffer, 1)) return false;
+    if (0 != m_cI2C.write(0xd0, (char *)&in_nAddress, size_t(in_nAddress))) return false;
     if (0 != m_cI2C.read(0xd0, out_pBuffer, in_nLength)) return false;
     
     return true;
@@ -189,7 +187,7 @@
     return write(7, &nValue, 1);
 }
 
-bool RTclock::write(int in_nAddress, const char * in_pBuffer, int in_nLength)
+bool RTclock::write(uint8_t in_nAddress, const char * in_pBuffer, int in_nLength)
 {    
     char aBuffer[10];