2017/07/03

Dependencies:   NTPClient kt_vfd_20170703

Fork of NTPClient_example by Chronos .

Files at this revision

API Documentation at this revision

Comitter:
kojie
Date:
Mon Jul 03 14:16:32 2017 +0000
Parent:
0:5b52498d3019
Commit message:
2017/07/03

Changed in this revision

kt_vfd.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
diff -r 5b52498d3019 -r 811f6ec3c263 kt_vfd.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kt_vfd.lib	Mon Jul 03 14:16:32 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/kojie/code/kt_vfd_20170703/#94347d9bbcf4
diff -r 5b52498d3019 -r 811f6ec3c263 main.cpp
--- a/main.cpp	Fri Jan 06 13:51:45 2017 +0000
+++ b/main.cpp	Mon Jul 03 14:16:32 2017 +0000
@@ -1,33 +1,36 @@
 #include "mbed.h"
 #include "NTPClient.h"
 #include "EthernetInterface.h"
-  
-int main() {
+#include "kt_vfd.h"
+
+// GU140X16G-7040
+KT_VFD vfd(p15, p16, p17, p18, p19, p20, p21, p22, p23, p24) ;
 
-  EthernetInterface eth;
+int main()
+{
+    EthernetInterface eth ;
+
+    vfd.printf("Setting up...\n") ;
+    int ethError = eth.connect() ;
 
-  printf("Setting up...\n");
-  
-  int ethError = eth.connect();
-    
-  if(ethError == 0)
-  {
-    NTPClient ntp(eth);
-    printf("ETH is up : %s\n", eth.get_ip_address());
-    time_t ctTime;
-    ctTime = time(NULL);  
-    printf("Current time is (UTC): %s\n", ctime(&ctTime));  
+    if(ethError != 0) {
+        vfd.printf("Connect failed (%d)", ethError) ;
+        eth.disconnect() ;
+        return 0 ;
+    }
 
-    ntp.setTime("0.uk.pool.ntp.org");
-    
-    ctTime = time(NULL);  
-    printf("\nTime is now (UTC): %s\n", ctime(&ctTime)); 
-  
-    eth.disconnect();
-  } else {
-      printf("Connect failed (%d)", ethError);
-  }
-  
-  return 0;
-  
+    NTPClient ntp(eth) ;
+    vfd.cls() ;
+    vfd.printf("Connect success\n", ethError) ;
+    vfd.printf("IP: %s", eth.get_ip_address()) ;
+    time_t ctTime ;
+    wait(5) ;
+    vfd.cls() ;
+    while(1) {
+        ntp.setTime("ntp.nict.jp") ;
+        ctTime = time(NULL) + (60 * 60 * 9) ; // JST
+        char buffer[64] ;
+        strftime(buffer, 64, "  %a %d %b %Y\n   %H:%M:%S (JST)", localtime(&ctTime)) ;
+        vfd.printf("%s\n", buffer) ;
+    }
 }