
Demo for the Clock library (real time clock driven by a Ticker).
Revision 3:0a77d653f8a6, committed 2015-11-30
- Comitter:
- hudakz
- Date:
- Mon Nov 30 11:36:44 2015 +0000
- Parent:
- 2:0fcd1b86588b
- Child:
- 4:abbab29cf5c1
- Commit message:
- Updated.
Changed in this revision
Clock.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Clock.lib Sun Nov 29 19:51:16 2015 +0000 +++ b/Clock.lib Mon Nov 30 11:36:44 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/hudakz/code/Clock/#a18375196723 +http://developer.mbed.org/users/hudakz/code/Clock/#58f5afbd24cd
--- a/main.cpp Sun Nov 29 19:51:16 2015 +0000 +++ b/main.cpp Mon Nov 30 11:36:44 2015 +0000 @@ -30,7 +30,12 @@ ticked = true; } - +/** + * @brief Main + * @note + * @param + * @retval + */ int main() { rtc.attach(&onClockTick); // attach a handler function to the rtc's tick event @@ -44,8 +49,8 @@ ticked = false; // clear the flag for next use // In your application you can - // draw clock hands on a graphical display here - // or update digital display etc. + // draw clock hands on a graphical display + // or update digital display or etc. // ... // In this demo we just print some info .. // @@ -63,7 +68,7 @@ pc.printf("Time as a custom formatted string = %s\r\n", buffer); // - // Design your own format: + // Create your own format: // pc.printf("Date: %.4d-%.2d-%.2d\r\n", rtc.year(), rtc.mon(), rtc.mday()); pc.printf("Time: %.2d:%.2d:%.2d\r\n", rtc.hour(), rtc.min(), rtc.sec()); @@ -72,20 +77,28 @@ // Perform periodical tasks: // if(rtc.sec() % 10 == 0) { - pc.printf("\r\n Called each 10 seconds\r\n\r\n"); + pc.printf("\r\n Called once per 10 seconds\r\n\r\n"); } if(rtc.sec() == 0) { - pc.printf("\r\n Called each minute.\r\n\r\n"); + pc.printf("\r\n Called once per minute.\r\n\r\n"); if(rtc.min() % 5 == 0) - pc.printf("\r\n Called each 5 minutes\r\n"); + pc.printf("\r\n Called once per 5 minutes\r\n"); + + if(rtc.min() == 0) { + pc.printf("\r\n Called once per hour\r\n"); + + if(rtc.hour() % 3 == 0) + pc.printf("\r\n Called once per 3 hours\r\n"); - if(rtc.min() == 0) - pc.printf("\r\n Called each hour\r\n"); - - if(rtc.hour() == 0) - pc.printf("\r\n Called at midnight\r\n"); + if(rtc.hour() == 0) { + pc.printf("\r\n Called at midnight\r\n"); + + if(rtc.wday() == 3) + pc.printf("\r\n Called on Wednesday at midnight\r\n"); + } + } } // @@ -101,3 +114,4 @@ } } } +