![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
a
Dependencies: CheckRTC mbed mbed
main.cpp@0:e99d6df2cc36, 2015-08-13 (annotated)
- Committer:
- jhon309
- Date:
- Thu Aug 13 00:21:23 2015 +0000
- Revision:
- 0:e99d6df2cc36
.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhon309 | 0:e99d6df2cc36 | 1 | /// Include --------------------------------------------------------------------------------------- |
jhon309 | 0:e99d6df2cc36 | 2 | #include "mbed.h" |
jhon309 | 0:e99d6df2cc36 | 3 | |
jhon309 | 0:e99d6df2cc36 | 4 | #include "CheckRTC.h" |
jhon309 | 0:e99d6df2cc36 | 5 | |
jhon309 | 0:e99d6df2cc36 | 6 | // Object ---------------------------------------------------------------------------------------- |
jhon309 | 0:e99d6df2cc36 | 7 | Serial pc(SERIAL_TX, SERIAL_RX); |
jhon309 | 0:e99d6df2cc36 | 8 | DigitalOut myled1(LED1); // Assign LED1 output port |
jhon309 | 0:e99d6df2cc36 | 9 | |
jhon309 | 0:e99d6df2cc36 | 10 | |
jhon309 | 0:e99d6df2cc36 | 11 | |
jhon309 | 0:e99d6df2cc36 | 12 | // Function prototypes --------------------------------------------------------------------------- |
jhon309 | 0:e99d6df2cc36 | 13 | |
jhon309 | 0:e99d6df2cc36 | 14 | // Definition ------------------------------------------------------------------------------------ |
jhon309 | 0:e99d6df2cc36 | 15 | |
jhon309 | 0:e99d6df2cc36 | 16 | |
jhon309 | 0:e99d6df2cc36 | 17 | //------------------------------------------------------------------------------------------------- |
jhon309 | 0:e99d6df2cc36 | 18 | // Control Program |
jhon309 | 0:e99d6df2cc36 | 19 | //------------------------------------------------------------------------------------------------- |
jhon309 | 0:e99d6df2cc36 | 20 | |
jhon309 | 0:e99d6df2cc36 | 21 | |
jhon309 | 0:e99d6df2cc36 | 22 | int main() |
jhon309 | 0:e99d6df2cc36 | 23 | { |
jhon309 | 0:e99d6df2cc36 | 24 | |
jhon309 | 0:e99d6df2cc36 | 25 | time_t seconds; |
jhon309 | 0:e99d6df2cc36 | 26 | char buf[64]; |
jhon309 | 0:e99d6df2cc36 | 27 | struct tm t; |
jhon309 | 0:e99d6df2cc36 | 28 | |
jhon309 | 0:e99d6df2cc36 | 29 | t.tm_year = 15 + 100; |
jhon309 | 0:e99d6df2cc36 | 30 | t.tm_mon = 7 - 1; |
jhon309 | 0:e99d6df2cc36 | 31 | t.tm_mday = 29; |
jhon309 | 0:e99d6df2cc36 | 32 | t.tm_hour = 23; |
jhon309 | 0:e99d6df2cc36 | 33 | t.tm_min = 57; |
jhon309 | 0:e99d6df2cc36 | 34 | t.tm_sec = 00; |
jhon309 | 0:e99d6df2cc36 | 35 | seconds = mktime(&t); |
jhon309 | 0:e99d6df2cc36 | 36 | set_time(seconds); |
jhon309 | 0:e99d6df2cc36 | 37 | |
jhon309 | 0:e99d6df2cc36 | 38 | |
jhon309 | 0:e99d6df2cc36 | 39 | for (;;) { |
jhon309 | 0:e99d6df2cc36 | 40 | seconds = time(NULL); |
jhon309 | 0:e99d6df2cc36 | 41 | strftime(buf,40, "%I:%M:%S %p (%Y/%m/%d)", localtime(&seconds)); |
jhon309 | 0:e99d6df2cc36 | 42 | wait(1); |
jhon309 | 0:e99d6df2cc36 | 43 | myled1 =! myled1; |
jhon309 | 0:e99d6df2cc36 | 44 | pc.printf("%s\r\n",buf); |
jhon309 | 0:e99d6df2cc36 | 45 | } |
jhon309 | 0:e99d6df2cc36 | 46 | |
jhon309 | 0:e99d6df2cc36 | 47 | |
jhon309 | 0:e99d6df2cc36 | 48 | } |