Software implemented real time clock driven by a Ticker. No external hardware (like DS1307 or DS3231 or etc.) is needed. Should work on any mbed platform where Ticker works.
See demo:
Import programClock_Hello
Demo for the Clock library (real time clock driven by a Ticker).
Diff: Clock.cpp
- Revision:
- 4:bbe7d7474acd
- Parent:
- 3:58f5afbd24cd
- Child:
- 5:d65fc7060635
--- a/Clock.cpp Mon Nov 30 11:36:09 2015 +0000 +++ b/Clock.cpp Fri Apr 01 07:23:02 2016 +0000 @@ -4,10 +4,10 @@ Created on: Mar 24, 2015 Author: Zoltan Hudak - This is a software implemented Clock. - No external parts are needed. + This is a software implemented Real Time Clock driven by a Ticker. + No external parts (like DS1307 or DS3231 or etc.) are needed. - For how to use it have a look at <http://developer.mbed.org/users/hudakz/code/Hello_Clock/> + See demo <http://developer.mbed.org/users/hudakz/code/Clock_Hello/> Copyright (c) 2015 Zoltan Hudak <hudakz@inbox.com> All rights reserved. @@ -93,7 +93,7 @@ _time = mktime(&_tm); // convert to seconds elapsed since January 1, 1970 set_time(_time); // set time - _ticker.attach(&tick, 1.0); // renew ticks + _ticker.attach(&tick, 1.0); // resume ticks } /** @@ -105,7 +105,7 @@ void Clock::set(tm& val) { _ticker.detach(); // suspend ticks _tm = val; - _ticker.attach(&tick, 1.0); // renew ticks + _ticker.attach(&tick, 1.0); // resume ticks } /** @@ -118,7 +118,7 @@ _ticker.detach(); // suspend ticks _time = val; _tm = *::localtime(&_time); - _ticker.attach(&tick, 1.0); // renew ticks + _ticker.attach(&tick, 1.0); // resume ticks } /**