lcd clock
Dependencies: NTPClient_NetServices mbed 4DGL-uLCD-SE EthernetNetIf
Diff: Internet_LCD_Clock.cpp
- Revision:
- 1:9da7a9089f12
- Parent:
- 0:da7f4b6d2b7c
diff -r da7f4b6d2b7c -r 9da7a9089f12 Internet_LCD_Clock.cpp --- a/Internet_LCD_Clock.cpp Fri May 25 00:41:26 2012 +0000 +++ b/Internet_LCD_Clock.cpp Thu Feb 06 21:29:35 2020 +0000 @@ -1,37 +1,31 @@ #include "mbed.h" #include "EthernetNetIf.h" #include "NTPClient.h" -#include "NokiaLCD.h" +#include "uLCD_4DGL.h" // Internet of Things clock example: LCD time is set via internet NTP time server EthernetNetIf eth; NTPClient ntp; -NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type +uLCD_4DGL lcd(p28,p27,p30); // mosi, sclk, cs, rst, type int main() { //system time structure time_t ctTime; char *time_str; //clear LCD - lcd.cls(); - lcd.locate(0,2); // lcd.printf prints to LCD display; lcd.printf("Get IP addr..."); EthernetErr ethErr = eth.setup(); //Get an Internet IP address using DHCP if (ethErr) { //error or timeout getting an IP address - lcd.cls(); - lcd.locate(0,2); lcd.printf("Net Error %d",ethErr); return -1; } - lcd.locate(0,3); lcd.printf("Reading Time..."); //specify time server URL - Host server(IpAddr(), 123, "0.uk.pool.ntp.org"); + Host server(IpAddr(), 123, "0.north-america.pool.ntp.org"); //Read time from server ntp.setTime(server); - lcd.locate(0,4); lcd.printf("Time set"); //Delay for human time to read LCD display wait(1); @@ -39,9 +33,7 @@ // loop and periodically update the LCD's time display lcd.cls(); ctTime = time(NULL); - lcd.locate(0,1); lcd.printf("UTC:"); - lcd.locate(0,3); time_str = ctime(&ctTime); time_str[strlen(time_str)-1] = 0; lcd.printf("%s", time_str);