2017/07/03

Dependencies:   NTPClient kt_vfd_20170703

Fork of NTPClient_example by Chronos .

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "NTPClient.h"
00003 #include "EthernetInterface.h"
00004 #include "kt_vfd.h"
00005 
00006 // GU140X16G-7040
00007 KT_VFD vfd(p15, p16, p17, p18, p19, p20, p21, p22, p23, p24) ;
00008 
00009 int main()
00010 {
00011     EthernetInterface eth ;
00012 
00013     vfd.printf("Setting up...\n") ;
00014     int ethError = eth.connect() ;
00015 
00016     if(ethError != 0) {
00017         vfd.printf("Connect failed (%d)", ethError) ;
00018         eth.disconnect() ;
00019         return 0 ;
00020     }
00021 
00022     NTPClient ntp(eth) ;
00023     vfd.cls() ;
00024     vfd.printf("Connect success\n", ethError) ;
00025     vfd.printf("IP: %s", eth.get_ip_address()) ;
00026     time_t ctTime ;
00027     wait(5) ;
00028     vfd.cls() ;
00029     while(1) {
00030         ntp.setTime("ntp.nict.jp") ;
00031         ctTime = time(NULL) + (60 * 60 * 9) ; // JST
00032         char buffer[64] ;
00033         strftime(buffer, 64, "  %a %d %b %Y\n   %H:%M:%S (JST)", localtime(&ctTime)) ;
00034         vfd.printf("%s\n", buffer) ;
00035     }
00036 }