2017/07/03
Dependencies: NTPClient kt_vfd_20170703
Fork of NTPClient_example by
Diff: main.cpp
- Revision:
- 1:811f6ec3c263
- Parent:
- 0:5b52498d3019
--- 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) ; + } }