Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WiFi.h>
- #include <NTPClient.h>
- #include <WiFiUdp.h>
- #include <TFT_eSPI.h>
- #include <SPI.h>
- #define TFT_BL 4 // Dispaly backlight control pin
- // Replace with your network credentials
- const char* ssid = "";
- const char* password = "";
- WiFiUDP ntpUDP;
- NTPClient timeClient(ntpUDP);
- TFT_eSPI tft = TFT_eSPI();
- void setup() {
- if (TFT_BL > 0) {
- pinMode(TFT_BL, OUTPUT);
- digitalWrite(TFT_BL, HIGH);
- }
- tft.init();
- tft.setRotation(1);
- tft.fillScreen(TFT_BLACK);
- tft.setTextColor(TFT_YELLOW, TFT_BLACK); // Note: the new fonts do not draw the background colour
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- }
- timeClient.begin();
- timeClient.setTimeOffset(3600);
- }
- void loop() {
- while(!timeClient.update()) {
- timeClient.forceUpdate();
- }
- char timeString[25];
- sprintf (timeString, "%i:%i:%i", timeClient.getHours (), timeClient.getMinutes (), timeClient.getSeconds ());
- tft.setTextColor(0x39C4, TFT_BLACK); // Leave a 7 segment ghost image, comment out next line!
- tft.drawString("88:88:88",10,10,7); // Overwrite the text to clear it
- tft.setTextColor(0xFBE0, TFT_BLACK); // Orange
- tft.drawString (timeString, 10, 10, 7);
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement