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:
- 2:7d153bc7403f
- Parent:
- 1:fb8fd750e935
- Child:
- 3:c8bfeb8a2989
--- a/PseudoRTC.h Sat Sep 20 14:25:38 2014 +0000 +++ b/PseudoRTC.h Mon Aug 03 09:04:48 2015 +0000 @@ -30,7 +30,7 @@ * * main() * { - * /* Example: September 20, 2014, 21:05:30 + * // Example: September 20, 2014, 21:05:30 * c.setTime(2014, 09, 20, 21, 05, 30); * * while(true) { @@ -59,6 +59,23 @@ */ void setTime(int y, int mo, int d, int h, int mi, int s); + /** Set the time using a unix timestamp value (the number of seconds since January 1, 1970) + * @param thetime unix time as time_t + */ + void set_time(time_t thetime); + + /** Get the unix timestamp value (the number of seconds since January 1, 1970) + * @param timer Pointer to the time_t variable + * @return time_t current timestamp + */ + time_t time(time_t *timer); + + /** add (or subtract) some seconds to the rtc to adjust time as needed + * @param nSec number of seconds to add or subtract + * @return time_t current timestamp + */ + time_t addSeconds(int nSec); + /** Get the year value */ int getYear(void); @@ -84,7 +101,9 @@ int hour; int minute; int second; + time_t unixtime; Ticker t; + time_t toUnixTime(void); void tictoc(void); };