It is a simple clock that used TextLCD and NTP Client.

Dependencies:   mbed NetEthApiLPC1768 NetServicesLPC1768

Files at this revision

API Documentation at this revision

Comitter:
nucho
Date:
Fri Jun 04 00:39:29 2010 +0000
Commit message:

Changed in this revision

NetEthApiLPC1768.lib Show annotated file Show diff for this revision Revisions of this file
NetServicesLPC1768.lib Show annotated file Show diff for this revision Revisions of this file
SimpleLCDClock.cpp 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
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/NetEthApiLPC1768.lib	Fri Jun 04 00:39:29 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/NetEthApiLPC1768/#2929fcb16bbf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NetServicesLPC1768.lib	Fri Jun 04 00:39:29 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/NetServicesLPC1768/#acb9b7d53771
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SimpleLCDClock.cpp	Fri Jun 04 00:39:29 2010 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "EthernetNetIf.h"
+#include "NtpClient.h"
+#include "TextLCD.h"
+
+TextLCD lcd(p6, p8, p13, p14, p15, p16); // rs, e, d0, d1, d2, d3
+
+EthernetNetIf eth;
+NtpClient ntp;
+
+int main() {
+    char buf[40];
+    printf("\r\nSetting up...\r\n");
+    lcd.printf("Setting up...\n");
+    EthernetErr ethErr = eth.setup();
+    if (ethErr) {
+        printf("Error %d in setup.\n", ethErr);
+        lcd.printf("Error %d in setup.\n", ethErr);
+        return -1;
+    }
+    printf("\r\nSetup OK\r\n");
+
+    time_t ctTime;
+    ctTime = time(NULL);
+
+    printf("\r\nCurrent time is : %s JST\r\n", ctime(&ctTime));
+    lcd.printf("Timer setting...\n");
+    Host server(IpAddr(), 123, "ntp.jst.mfeed.ad.jp");
+    ntp.setTime(server);
+
+    ctTime = time(NULL);
+    ctTime += 32400; //set jst time
+    strftime(buf,sizeof(buf), "%A %m/%d/%Y %H:%M:%S\n", localtime(&ctTime));
+    printf("\r\nTime is now : %s JST\r\n", buf);
+
+    while (1) {
+        lcd.cls();
+        ctTime = time(NULL);
+        ctTime += 32400;
+        strftime(buf,sizeof(buf), "%Y/%m/%d %a \n%H:%M:%S", localtime(&ctTime));
+        printf("%s\n", buf);
+        lcd.printf("%s", buf);
+
+        wait(1);
+    }
+
+    return 0;
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Fri Jun 04 00:39:29 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jun 04 00:39:29 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e6be4cd80aad