Starboard Orangeで使用することを想定したHTTPから時刻を取得して表示するプログラムです。
Dependencies: TextLCD mbed lwip
Revision 0:4c1d230c9eac, committed 2010-12-30
- Comitter:
- Nardi
- Date:
- Thu Dec 30 11:58:35 2010 +0000
- Commit message:
- 1.0
Changed in this revision
diff -r 000000000000 -r 4c1d230c9eac HTTPClient.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPClient.lib Thu Dec 30 11:58:35 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_unsupported/code/lwip/ \ No newline at end of file
diff -r 000000000000 -r 4c1d230c9eac RTCsetwithHttpClient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RTCsetwithHttpClient.cpp Thu Dec 30 11:58:35 2010 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" +#include "HTTPClient.h" +#include "TextLCD.h" + +TextLCD lcd(p24,p26,p27,p28,p29,p30); // rs, e, d4-d7 + +#define PAGE_SIZE 77 + +HTTPClient http; + +int main(void) { + char result[PAGE_SIZE+1]; + char buf[40]; + char *e; + + time_t seconds; + + http.get("http://ntp-a1.nict.go.jp/cgi-bin/ntp", result,PAGE_SIZE); + result[PAGE_SIZE]='\0'; + + + int start_body=strstr(result,"<BODY>")-result+7; + int end_body = strstr(result,"</BODY>")-result-1; + strncpy(buf, result+start_body, end_body-start_body); + buf[end_body-start_body]='\0'; + + seconds = strtoul(buf,&e,10)-2208988800UL; + seconds += 32400;//JST TIME + set_time(seconds); + + // Work is done! + while (1) { + seconds = time(NULL); + strftime(buf,sizeof(buf),"%Y/%m/%d %a\n%H:%M:%S", localtime(&seconds)); + lcd.printf("%s\n", buf); + wait(1); + } +} +
diff -r 000000000000 -r 4c1d230c9eac TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Thu Dec 30 11:58:35 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#e4cb7ddee0d3
diff -r 000000000000 -r 4c1d230c9eac mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Dec 30 11:58:35 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/029aa53d7323