I made a clock in mbed. mbed has RTC built-in. A convenient function is prepared for in the rtc_time function group of mbed.h. Because data are provided at the time when they give unix timestamp and ask it at suitable distance, a format to like it can be set and displays it to LCD. If unix timestamp is provided from web, it becomes more convenient. See: http://blogs.yahoo.co.jp/jf1vrr_station/19803647.html (Japanese)
Revision 0:11c4cf24f38b, committed 2011-04-18
- Comitter:
- jf1vrr
- Date:
- Mon Apr 18 05:58:23 2011 +0000
- Commit message:
- Rev. 0.01A 2011/04/18
Changed in this revision
diff -r 000000000000 -r 11c4cf24f38b TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Mon Apr 18 05:58:23 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
diff -r 000000000000 -r 11c4cf24f38b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 18 05:58:23 2011 +0000 @@ -0,0 +1,34 @@ +/* I made a clock in mbed. mbed has RTC built-in. +A convenient function is prepared for in the rtc_time +function group of mbed.h. Because data are provided +at the time when they give unix timestamp and ask it +at suitable distance, a format to like it can be set +and displays it to LCD. If unix timestamp is provided +from web, it becomes more convenient. +*/ +#include "mbed.h" +#include "TextLCD.h" + +TextLCD lcd(p24, p26, p27, p28, p29, p30); +int offset_JAPAN = 32400; + +int main() { + set_time(1303099200+offset_JAPAN); // Set RTC time to Mon, 18 Apr 2011 13:00:00 + + lcd.cls(); + while(1) { + time_t seconds = time(NULL); + + lcd.locate(0,0); + char day[16]; + strftime(day, 16, "%Y/%m/%d %a\n", localtime(&seconds)); + lcd.printf("%s", day); + + char time[16]; + strftime(time, 16, "%H:%M:%S\n", localtime(&seconds)); + lcd.locate(0,1); + lcd.printf("%s", time); + + wait(1.0); + } +}
diff -r 000000000000 -r 11c4cf24f38b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Apr 18 05:58:23 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912