33行のNTPサーバは変更する必要あり?
Dependencies: TextLCD mbed NetServicesSource
Revision 0:19a5ef7a79e8, committed 2011-07-18
- Comitter:
- yueee_yt
- Date:
- Mon Jul 18 10:37:23 2011 +0000
- Commit message:
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NetServicesSource.lib Mon Jul 18 10:37:23 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/NetServicesSource/#da4498f591ee
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Mon Jul 18 10:37:23 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jul 18 10:37:23 2011 +0000 @@ -0,0 +1,53 @@ +#include "mbed.h" +#include "EthernetNetIf.h" +#include "NTPClient.h" +#include "TextLCD.h" + +EthernetNetIf ethif; //for DHCP +//EthernetNetIf ethif(IpAddr(xxx,xxx,xxx,xxx), IpAddr(xxx,xxx,xxx,xxx), IpAddr(xxx,xxx,xxx,xxx), IpAddr(xxx,xxx,xxx,xxx)); //for Static IP Address + +NTPClient ntp; +TextLCD lcd(p24, p26, p27, p28, p29, p30); + +int main() { + char buffer[17]; + lcd.locate(0,1); + lcd.printf("Start\n"); + lcd.locate(0,1); + lcd.printf("Setting up...\n"); + EthernetErr ethErr = ethif.setup(); + if (ethErr) { + lcd.locate(0,1); + lcd.printf("Error %d in setup.\n", ethErr); + return -1; + } + lcd.locate(0,1); + lcd.printf("Setup OK\r\n"); + IpAddr ethIp=ethif.getIp(); + lcd.locate(0,1); + lcd.printf("%d.%d.%d.%d", ethIp[0], ethIp[1], ethIp[2], ethIp[3]); + wait(1.0f); + + time_t ctTime; + + Host server(IpAddr(), 123, "ntp.nict.jp"); //near ntp server + ntp.setTime(server); +//UTC-->JST +9Hour(32400Sec) + ctTime = time(NULL); + ctTime+=32400; + set_time(ctTime); + + lcd.cls(); + while (1) { + lcd.locate(0,0); + ctTime = time(NULL); + lcd.locate(0,0); + strftime(buffer,17,"%Y/%m/%d(%a)",localtime(&ctTime)); + lcd.printf("%s",buffer); + lcd.locate(0,1); + strftime(buffer,17,"%X",localtime(&ctTime)); + lcd.printf("%s",buffer); + wait(1.0f); + } + return 0; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jul 18 10:37:23 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912