Pseudo real-time clock using Ticker interruption, also implements time() and set_time() for platforms that don't (such as mBuino)
Fork of PseudoRTC by
Diff: PseudoRTC.h
- Revision:
- 3:c8bfeb8a2989
- Parent:
- 2:7d153bc7403f
diff -r 7d153bc7403f -r c8bfeb8a2989 PseudoRTC.h --- a/PseudoRTC.h Mon Aug 03 09:04:48 2015 +0000 +++ b/PseudoRTC.h Mon Aug 03 10:29:25 2015 +0000 @@ -30,9 +30,17 @@ * * main() * { - * // Example: September 20, 2014, 21:05:30 - * c.setTime(2014, 09, 20, 21, 05, 30); - * + * time_t seconds; + * char buffer[32]; + * c.set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37 (NOW WORKING ON mBuino) + * + * seconds=c.time(NULL); + * printf("Time as seconds since January 1, 1970 = %d\r\n", seconds); + * printf("Time as a basic string = %s\r", ctime(&seconds)); // ctime includes \n + * strftime(buffer, 32, "%I:%M %p", localtime(&seconds)); + * printf("Time as a custom formatted string = %s\r\n", buffer); + * + * c.setTime(2014, 09, 20, 21, 05, 30); // Second example: September 20, 2014, 21:05:30 * while(true) { * printf("%04d/%02d/%02d %02d:%02d:%02d\r\m", c.getYear(), c.getMonth(), c.getDay(), c.getHour(), c.getMinute(), c.getSecond()); * wait(1); @@ -51,11 +59,11 @@ /** Set time in the pseudo real-time clock * @param y Year - * @param mo Month - * @param d Day - * @param h Hour - * @param m Minute - * @param s Second + * @param mo Month (1-12) + * @param d Day (1-31) + * @param h Hour (0-23) + * @param m Minute (0-59) + * @param s Second (0-59) */ void setTime(int y, int mo, int d, int h, int mi, int s);