Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Code by:
- // Levente Daradici
- // Youtube video with this code on microcontroller
- // https://youtu.be/mdoX3ZSBYtc
- // 09-04-2023
- // A short description and discussions in Romanian: http://satelit-info.com/phpBB3/viewtopic.php?f=172&t=3322&start=10#p25865
- //
- #include <TFT_eSPI.h>
- #include <SPI.h>
- #include <WiFi.h>
- #include <WiFiClient.h>
- #include "NTPClient.h"
- WiFiClient client;
- const char* ssid = "Your WIFI network SSID";
- const char* password = "Your WIFI password";
- const char* host = "192.168.XXX.XXX"; //YOUR SET TOP BOX IP
- const char* path = "/web/getcurrent";
- const long utcOffsetInSeconds = 10800;
- String NumeCanalVechi, NumeCanalNou, EPGacumVECHI, EPGacumNOU, EPGacumVECHI2, EPGacumNOU2, AfisareEPG, AfisareEPG2, AfisareDESC, AfisareDESC2, AfisareEPGtotal,AfisareDescriereEPG,AfisareDescriereEPG2 = " ";
- int Conexiune, Pozitie, EPGacum, DescriereACUM, DescriereACUMepg = 0;
- String NumeCanalCurent ="Nume Canal Curent";
- String NumeEmisiuneCurenta ="Nume Emisiune Curenta";
- String EpgEmisiuneCurenta ="EPG Emisiune Curenta";
- String OraExacta ="22:26:35";
- String NumeProvider ="Digi Tv / RCS & RDS";
- String RezolutieCanal ="1920x1080";
- TFT_eSPI tft = TFT_eSPI();
- WiFiUDP ntpUDP;
- NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);
- void setup(void)
- {
- Serial.begin(115200);
- delay(500);
- tft.init();
- tft.setRotation(3);
- tft.fillScreen(TFT_BLACK);
- EPGacum = 1;
- DescriereACUM = 1;
- DescriereACUMepg = 1;
- WiFi.begin(ssid, password);
- Serial.print("Connecting to WiFi");
- while (WiFi.status() != WL_CONNECTED)
- {
- Serial.print(".");
- delay(500);
- }
- Serial.println();
- Serial.println("Connected to WiFi");
- delay(2000);
- Conexiune == 1;
- timeClient.begin();
- }
- void loop()
- {
- timeClient.update();
- tft.setTextSize(2);
- tft.setTextColor(TFT_CYAN, TFT_BLACK);
- OraExacta = timeClient.getFormattedTime();
- Serial.println(OraExacta);
- tft.drawString(OraExacta, 205, 2, 2);
- WiFiClient client;
- if (!client.connect(host, 80))
- {
- Serial.println("NOT CONNECTED TO");
- Serial.println("ENIGMA2 RECEIVER!");
- Conexiune = 0;
- return;
- } else
- if (Conexiune == 0)
- {
- Serial.println("CONNECTED TO");
- Serial.println("ENIGMA2 RECEIVER");
- delay(2000);
- Conexiune = 1;
- NumeCanalVechi = " ";
- EPGacumVECHI = " ";
- EPGacum = 1;
- }
- Serial.println("");
- String url = String(path);
- client.print(String("GET ") + url + " HTTP/1.1\r\n" +
- "Host: " + host + "\r\n" +
- "Connection: close\r\n\r\n");
- while(!client.available())
- {
- delay(500);
- }
- String line;
- while (client.available())
- {
- line = client.readStringUntil('\n');
- if (line.indexOf("e2servicename") >= 0)
- {
- int startIndex = line.indexOf(">") + 1;
- int endIndex = line.indexOf("<", startIndex);
- String e2servicename = line.substring(startIndex, endIndex);
- NumeCanalNou = e2servicename ;
- if (NumeCanalVechi != NumeCanalNou)
- {
- tft.setTextSize(3);
- tft.setTextColor(TFT_RED, TFT_BLACK);
- tft.drawString(NumeCanalNou + " ", 0, 32, 2);
- tft.setTextSize(2);
- tft.setTextColor(TFT_BLUE, TFT_BLACK);
- tft.drawString("ACUM", 150, 80, 2);
- tft.drawString("EPG", 3, 144, 2);
- NumeCanalVechi = NumeCanalNou;
- }
- Serial.println("Canal: " + e2servicename);
- } else if (line.indexOf("e2providername") >= 0)
- {
- int startIndex = line.indexOf(">") + 1;
- int endIndex = line.indexOf("<", startIndex);
- String e2providername = line.substring(startIndex, endIndex);
- NumeProvider = e2providername;
- tft.setTextSize(1);
- tft.setTextColor(TFT_YELLOW, TFT_BLACK);
- tft.drawString(NumeProvider + + " ", 230, 80, 2);
- Serial.println("Provider: " + e2providername);
- }
- else if (line.indexOf("e2servicevideosize") >= 0)
- {
- int startIndex = line.indexOf(">") + 1;
- int endIndex = line.indexOf("<", startIndex);
- String e2servicevideosize = line.substring(startIndex, endIndex);
- tft.setTextSize(1);
- tft.setTextColor(TFT_YELLOW, TFT_BLACK);
- tft.drawString(e2servicevideosize + " ", 230, 96, 2);
- Serial.println("Rezolutie: " + e2servicevideosize);
- }
- else if (line.indexOf("e2eventname") >= 0)
- {
- int startIndex = line.indexOf(">") + 1;
- int endIndex = line.indexOf("<", startIndex);
- String e2eventname = line.substring(startIndex, endIndex);
- if (EPGacum == 1)
- {
- AfisareEPG = e2eventname;
- tft.setTextSize(2);
- tft.setTextColor(TFT_GREEN, TFT_BLACK);
- tft.drawString(AfisareEPG + " ", 0, 112, 2);
- }
- if (EPGacum == 2) AfisareEPG2 = e2eventname;
- EPGacum = EPGacum + 1;
- if (EPGacum > 2) EPGacum = 1;
- }
- else if (line.indexOf("e2eventdescription") >= 0)
- {
- int startIndex = line.indexOf(">") + 1;
- int endIndex = line.indexOf("<", startIndex);
- String e2eventdescription = line.substring(startIndex, endIndex);
- if (DescriereACUM > 4) DescriereACUM = 1;
- if (DescriereACUM == 1) AfisareDESC = e2eventdescription;
- if (DescriereACUM == 2) AfisareDescriereEPG = e2eventdescription;
- if (DescriereACUM == 3) AfisareDESC2 = e2eventdescription;
- if (DescriereACUM == 4) AfisareDescriereEPG2 = e2eventdescription;
- tft.setTextSize(1);
- tft.setTextColor(TFT_YELLOW, TFT_BLACK);
- tft.drawString(AfisareDESC.substring(0, 40) + " ", 55, 144, 2);
- tft.drawString(AfisareDESC.substring(41,80) + " ", 55, 160, 2);
- tft.setTextColor(TFT_WHITE, TFT_BLACK);
- tft.drawString(AfisareDescriereEPG.substring(0, 48) + " ", 0, 176, 2);
- tft.drawString(AfisareDescriereEPG.substring(48, 98) + " ", 0, 192, 2);
- tft.drawString(AfisareDescriereEPG.substring(98, 148) + " ", 0, 208, 2);
- tft.drawString(AfisareDescriereEPG.substring(148, 198) + " ", 0, 224, 2);
- DescriereACUM = DescriereACUM + 1;
- }
- }
- Serial.println(AfisareEPGtotal);
- client.stop();
- Serial.println("");
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement