Va salut !
Fiindca o lunga perioada de timp am fost in concediu medical, dupa o afectiune oncologica ce a necesitat operatie, in timpul liber disponibil am lucrat la o serie de proiecte, care sa-mi tina mintea distrasa de la alte ganduri ...
Cu ajutorul AI (Vercel, Perplexity, Gemini, Qwen, Le Chat) am conceput si finalizat, dupa multe, multe incercari si aceasta statie meteo color. Functioneaza foarte bine, prietenul meu, Dragos, o are "activa" si e multumit de ea.
Nota : am experimentat cu datele meteo de pe toate siteurile care pun la dispozitie apiKey. Nu sunt doua la fel !! Exista mari variatii, in special in privinta temperaturii, dar, la unele siteuri, si la starea vremii propriu-zisa (afara era soare, senin si prognoza era innorat, sanse de ploaie :( ). Acesta este si motivul pentru care eu nu folosesc aceasta statie, prefer ceasul cu termometru (ce poate fi vazut tot aici, pe blog).
Cine doreste poate face statia, ideea este sa va obtineti propriul apiKey (google_it) si sa va setati locatia. Succes !
//Statie meteo cu ST7735
#include <SPI.h> #include <TimeLib.h> #include <ArduinoJson.h> #include <Adafruit_GFX.h> #include <Adafruit_ST7735.h> #include <ESP8266HTTPClient.h> #include <WiFiClient.h> #include <Arduino.h> #include <ESP8266WiFi.h> #include <time.h> #include "OpenWeatherMapCurrent.h" #include <WiFiUdp.h> #include <Fonts/FreeMonoBold12pt7b.h> #include <Fonts/FreeMono12pt7b.h> #include <Fonts/FreeSans9pt7b.h> #include <Fonts/FreeSans12pt7b.h> #include <Fonts/FreeSansBold18pt7b.h> #include <Fonts/FreeSansBold9pt7b.h>
OpenWeatherMapCurrent client;
#define TFT_CS D8
#define TFT_RST D4
#define TFT_DC D3
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
const char *ssid = "Andy_2.4G";
const char *password = "andy1603";
//const char *ssid = "your_ssid"; // SSID of local network
//const char *password = "your_psw"; // Password on network
const String apiKey = "a3df618d921a49aa8b8144948250802"; //creati-va propriul apiKey !!!
const String city = "Ploiesti";
/*
#define ST7735_BLACK 0x0000
#define ST7735_WHITE 0xFFFF
#define ST7735_RED 0xF800
#define ST7735_GREEN 0x07E0
#define ST7735_BLUE 0x001F
#define ST7735_CYAN 0x07FF
#define ST7735_MAGENTA 0xF81F
#define ST7735_YELLOW 0xFFE0
#define ST7735_ORANGE 0xFC00
*/
String dayName = "";
char daysOfTheWeek[7][12] = {"Duminica", "Luni", "Marti", "Miercuri", "Joi", "Vineri", "Sambata"};
// Variabile globale
String maine = "";
String desc = "";
float wind = 0.0;
float temp = 0.0;
int pres = 0;
int humidity = 0;
float pres_mmHg = 0.0;
int getD = -1;
int getH = -1;
int getM = -1;
int getS = -1;
String fDate = "";
unsigned long lastWeatherUpdate = 0;
const unsigned long WEATHER_UPDATE_INTERVAL = 300 * 1000; // 5 minute
unsigned long previousTimeUpdate = 0;
unsigned long previousScreenSwitch = 0;
const unsigned long timeUpdateInterval = 1000; // 1 secundă
const unsigned long screen1Duration = 40000; // 40 secunde
const unsigned long screen2Duration = 10000; // 10 secunde
const unsigned long ntpSyncInterval = 3600000; // 1 oră
unsigned long previousNtpSync = 0;
bool showingScreen1 = true;
const unsigned char thunder[] PROGMEM = {
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00111110,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000001,B11100011,B11000000,B00000000,B00000000,
B00000000,B00000000,B00000011,B00000000,B01100000,B00000000,B00000000,
B00000000,B00000000,B00000100,B00000000,B00110000,B00000000,B00000000,
B00000000,B00000000,B00001000,B00000000,B00011000,B00000000,B00000000,
B00000000,B00000000,B00010000,B00000000,B00001100,B00000000,B00000000,
B00000000,B00000000,B00110000,B00000000,B00000111,B11000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,B01100000,B00000000,
B00000000,B00001111,B11100000,B00000000,B00000000,B00010000,B00000000,
B00000000,B00011000,B00000000,B00000000,B00000000,B00011000,B00000000,
B00000000,B00100000,B00000000,B00000000,B00000000,B00001000,B00000000,
B00000000,B01100000,B00000000,B00000000,B00000000,B00001100,B00000000,
B00000000,B01000000,B00000000,B00000000,B00000000,B00001100,B00000000,
B00000000,B11000000,B00000000,B00000000,B00000000,B00001100,B00000000,
B00001111,B10000000,B00000000,B00000100,B00000000,B00001000,B00000000,
B00011000,B00000000,B00000000,B00000100,B00000000,B00001100,B00000000,
B00110000,B00000000,B00000000,B00001100,B00000000,B00000110,B00000000,
B00100000,B00000000,B00000000,B00001000,B00000000,B00000010,B00000000,
B01100000,B00000000,B00000000,B00011000,B00000000,B00000011,B00000000,
B01000000,B00000000,B00000000,B00010000,B00000000,B00000001,B00000000,
B01000000,B00000000,B00010000,B00110000,B00000000,B00000001,B00000000,
B01000000,B00000000,B00110000,B00100000,B00000000,B00000001,B00000000,
B01100000,B00000000,B00100000,B00100000,B00000000,B00000011,B00000000,
B00100000,B00000000,B01100000,B01111111,B10000000,B00000010,B00000000,
B00010000,B00000000,B01000000,B01111111,B10000000,B00000110,B00000000,
B00011100,B00000000,B01111000,B00000001,B00000000,B00011100,B00000000,
B00000111,B11111100,B00001000,B00000011,B00111111,B11110000,B00000000,
B00000000,B00000000,B00011000,B00000010,B00000000,B00000000,B00000000,
B00000000,B00000000,B00010000,B00000010,B00000000,B00000000,B00000000,
B00000000,B00000000,B00110000,B00000100,B00000000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000100,B00000000,B00000000,B00000000,
B00000000,B00000000,B01100000,B00001100,B00000000,B00000000,B00000000,
B00000000,B00000000,B01000000,B00001000,B00000000,B00000000,B00000000,
B00010000,B00000110,B00000000,B10000000,B00010000,B00000100,B00000000,
B00110000,B00000100,B00000001,B10000000,B00100000,B00000100,B00000000,
B00100000,B00001100,B00000001,B00000000,B00100000,B00001100,B00000000,
B01100000,B00001000,B00000001,B00000000,B01100000,B00001000,B00000000,
B01000000,B00001000,B00000011,B00000000,B01000000,B00011000,B00000000,
B01000000,B00000000,B00000010,B00000000,B01000000,B00010000,B00000000
};
const unsigned char drizzle[] PROGMEM = {
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01111111,B11000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B11100000,B11100000,B00000000,B00000000,
B00000000,B00000000,B00000011,B10000000,B00111000,B00000000,B00000000,
B00000000,B00000000,B00000110,B00000000,B00001100,B00000000,B00000000,
B00000000,B00000000,B00000100,B00000000,B00000110,B00000000,B00000000,
B00000000,B00000000,B00001100,B00000000,B00000010,B00000000,B00000000,
B00000000,B00000000,B00011000,B00000000,B00000011,B11100000,B00000000,
B00000000,B00000000,B00010000,B00000000,B00000001,B11111000,B00000000,
B00000000,B00000011,B11110000,B00000000,B00000000,B00001100,B00000000,
B00000000,B00001110,B01110000,B00000000,B00000000,B00000110,B00000000,
B00000000,B00011000,B00000000,B00000000,B00000000,B00000110,B00000000,
B00000000,B00100000,B00000000,B00000000,B00000000,B00000010,B00000000,
B00000000,B01100000,B00000000,B00000000,B00000000,B00000011,B00000000,
B00000000,B01000000,B00000000,B00000000,B00000000,B00000011,B00000000,
B00000000,B11000000,B00000000,B00000000,B00000000,B00000011,B00000000,
B00000111,B11000000,B00000000,B00000000,B00000000,B00000010,B00000000,
B00011100,B00000000,B00000000,B00000000,B00000000,B00000011,B00000000,
B00010000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000000,
B00100000,B00000000,B00000000,B00000000,B00000000,B00000001,B10000000,
B01100000,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000,
B01000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000,
B01000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01000000,
B01000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01000000,
B01000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01000000,
B01100000,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000,
B00100000,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000,
B00110000,B00000000,B00000000,B00000000,B00000000,B00000001,B10000000,
B00011000,B00000000,B00000000,B00000000,B00000000,B00000011,B00000000,
B00001110,B00000000,B00000000,B00000000,B00000000,B00001110,B00000000,
B00000111,B11111111,B11111111,B11111111,B11111111,B11111100,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B11000000,B00110000,B00001100,B00000011,B00000000,B00000000,
B00000000,B11000000,B00100000,B00001000,B00000010,B00000000,B00000000,
B00000000,B10000000,B00100000,B00011000,B00000110,B00000000,B00000000,
B00000001,B10000000,B01100000,B00010000,B00000100,B00000000,B00000000,
B00000001,B00000000,B01000000,B00110000,B00000100,B00000000,B00000000,
B00000001,B00000000,B01000000,B00110000,B00001100,B00000000,B00000000
};
const unsigned char rain[] PROGMEM = {
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B11111110,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000011,B00000001,B10001111,B11110000,B00000000,B00000000,
B00000000,B00000110,B00000000,B11110000,B00001100,B00000000,B00000000,
B00000000,B00001100,B00000000,B01000000,B00000110,B00000000,B00000000,
B00000000,B01111000,B00000000,B10000000,B00000011,B00000000,B00000000,
B00000001,B10000000,B00000001,B10000000,B00000001,B11100000,B00000000,
B00000001,B00000000,B00000001,B00000000,B00000000,B00011000,B00000000,
B00000001,B00000000,B01111111,B00000000,B00000000,B00001100,B00000000,
B00000001,B00000000,B11000000,B00000000,B00000000,B00000110,B00000000,
B00000001,B00000001,B10000000,B00000000,B00000000,B00000010,B00000000,
B00000011,B00000001,B00000000,B00000000,B00000000,B00000010,B00000000,
B00000110,B00000111,B00000000,B00000000,B00000000,B00000010,B00000000,
B00000100,B00111000,B00000000,B00000000,B00000000,B00000110,B00000000,
B00000100,B01100000,B00000000,B00000000,B00000000,B00000011,B00000000,
B00000100,B01000000,B00000000,B00000000,B00000000,B00000001,B00000000,
B00000110,B11000000,B00000000,B00000000,B00000000,B00000000,B10000000,
B00000011,B10000000,B00000000,B00000000,B00000000,B00000000,B10000000,
B00000001,B10000000,B00000000,B00000000,B00000000,B00000000,B10000000,
B00000000,B01000000,B00000000,B00000000,B00000000,B00000001,B10000000,
B00000000,B01000000,B00000000,B00000000,B00000000,B00000001,B00000000,
B00000000,B00100000,B00000000,B00000000,B00000000,B00000010,B00000000,
B00000000,B00011111,B11111111,B11111111,B11111111,B11111100,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000010,B00000001,B00000000,B10000000,B01000000,B00110000,B00000000,
B00000100,B00000010,B00000001,B10000000,B01000000,B00100000,B00000000,
B00000100,B00000010,B00000001,B00000000,B10000000,B01100000,B00000000,
B00001000,B00000100,B00000011,B00000000,B10000000,B01000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000001,B00000000,B00000000,
B00100000,B00010000,B00001000,B00000110,B00000001,B00000000,B00000000,
B01100000,B00110000,B00001000,B00000100,B00000010,B00000000,B00000000,
B01000000,B00100000,B00010000,B00001100,B00000010,B00000000,B00000000,
B11000000,B01100000,B00010000,B00001000,B00000100,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000
};
const unsigned char snow[] PROGMEM = {
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00100000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00100000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00100000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00010000,B00100000,B01000000,B00000000,B00000000,
B00000000,B00000000,B00011000,B00100000,B11000000,B00000000,B00000000,
B00000000,B00000000,B00000110,B00100001,B10000000,B00000000,B00000000,
B00000000,B00000000,B00000011,B00100110,B00000000,B00000000,B00000000,
B00000000,B00100000,B00000000,B10101100,B00000000,B00100000,B00000000,
B00000000,B00010000,B00000000,B01110000,B00000000,B01100000,B00000000,
B00000000,B00010000,B00000000,B00100000,B00000000,B01000000,B00000000,
B00011100,B00011000,B00000000,B00100000,B00000000,B11000001,B11000000,
B00000011,B00001000,B00000000,B01110000,B00000000,B10000111,B00000000,
B00000000,B11101100,B00000000,B11111000,B00000000,B10111000,B00000000,
B00000000,B00011100,B00000011,B00100110,B00000001,B11000000,B00000000,
B00000000,B11111111,B11111100,B00100001,B11111111,B11111000,B00000000,
B00011111,B00000001,B11100000,B00100000,B00111100,B00000111,B11000000,
B00000000,B00000000,B11011000,B00100000,B11111000,B00000000,B00000000,
B00000000,B00000000,B01000111,B00100011,B00011000,B00000000,B00000000,
B00000000,B00000000,B01000001,B11111100,B00010000,B00000000,B00000000,
B00000000,B00000000,B01000000,B01111000,B00010000,B00000000,B00000000,
B00000000,B00000000,B01000011,B10100110,B00010000,B00000000,B00000000,
B00000000,B00000000,B11011100,B00100001,B11011000,B00000000,B00000000,
B00011100,B00000000,B11100000,B00100000,B00111100,B00000001,B11000000,
B00000011,B11110011,B11111000,B00100000,B11111110,B01111110,B00000000,
B00000000,B00011110,B00000111,B00100011,B10000001,B11000000,B00000000,
B00000000,B01111100,B00000001,B10101100,B00000001,B10110000,B00000000,
B00000001,B10001000,B00000000,B01111000,B00000000,B10001110,B00000000,
B00001110,B00001000,B00000000,B00110000,B00000000,B11000011,B10000000,
B00010000,B00011000,B00000000,B00100000,B00000000,B01000000,B00000000,
B00000000,B00010000,B00000000,B01110000,B00000000,B01100000,B00000000,
B00000000,B00110000,B00000000,B11111000,B00000000,B00100000,B00000000,
B00000000,B00100000,B00000001,B10100110,B00000000,B00100000,B00000000,
B00000000,B00000000,B00000110,B00100011,B00000000,B00000000,B00000000,
B00000000,B00000000,B00001100,B00100001,B10000000,B00000000,B00000000,
B00000000,B00000000,B00010000,B00100000,B01100000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00100000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00100000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000
};
const unsigned char mist[] PROGMEM = {
B00000000,B00000000,B00000011,B11111000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00001111,B11111111,B10000000,B00000000,B00000000,
B00000000,B00000000,B00111000,B00000011,B11000000,B00000000,B00000000,
B00000000,B00000000,B01110000,B00000000,B01100000,B00000000,B00000000,
B00000000,B00000000,B11000000,B00000000,B00111000,B00000000,B00000000,
B00000000,B00000011,B10000000,B00000000,B00011111,B11110000,B00000000,
B00000000,B00000011,B00000000,B00000000,B00011111,B11111110,B00000000,
B00000000,B00000111,B00000000,B00000000,B00000000,B00001111,B00000000,
B00000000,B11111111,B11000000,B00000000,B00000000,B00000001,B11000000,
B00000111,B11000000,B11111000,B00000000,B00000000,B00000001,B11000000,
B00001111,B00000000,B00111100,B00000000,B00000000,B00000000,B11100000,
B00011000,B00000000,B00001111,B00000000,B00000000,B00000000,B11100000,
B01110000,B00000000,B00000111,B10111100,B00000000,B00000000,B11100000,
B01110000,B00000000,B00000011,B11111111,B11000000,B00000000,B11100000,
B01100000,B00000000,B00000000,B10000001,B11100000,B00000000,B11100000,
B11100000,B00000000,B00000000,B00000000,B00111000,B00000000,B11100000,
B11100000,B00000000,B00000000,B00000000,B00011000,B00000000,B11000000,
B11100000,B00000000,B00000000,B00000000,B00011100,B00000001,B11000000,
B11100000,B00000000,B00000000,B00000000,B00011100,B00000011,B00000000,
B11100000,B00000000,B00000000,B00000000,B00000100,B00011110,B00000000,
B11100000,B00000000,B00000000,B00000000,B00000111,B11111100,B00000000,
B01100000,B00000000,B00000000,B00000000,B00000111,B11000000,B00000000,
B01110000,B00000000,B00000000,B00000000,B00011100,B00000000,B00000000,
B00011000,B00000000,B00000000,B00000000,B00011100,B00000000,B00000000,
B00011110,B00000000,B00000000,B00000000,B00111000,B00000000,B00000000,
B00001111,B00000000,B00000000,B00000000,B01100000,B00000000,B00000000,
B00000001,B11000000,B00000000,B00000011,B11000000,B00000000,B00000000,
B00000000,B11111111,B11111111,B11111111,B10000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B11000011,B11110000,B11111001,B11111000,B01100000,B00000000,
B00000000,B11111111,B11111111,B10111111,B11111111,B11100000,B00000000,
B00000000,B00111100,B00001111,B00011110,B00000111,B10000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B11000011,B11110000,B11111001,B11111000,B01100000,B00000000,
B00000000,B11111111,B11111111,B10111111,B11111111,B11100000,B00000000,
B00000000,B00111100,B00001111,B00011110,B00000111,B10000000,B00000000
};
const unsigned char clearS[] PROGMEM = {
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000,
B00000000,B00000110,B00000000,B01000000,B00001100,B00000000,B00000000,
B00000000,B00000011,B00000000,B01000000,B00011000,B00000000,B00000000,
B00000000,B00000001,B00000000,B01000000,B00010000,B00000000,B00000000,
B00000000,B00000000,B10000000,B10100000,B00100000,B00000000,B00000000,
B00000000,B00000000,B01011111,B00011111,B01000000,B00000000,B00000000,
B00111000,B00000000,B01100000,B00000000,B11100000,B00000001,B10000000,
B00000110,B00000001,B10000000,B00000000,B00011000,B00001100,B00000000,
B00000001,B11000110,B00000000,B00000000,B00001100,B01110000,B00000000,
B00000000,B00101100,B00000000,B00000000,B00000110,B11000000,B00000000,
B00000000,B00001000,B00000000,B00000000,B00000011,B00000000,B00000000,
B00000000,B00010000,B00000000,B00000000,B00000001,B00000000,B00000000,
B00000000,B00110000,B00000000,B00000000,B00000001,B10000000,B00000000,
B00000000,B00100000,B00000000,B00000000,B00000000,B10000000,B00000000,
B00000000,B00100000,B00000000,B00000000,B00000000,B10000000,B00000000,
B00111111,B11100000,B00000000,B00000000,B00000000,B11111111,B11000000,
B00000000,B00100000,B00000000,B00000000,B00000000,B10000000,B00000000,
B00000000,B00100000,B00000000,B00000000,B00000000,B10000000,B00000000,
B00000000,B00110000,B00000000,B00000000,B00000001,B10000000,B00000000,
B00000000,B00010000,B00000000,B00000000,B00000001,B00000000,B00000000,
B00000000,B00001000,B00000000,B00000000,B00000011,B00000000,B00000000,
B00000000,B01101100,B00000000,B00000000,B00000110,B11000000,B00000000,
B00000001,B11000110,B00000000,B00000000,B00001100,B01110000,B00000000,
B00001110,B00000001,B10000000,B00000000,B00110000,B00001110,B00000000,
B00110000,B00000000,B01100000,B00000000,B11000000,B00000001,B10000000,
B00000000,B00000000,B01011111,B00011111,B01100000,B00000000,B00000000,
B00000000,B00000000,B10000000,B00000000,B00100000,B00000000,B00000000,
B00000000,B00000001,B00000000,B01000000,B00010000,B00000000,B00000000,
B00000000,B00000011,B00000000,B01000000,B00001000,B00000000,B00000000,
B00000000,B00000110,B00000000,B01000000,B00001100,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B00000000
};
const unsigned char clearS1[] PROGMEM = {
B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,
B00000000,B00100000,B00100000,B00100000,B00000000,
B00000000,B00100000,B00100000,B01000000,B00000000,
B00000000,B00010000,B00100000,B01000000,B00000000,
B00000000,B00001000,B01110000,B10000000,B00000000,
B00000000,B00001011,B10001111,B10000000,B00000000,
B00110000,B00001100,B00000001,B10000000,B01100000,
B00001100,B00010000,B00000000,B11000001,B10000000,
B00000110,B00100000,B00000000,B00100110,B00000000,
B00000001,B01000000,B00000000,B00111100,B00000000,
B00000000,B01000000,B00000000,B00010000,B00000000,
B00000000,B10000000,B00000000,B00001000,B00000000,
B00000000,B10000000,B00000000,B00001000,B00000000,
B00000000,B10000000,B00000000,B00001000,B00000000,
B00000001,B00000000,B00000000,B00001000,B00000000,
B00111111,B00000000,B00000000,B00001111,B11100000,
B00000001,B00000000,B00000000,B00001000,B00000000,
B00000000,B10000000,B00000000,B00001000,B00000000,
B00000000,B10000000,B00000000,B00001000,B00000000,
B00000000,B10000000,B00000000,B00001000,B00000000,
B00000000,B01000000,B00000000,B00010000,B00000000,
B00000001,B01000000,B00000000,B00111100,B00000000,
B00000110,B00100000,B00000000,B00100010,B00000000,
B00001100,B00010000,B00000000,B11000001,B10000000,
B00110000,B00001100,B00000001,B10000000,B01100000,
B00000000,B00001011,B10001111,B10000000,B00000000,
B00000000,B00011000,B01000000,B10000000,B00000000,
B00000000,B00010000,B00100000,B01000000,B00000000,
B00000000,B00100000,B00100000,B01000000,B00000000,
B00000000,B00100000,B00100000,B00100000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000,
B00000000,B00000000,B00100000,B00000000,B00000000
};
const unsigned char clouds[] PROGMEM = {
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B01100000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000011,B11111100,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000111,B00001110,B00001111,B11000000,B00000000,B00000000,
B00000000,B00001100,B00000011,B00011110,B11110000,B00000000,B00000000,
B00000000,B00011000,B00000001,B11110000,B00011000,B00000000,B00000000,
B00000000,B00010000,B00000000,B11000000,B00001100,B00000000,B00000000,
B00000000,B01110000,B00000000,B10000000,B00000110,B00000000,B00000000,
B00000001,B11100000,B00000001,B10000000,B00000011,B00000000,B00000000,
B00000011,B00000000,B00000001,B00000000,B00000001,B00000000,B00000000,
B00000110,B00000000,B00000011,B00000000,B00000001,B11110000,B00000000,
B00000100,B00000000,B00000010,B00000000,B00000000,B10111000,B00000000,
B00001100,B00000000,B01111110,B00000000,B00000000,B00001100,B00000000,
B00001000,B00000000,B11100110,B00000000,B00000000,B00000100,B00000000,
B00001000,B00000001,B10000000,B00000000,B00000000,B00000010,B00000000,
B00001000,B00000011,B00000000,B00000000,B00000000,B00000010,B00000000,
B00000100,B00000010,B00000000,B00000000,B00000000,B00000010,B00000000,
B00001100,B00000100,B00000000,B00000000,B00000000,B00000011,B00000000,
B00011000,B00000100,B00000000,B00000000,B00000000,B00000011,B00000000,
B00010000,B00011100,B00000000,B00000000,B00000000,B00000010,B00000000,
B00010000,B01111100,B00000000,B00000000,B00000000,B00000010,B00000000,
B00110000,B11000000,B00000000,B00000000,B00000000,B00000011,B00000000,
B00110001,B10000000,B00000000,B00000000,B00000000,B00000001,B00000000,
B00110001,B00000000,B00000000,B00000000,B00000000,B00000001,B10000000,
B00010011,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000,
B00010010,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000,
B00011010,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000,
B00001110,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000,
B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B11000000,
B00000010,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000,
B00000011,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000,
B00000001,B00000000,B00000000,B00000000,B00000000,B00000001,B10000000,
B00000001,B10000000,B00000000,B00000000,B00000000,B00000001,B00000000,
B00000000,B11000000,B00000000,B00000000,B00000000,B00000011,B00000000,
B00000000,B01111111,B11111111,B11111111,B11111111,B11111110,B00000000,
B00000000,B00011111,B11111111,B11111111,B11111111,B11111000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000
};
const unsigned char weather1[] PROGMEM = {
B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00011111,B11000000,B00000000,
B00000000,B00000000,B01100000,B01100000,B00000000,
B00000000,B00000000,B10000000,B00010000,B00000000,
B00000000,B00000001,B00000000,B00001000,B00000000,
B00000000,B00000011,B00000000,B00000111,B00000000,
B00000000,B00000010,B00000000,B00000000,B11000000,
B00000000,B01111110,B00000000,B00000000,B01100000,
B00000000,B10000000,B00000000,B00000000,B00110000,
B00000001,B00000000,B00000000,B00000000,B00010000,
B00000011,B00000000,B00000000,B00000000,B00010000,
B00000110,B00000000,B00000000,B00000000,B00010000,
B00011100,B00000000,B00000000,B00000000,B00010000,
B00100000,B00000000,B00000000,B00000000,B00011000,
B01000000,B00000000,B00000000,B00000000,B00001000,
B01000000,B00000000,B00000000,B00000000,B00000100,
B11000000,B00000000,B00000000,B00000000,B00000100,
B01000000,B00000000,B00000000,B00000000,B00000100,
B01000000,B00000000,B00000000,B00000000,B00001100,
B01000000,B00000000,B00000000,B00000000,B00001000,
B00100000,B00000000,B00000000,B00000000,B00010000,
B00011111,B11111111,B11111111,B11111111,B11100000,
B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,B00000000,B00000000
};
String interpretWeatherCode(int code) {
switch (code) {
case 0: return "Senin";
case 1: case 2: case 3: return "Partial noros";
case 45: case 48: return "Ceata";
case 51: case 53: case 55: return "Burnita";
case 61: case 63: case 65: return "Ploaie";
case 66: case 67: return "Lapovita";
case 71: case 73: case 75: return "Ninsoare";
case 80: case 81: case 82: return "Averse";
case 85: case 86: return "Ninsoare";
case 95: return "Furtuna";
case 96: case 99: return "Furtuna puternica";
default: return "Necunoscut";
}
}
// --- DST utilities (Romania) ---
// weekday_for_date: 0=Sunday, 1=Monday, ...
int weekday_for_date(int y, int m, int d) {
static int t[] = {0,3,2,5,0,3,5,1,4,6,2,4};
if (m < 3) y -= 1;
return (y + y / 4 - y / 100 + y / 400 + t[m - 1] + d) % 7; // 0 = Sunday
}
int lastSunday(int year, int month) {
for (int d = 31; d >= 25; d--) {
if (d > 0) {
int w = weekday_for_date(year, month, d);
if (w == 0) return d;
}
}
return 31;
}
// Return true if DST (EEST) is active for Romania for the given date
bool isDST_ro(int year, int month, int day) {
// DST: from last Sunday of March (inclusive) to last Sunday of October (exclusive)
if (month < 3 || month > 10) return false;
if (month > 3 && month < 10) return true;
int ls = lastSunday(year, month);
if (month == 3) return day >= ls; // from last Sunday of March inclusive
if (month == 10) return day < ls; // until last Sunday of October (exclusive)
return false;
}
// --- end DST utilities ---
void getTime() {
time_t now_utc = time(nullptr); // UTC epoch from system (configTime)
if (now_utc < 1000000000L) {
// time not set yet; leave previous values
return;
}
struct tm *utc = gmtime(&now_utc);
if (!utc) return;
int year = utc->tm_year + 1900;
int month = utc->tm_mon + 1;
int day = utc->tm_mday;
bool dstActive = isDST_ro(year, month, day);
int offset = dstActive ? 10800 : 7200;
time_t localEpoch = now_utc + offset;
struct tm *local = gmtime(&localEpoch);
if (!local) return;
getD = local->tm_wday;
getH = local->tm_hour;
getM = local->tm_min;
getS = local->tm_sec;
dayName = daysOfTheWeek[getD];
}
String getFormattedDate() {
time_t now_utc = time(nullptr);
if (now_utc < 1000000000L) return String("??/??/????");
struct tm *utc = gmtime(&now_utc);
if (!utc) return String("??/??/????");
int year = utc->tm_year + 1900;
int month = utc->tm_mon + 1;
int day = utc->tm_mday;
bool dstActive = isDST_ro(year, month, day);
int offset = dstActive ? 10800 : 7200;
time_t localEpoch = now_utc + offset;
struct tm *local = gmtime(&localEpoch);
if (!local) return String("??/??/????");
char buffer[11];
sprintf(buffer, "%02d/%02d/%04d", local->tm_mday, local->tm_mon + 1, local->tm_year + 1900);
return String(buffer);
}
void syncTimeWithNTP() {
if (WiFi.status() != WL_CONNECTED) {
Serial.println("[syncTimeWithNTP] WiFi nu este conectat. Încerc reconectarea...");
WiFi.reconnect();
delay(5000);
if (WiFi.status() != WL_CONNECTED) {
Serial.println("[syncTimeWithNTP] Eroare: nu s-a putut reconecta la WiFi.");
return;
}
Serial.println("[syncTimeWithNTP] Rețea WiFi reconectată.");
}
// Request NTP via system configTime (we'll keep TZ untouched and compute DST manually)
configTime(0, 0, "ro.pool.ntp.org", "pool.ntp.org", "time.nist.gov");
Serial.println("[syncTimeWithNTP] Cerere NTP trimisă (configTime)...");
// wait up to 10 seconds for time to be set
unsigned long start = millis();
time_t now = time(nullptr);
while (now < 1510590025 && millis() - start < 10000) {
delay(200);
now = time(nullptr);
}
if (now < 1510590025) {
Serial.println("[syncTimeWithNTP] Eroare: nu s-a putut obține ora locală.");
return;
}
// now contains UTC epoch (system time after configTime with zero offsets)
struct tm *utc = gmtime(&now);
if (!utc) {
Serial.println("[syncTimeWithNTP] Eroare: gmtime(NULL).");
return;
}
int year = utc->tm_year + 1900;
int month = utc->tm_mon + 1;
int day = utc->tm_mday;
bool dstActive = isDST_ro(year, month, day);
int offset = dstActive ? 10800 : 7200; // seconds: EEST or EET
time_t localEpoch = now + offset;
struct tm *local = gmtime(&localEpoch);
if (!local) {
Serial.println("[syncTimeWithNTP] Eroare: local gmtime(NULL).");
return;
}
char buf[64];
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", local);
Serial.print("[syncTimeWithNTP] Ora sincronizata (local): ");
Serial.println(buf);
Serial.print("[syncTimeWithNTP] DST activ: ");
Serial.println(dstActive ? "DA (ora de vara)" : "NU (ora de iarna)");
}
WiFiClient wifiClient;
void initScreen() {
tft.initR(INITR_GREENTAB);
tft.fillScreen(ST7735_BLACK);
tft.drawFastHLine(0, 0, tft.width(), ST7735_WHITE);
tft.drawFastHLine(1, 159, tft.width(), ST7735_WHITE);
tft.drawFastVLine(0, 0, tft.height(), ST7735_WHITE);
tft.drawFastVLine(127, 0, tft.height(), ST7735_WHITE);
tft.drawFastHLine(1, 140, tft.width(), ST7735_WHITE);
tft.drawFastHLine(1, 19, tft.width(), ST7735_WHITE);
}
void connectWifi() {
tft.setCursor(10, 70);
tft.setTextColor(ST7735_YELLOW);
tft.setTextSize(1);
tft.println("Connecting");
tft.setCursor(10, 90);
tft.println("to WiFi...");
delay(2000);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
unsigned long start = millis();
while (WiFi.status() != WL_CONNECTED) {
if (millis() - start > 15000) {
Serial.println("\nWiFi connection failed! Restarting...");
ESP.restart();
}
delay(250);
Serial.print(".");
static int progress = 0;
tft.fillRect(10 + progress, 110, 10, 10, ST7735_YELLOW);
progress += 10;
if (progress >= 100) progress = 0;
}
Serial.println("\nWiFi connected!");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
tft.fillRect(3, 22, 123, 116, ST7735_BLACK);
tft.setCursor(10, 50);
tft.setTextColor(0x07FF);
tft.println("Connected to");
tft.setCursor(20, 70);
tft.println(ssid);
delay(3000);
}
void setup() {
Serial.begin(115200);
initScreen();
connectWifi();
tft.fillRect(3, 22, 123, 116, ST7735_BLACK);
tft.setCursor(10, 40);
tft.setTextColor(ST7735_YELLOW);
tft.println("Synchro time...");
// Inițializare NTP fără fus orar (UTC pur)
configTime(0, 0, "ro.pool.ntp.org", "pool.ntp.org", "time.nist.gov");
time_t now = time(nullptr);
int retry = 0;
int progressX = 10;
while (now < 86400 && retry < 30) {
tft.fillRect(progressX, 60, 5, 5, ST7735_YELLOW);
progressX += 7;
if (progressX > 120) progressX = 10;
delay(1000);
now = time(nullptr);
retry++;
}
if (now < 86400) {
tft.fillRect(3, 22, 123, 116, ST7735_BLACK);
tft.setCursor(10, 40);
tft.setTextColor(ST7735_RED);
tft.println(" Sync failed!");
tft.setCursor(10, 60);
tft.println("Restart in 5s...");
delay(5000);
ESP.restart();
}
tft.fillRect(3, 22, 123, 116, ST7735_BLACK);
tft.setCursor(10, 40);
tft.setTextColor(ST7735_GREEN);
tft.println("Time synchronized!");
// --- AFIȘARE ORĂ LOCALĂ FĂRĂ localtime() ---
struct tm *utc = gmtime(&now);
if (utc) {
int year = utc->tm_year + 1900;
int month = utc->tm_mon + 1;
int day = utc->tm_mday;
bool dstActive = isDST_ro(year, month, day);
int offset = dstActive ? 10800 : 7200; // +3h sau +2h
time_t localEpoch = now + offset;
struct tm *local = gmtime(&localEpoch);
if (local) {
char timeStr[9];
strftime(timeStr, sizeof(timeStr), "%H:%M:%S", local);
Serial.print("[SETUP] Ora sincronizată: ");
Serial.println(timeStr);
char dateStr[11];
strftime(dateStr, sizeof(dateStr), "%d/%m/%Y", local);
Serial.print("[SETUP] Data: ");
Serial.println(dateStr);
Serial.print("[SETUP] DST activ: ");
Serial.println(dstActive ? "DA (ora de vară)" : "NU (ora de iarnă)");
} else {
Serial.println("[SETUP] Eroare: gmtime(localEpoch) e NULL");
}
} else {
Serial.println("[SETUP] Eroare: gmtime(now) e NULL");
}
delay(1000);
getTime(); // folosește logica manuală
delay(2000);
tft.fillRect(3, 22, 123, 116, ST7735_BLACK);
tft.setCursor(10, 40);
tft.setTextColor(ST7735_YELLOW);
tft.println("Getting weather...");
delay(3000);
getCurrentData();
lastWeatherUpdate = millis();
screen1();
}
int lastH = -1, lastM = -1;
String lastDayName = "";
void updateTimeOnScreen() {
getTime();
if (getH != lastH || getM != lastM) {
String timeStr = String(getH) + ":" + (getM < 10 ? "0" : "") + String(getM);
tft.setFont(&FreeSansBold18pt7b);
tft.setTextSize(1);
int16_t x1, y1;
uint16_t textWidth, textHeight;
tft.getTextBounds(timeStr, 0, 0, &x1, &y1, &textWidth, &textHeight);
int centerX = (128 - textWidth) / 2;
int centerY = 80;
int padding = 10;
int eraseX = centerX - padding;
int eraseWidth = textWidth + 2 * padding;
tft.fillRect(eraseX, centerY + y1, eraseWidth, textHeight, ST7735_BLACK);
tft.setTextColor(0xFB20);
tft.setCursor(centerX, centerY);
tft.print(timeStr);
lastH = getH;
lastM = getM;
}
if (dayName != lastDayName) {
tft.setFont(&FreeSansBold9pt7b);
tft.setTextSize(1);
int16_t x1, y1;
uint16_t textWidth, textHeight;
tft.getTextBounds(dayName, 0, 0, &x1, &y1, &textWidth, &textHeight);
int centerX = (128 - textWidth) / 2;
int centerY = 100;
int padding = 10;
int eraseX = centerX - padding;
int eraseWidth = textWidth + 2 * padding;
tft.fillRect(eraseX, centerY + y1, eraseWidth, textHeight, ST7735_BLACK);
tft.setTextColor(0x001F);
tft.setCursor(centerX, centerY);
tft.print(dayName);
lastDayName = dayName;
}
}
void getCurrentData() {
unsigned long currentMillis = millis();
if (currentMillis - lastWeatherUpdate < WEATHER_UPDATE_INTERVAL && lastWeatherUpdate != 0) {
Serial.println("Skipping weather update, not enough time has passed.");
return;
}
lastWeatherUpdate = currentMillis;
if (WiFi.status() != WL_CONNECTED) {
Serial.println("Not connected to Wi-Fi! Using last known weather data.");
return;
}
HTTPClient http;
String url = "http://api.open-meteo.com/v1/forecast?latitude=44.92&longitude=25.99¤t=temperature_2m,weathercode,windspeed_10m,relative_humidity_2m,pressure_msl&timezone=Europe/Bucharest";
Serial.println("[Weather] Requesting URL: " + url);
http.begin(wifiClient, url);
int httpResponseCode = http.GET();
if (httpResponseCode == HTTP_CODE_OK) {
String payload = http.getString();
Serial.println("[Weather] Raw JSON response:");
Serial.println(payload);
DynamicJsonDocument doc(1024);
DeserializationError error = deserializeJson(doc, payload);
if (error) {
Serial.print("[Weather] JSON deserialization failed: ");
Serial.println(error.f_str());
return;
}
// Ora pentru afișare vine din ESP8266 sincronizat prin NTP
if (doc.containsKey("timezone")) {
const char* tz = doc["timezone"];
}
temp = doc["current"]["temperature_2m"].as();
pres = doc["current"]["pressure_msl"].as();
pres_mmHg = pres * 0.75006;
humidity = doc["current"]["relative_humidity_2m"].as();
wind = doc["current"]["windspeed_10m"].as() / 3.6;
int weatherCode = doc["current"]["weathercode"].as();
maine = interpretWeatherCode(weatherCode);
Serial.println("[Weather] Data updated:");
Serial.println(" Conditii: " + maine);
Serial.printf(" Temperatura: %.1f°C\n", temp);
Serial.printf(" Presiune: %d hPa (%.1f mmHg)\n", pres, pres_mmHg);
Serial.printf(" Umiditate: %d%%\n", humidity);
Serial.printf(" Vant: %.2f m/s\n", wind);
} else {
Serial.print("[Weather] Error on HTTP request. Code: ");
Serial.println(httpResponseCode);
}
http.end();
}
void screen1() {
tft.setFont();
tft.setTextColor(0x07FF);
tft.setCursor(5, 7);
tft.print(city);
tft.setCursor(112, 7);
tft.print("RO");
tft.fillRect(3, 142, 123, 16, ST7735_BLACK);
tft.setCursor(5, 146);
tft.print(temp, 1);
tft.print(char(247));
tft.print("C");
tft.setCursor(65, 146);
tft.print(getFormattedDate());
tft.fillRect(3, 22, 123, 116, ST7735_BLACK);
tft.setFont(&FreeSansBold18pt7b);
String timeStr = String(getH) + ":" + (getM < 10 ? "0" : "") + String(getM);
int16_t x1, y1;
uint16_t textWidth, textHeight;
tft.getTextBounds(timeStr, 0, 0, &x1, &y1, &textWidth, &textHeight);
int centerX = (128 - textWidth) / 2;
tft.setTextColor(0xFB20);
tft.setCursor(centerX, 80);
tft.print(timeStr);
tft.setFont(&FreeSansBold9pt7b);
tft.getTextBounds(dayName, 0, 0, &x1, &y1, &textWidth, &textHeight);
centerX = (128 - textWidth) / 2;
tft.setTextColor(0x001F);
tft.setCursor(centerX, 100);
tft.print(dayName);
tft.setTextColor(ST7735_WHITE);
tft.setCursor(19, 120);
}
void screen2() {
tft.fillRect(3, 22, 123, 116, ST7735_BLACK);
displayweatherbitmap_screen2();
tft.setFont(&FreeSansBold9pt7b);
tft.setCursor(72, 50);
if (temp <= 0) {
tft.setTextColor(0xF800);
} else if (temp > 0 && temp < 5) {
tft.setTextColor(0xFC00);
} else if (temp >= 5 && temp < 16) {
tft.setTextColor(0xFFE0);
} else if (temp >= 16 && temp < 27) {
tft.setTextColor(0x07FF);
} else if (temp >= 27 && temp < 37) {
tft.setTextColor(0x001F);
} else {
tft.setTextColor(0x4B1F);
}
tft.printf("%.1f", temp);
int currentX = tft.getCursorX();
int currentY = tft.getCursorY();
tft.setCursor(currentX + 2, 45);
tft.setFont();
tft.print((char)247);
tft.print("C");
tft.setTextColor(ST7735_WHITE);
tft.setFont();
tft.setCursor(95, 83);
tft.setTextColor(0xF800);
tft.print("Umid.");
if (humidity < 10) {
tft.setTextColor(0x04E0);
} else if (humidity < 20) {
tft.setTextColor(0x87E0);
} else if (humidity < 30) {
tft.setTextColor(0xFFE0);
} else if (humidity < 40) {
tft.setTextColor(0xFB20);
} else {
tft.setTextColor(0xFFE0);
}
tft.setFont(&FreeSansBold9pt7b);
tft.setCursor(92, 106);
tft.print(humidity);
tft.setFont();
tft.setCursor(116, 100);
tft.print("%");
tft.setCursor(10, 110);
tft.setTextColor(0x001F);
tft.print("Pres.atm / Vant");
tft.setCursor(5, 122);
tft.setTextColor(0x07E0);
tft.print(pres_mmHg, 1);
tft.print(" mmHg");
tft.setCursor(75, 122);
tft.print(wind, 1);
tft.print(" m/s");
tft.setTextColor(ST7735_WHITE);
}
void displayweatherbitmap_screen2() {
tft.fillRect(3, 22, 123, 116, ST7735_BLACK);
tft.setCursor(5, 75);
tft.setTextSize(0);
if (maine.equals("Senin")) {
tft.setFont(&FreeSansBold9pt7b);
tft.setTextColor(0x07FF);
tft.println(maine);
tft.drawBitmap(8, 25, clearS, 51, 40, 0x07FF);
} else if (maine.equals("Partial noros")) {
tft.setFont();
tft.setTextColor(0x8410);
tft.println(maine);
tft.drawBitmap(8, 25, clouds, 51, 40, 0x8410);
} else if (maine.equals("Ceata")) {
tft.setFont(&FreeSansBold9pt7b);
tft.setTextColor(0x8410);
tft.println(maine);
tft.drawBitmap(8, 25, mist, 51, 40, 0x8410);
} else if (maine.equals("Ploaie")) {
tft.setFont();
tft.setTextColor(0x8410);
tft.println(maine);
tft.drawBitmap(8, 25, rain, 51, 40, 0x8410);
} else if (maine.equals("Ninsoare")) {
tft.setFont();
tft.setTextColor(0xFFFF);
tft.println(maine);
tft.drawBitmap(8, 25, snow, 51, 40, 0xFFFF);
} else if (maine.equals("Furtuna")) {
tft.setFont(&FreeSansBold9pt7b);
tft.setTextColor(0xF800);
tft.println(maine);
tft.drawBitmap(8, 25, thunder, 51, 40, 0xF800);
} else {
tft.setFont();
tft.setTextColor(0x8410);
tft.println("Necunoscut");
tft.drawBitmap(8, 25, mist, 51, 40, 0x8410);
}
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousTimeUpdate >= timeUpdateInterval) {
previousTimeUpdate = currentMillis;
getTime();
if (showingScreen1) {
updateTimeOnScreen();
}
}
if (currentMillis - previousScreenSwitch >= (showingScreen1 ? screen1Duration : screen2Duration)) {
previousScreenSwitch = currentMillis;
if (showingScreen1) {
screen2();
showingScreen1 = false;
} else {
screen1();
showingScreen1 = true;
}
}
if (currentMillis - lastWeatherUpdate >= WEATHER_UPDATE_INTERVAL) {
getCurrentData();
lastWeatherUpdate = currentMillis;
}
if (currentMillis - previousNtpSync >= ntpSyncInterval) {
previousNtpSync = currentMillis;
syncTimeWithNTP();
}
}
Niciun comentariu:
Trimiteți un comentariu