I made the digital watch which set the start time in ntp. It\'s same as \"clock\" see:[http://mbed.org/users/jf1vrr/programs/clock/lpucqk] except that I changed from unix timezone to ntp. See: http://blogs.yahoo.co.jp/jf1vrr_station/19816010.html (Japanese)

Dependencies:   EthernetNetIf NTPClient_NetServices TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
jf1vrr
Date:
Tue Apr 19 10:18:26 2011 +0000
Commit message:
Rev. 0.01A 2011/04/19

Changed in this revision

EthernetNetIf.lib Show annotated file Show diff for this revision Revisions of this file
NTPClient.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetNetIf.lib	Tue Apr 19 10:18:26 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NTPClient.lib	Tue Apr 19 10:18:26 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/NTPClient/#7c3f1199256a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Tue Apr 19 10:18:26 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	Tue Apr 19 10:18:26 2011 +0000
@@ -0,0 +1,48 @@
+/* I made the digital watch which set the start time in ntp. 
+It's same as "clock" see:[http://mbed.org/users/jf1vrr/programs/clock/lpucqk] 
+except that I changed from unix timezone to ntp.
+*/
+#include "mbed.h"
+#include "TextLCD.h"
+#include "EthernetNetIf.h"
+#include "NTPClient.h"
+
+TextLCD lcd(p24, p26, p27, p28, p29, p30);
+EthernetNetIf eth; 
+NTPClient ntp;
+
+int offset_JAPAN = 32400;
+
+int main() {
+    /* Set up Ethernet */
+    lcd.cls();
+    lcd.printf("Setting up Eth\n");
+    EthernetErr ethErr = eth.setup();
+    if (ethErr) {
+        lcd.cls();
+        lcd.printf("Error with Eth\nNum: %d", ethErr);
+        return -1;
+    }   
+    
+    /* Set up NTP */
+    lcd.printf("Setting up NTP\n");
+    Host server(IpAddr(), 123, "ntp1.jst.mfeed.ad.jp");
+    ntp.setTime(server);
+    
+    lcd.cls();    
+    while(1) {
+        time_t seconds = time(NULL)+offset_JAPAN;
+
+        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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Apr 19 10:18:26 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912