Facebook
From Tomberg, 4 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 437
  1. #include "SPI.h"
  2. #include "Wire.h"
  3. #include "DHT.h"
  4. #include "FT_VM801B43.h"
  5. FT801IMPL_SPI FTImpl(FT_CS_PIN,FT_PDN_PIN,FT_INT_PIN);
  6.  
  7.  
  8. //------------------------------------------ Temperatuta-Wilgonosc-------------------------------
  9. DHT dht;
  10. //------------------------------------------ Koniec Temperatuta-Wilgonosc------------------------
  11.  
  12.  
  13. //------------------------------------------ SD -------------------------------------------------
  14. FT_SD FtSd(FT_SD_CSPIN);
  15. FT_SDStatus sd_present;
  16. FT_SDFile Imagefile;
  17. //------------------------------------------ Koniec SD -------------------------------------------
  18.  
  19.  
  20. //------------------------------------------ Tablica Kalibracyjna---------------------------------
  21. uint8_t touchCallibration[24] = {
  22. 0xB1, 0x63, 0x0, 0x0,
  23. 0xF, 0xFC, 0xFF, 0xFF,
  24. 0x77, 0xF9, 0xFB, 0xFF,
  25. 0x60, 0x0, 0x0, 0x0,
  26. 0xBE, 0x63, 0x0, 0x0,
  27. 0x79, 0x4A, 0xF9, 0xFF
  28. };
  29. //------------------------------------------ Koniec Tablicy Kalibracyjnej -------------------------
  30.  
  31.  
  32. //------------------------------------------ Kalibracja -------------------------------------------
  33. void kalibracja()
  34. {
  35.   FTImpl.DLStart(); // Otwieramy liste wyswietlania
  36.   FTImpl.ClearColorRGB(0x00, 0x00, 0x00); // Kolor czyszczenia czarny
  37.   FTImpl.Clear(1, 1, 1); // Czyścimy ekran
  38.   FTImpl.ColorRGB(0xFF, 0xFF, 0xFF); // Ustawiamy kolor bialy (R,G,B)
  39.  
  40.   FTImpl.Cmd_Text((FT_DISPLAYWIDTH / 2), (FT_DISPLAYHEIGHT / 2), 30, FT_OPT_CENTER, "Dotknij punkty");
  41.  
  42.   FTImpl.Cmd_FGColor(0xFFFF00); // Kolor pierwszego planu
  43.   FTImpl.Cmd_BGColor(0x444400); // Kolor drugiego planu
  44.   FTImpl.Cmd_Calibrate(0); // Kalibracja
  45.  
  46.   FTImpl.DLEnd(); // Zamykamy liste wyswietlania
  47.   FTImpl.Finish(); // Renderujemu liste i czekamy na ukonczeni
  48.  
  49.   FTImpl.SetCTouchMode(FT_CTOUCH_MODE_EXTENDED);
  50.  
  51.   // Pobranie zawartosci 12 rejestrow i wyswietlenie w konsoli
  52.   Serial.println("uint8_t touchCallibration[24] = {");
  53.  
  54.   for (uint8_t i = 0; i < 24; i++)
  55.   {
  56.     if ((i % 4 == 0) && (i > 0)) Serial.println();
  57.     Serial.print("0x");
  58.     Serial.print(FTImpl.Read(REG_CTOUCH_TRANSFORM_A + i), HEX);
  59.     if (i < 23) Serial.print(", ");
  60.   }
  61.   Serial.println();
  62.   Serial.println("};");
  63. }
  64. //------------------------------------------ Koniec Kalibracji -------------------------------------------
  65.  
  66.  
  67. //------------------------------------------ Konfiguracja Ekranu -----------------------------------------
  68. boolean DisplayInit()
  69. {
  70.   uint32_t chipid = 0;
  71.  
  72.   Serial.println("Inicjalizacja ekranu");
  73.  
  74.   // Inicjalizujemy ekran
  75.   FTImpl.Init(FT_DISPLAY_RESOLUTION);
  76.  
  77.   delay(20);
  78.  
  79.   // Pobieramy ID ukladu i sprawdzamy czy to FT801
  80.   chipid = FTImpl.Read32(FT_ROM_CHIPID);
  81.  
  82.   if (chipid != FT801_CHIPID)
  83.   {
  84.     Serial.print("Nie obslugiwany uklad: 0x");
  85.     Serial.println(chipid, HEX);
  86.     return false;
  87.   }
  88.  
  89.   Serial.print("Obslugiwany uklad: 0x");
  90.   Serial.println(chipid, HEX);
  91.  
  92.   // Wlaczamy ekran
  93.   FTImpl.SetDisplayEnablePin(FT_DISPENABLE_PIN);
  94.   FTImpl.SetAudioEnablePin(FT_AUDIOENABLE_PIN);
  95.   FTImpl.DisplayOn();
  96.   FTImpl.AudioOn();  
  97.   return true;  
  98. }
  99. //------------------------------------------ Koniec Konfiguracja Ekranu -----------------------------------
  100.  
  101.  
  102. //------------------------------------------ Sprawdzenie Karty SD -----------------------------------------
  103. void CheckStorageDevicePrecence(){
  104.   while(sd_present){
  105.     FTImpl.DLStart();    
  106.     FTImpl.Clear(1,1,1);
  107.     FTImpl.ColorRGB(255,255,255);
  108.     FTImpl.Cmd_Text(FT_DISPLAYWIDTH>>1,FT_DISPLAYHEIGHT>>1,29,FT_OPT_CENTER,"STORAGE DEVICE NOT FOUND");
  109.     FTImpl.DLEnd();
  110.     FTImpl.Finish();
  111.     delay(5000);
  112.     }
  113. }
  114. //------------------------------------------ Koniec Sprawdzenie Karty SD ------------------------------------
  115.  
  116.  
  117. //------------------------------------------ Wybór grafiki tła ----------------------------------------------
  118. #define MAX_IMAGESc  13              //  0          1          2          3          4          5         6           7         8           9           10          11          12
  119. char imagenamec[MAX_IMAGESc][13] = {"tlo1.jpg","tlo2.jpg","tlo3.jpg","tlo4.jpg","tlo5.jpg","tlo6.jpg","tlo7.jpg","tlo8.jpg","tlo9.jpg","tlo10.jpg","tlo11.jpg","tlo12.jpg","tlo13.jpg"}; // 480x272
  120. int IDimagen = 10; //nr.obrazka
  121. //------------------------------------------ Koniec Wybór grafiki tła ----------------------------------------
  122.  
  123.  
  124. //------------------------------------------------------------------------------------------------------------
  125. float Temp;
  126. long previousMillis = 0;        // will store last time was updated
  127. //long interval = 1000; // 1 sec
  128. long interval = 500;  // 0.5 sec
  129. //long interval = 150;  // 0.15 sec
  130. //long interval = 100;    // 0.1 sec
  131. //long interval = 50;   // 0.05 sec
  132. //------------------------------------------------------------------------------------------------------------
  133.  
  134.  
  135. //-------------------------------------- załaduj grafikę z Karty SD do G-RAM ---------------------------------
  136. void OpenJPGSD()
  137. {
  138.     FtSd.OpenFile(Imagefile,imagenamec[IDimagen]);    //480x272    
  139.     FTImpl.WriteCmd(CMD_LOADIMAGE);
  140.     FTImpl.BitmapSource((0));        
  141.     FTImpl.WriteCmd(480L*2*272);                      //480x272
  142.     Load_Jpeg(Imagefile);        
  143. }
  144.  
  145. void Load_Jpeg(FT_SDFile &r)
  146. {
  147.   uint8_t imbuff[512];
  148.   uint16_t blocklen;
  149.   while (r.Offset < r.Size)
  150.   {
  151.     uint16_t n = min(512, r.Size - r.Offset);
  152.     n = (n + 3) & ~3;   // force 32-bit alignment
  153.     r.ReadSector(imbuff);
  154.     FTImpl.WriteCmd(imbuff,n);
  155.   }
  156. }
  157. //-------------------------------------- koniec załaduj grafikę z Karty SD do G-RAM --------------------------
  158.  
  159.  
  160. //-------------------------------------- załaduj grafikę z  G-RAM --------------------------------------------
  161. void SeeJPG()
  162. {
  163.     FTImpl.BitmapHandle(1);
  164.     FTImpl.BitmapSource((0));    
  165.     FTImpl.BitmapLayout(FT_RGB565,480L*2,272);                  //480x272
  166.     FTImpl.BitmapSize(FT_NEAREST,FT_BORDER,FT_BORDER,480,272);  //480x272
  167.     FTImpl.Begin(FT_BITMAPS);
  168.     FTImpl.Vertex2ii(0, 0,1, 0);    
  169. }  
  170. //-------------------------------------- koniec załaduj grafikę z  G-RAM -------------------------------------
  171.  
  172.  
  173. //-------------------------------------- Odbiór danych z com -------------------------------------------------
  174. String inputString = "";         // a String to hold incoming data
  175. bool stringComplete = false;  // whether the string is complete
  176.  
  177. void odbior_danych_com() {
  178.  
  179.   while (Serial.available()) {
  180.     char inChar = Serial.read();
  181.     if (inChar != '\n')
  182.       inputString += inChar;
  183.     else {
  184.       stringComplete = true;
  185.     }
  186.   }
  187. }
  188. //-------------------------------------- koniec Odbiór danych z com ------------------------------------------
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. String inputString2 = "";
  196. String inputString3 = "";
  197. String inputString4 = "";
  198. String czujnikSwiatla = "";
  199. byte scena = 0;  //--scena
  200. //-------------------------------------------SCENA-1----------------------------------------------------------
  201. void Scena_1() {
  202. //------------------------------------------ Mainboard -------------------------------------------------------
  203. if (inputString.indexOf("M") > -1)
  204.   {
  205.     int mainboardNameStart = inputString.indexOf("M:");  
  206.     int mainboardNameEnd = inputString.indexOf("|", mainboardNameStart);
  207.     String mainboardString = inputString.substring(mainboardNameStart +2, mainboardNameEnd);
  208.  
  209.     sTagXY sTagxy;
  210.     FTImpl.GetTagXY(sTagxy);
  211.     FTImpl.TagMask(1);        
  212.     FTImpl.DLStart();
  213.  
  214.     SeeJPG();
  215.  
  216.     FTImpl.Tag(3);
  217.     FTImpl.ColorRGB(255,255,255);
  218.     FTImpl.Cmd_FGColor(0x444444); //--kolor guzika przed wcisnieciem
  219.    
  220.     int tagoption = 0;
  221.     if (sTagxy.tag == 3) {
  222.     tagoption = FT_OPT_FLAT; //--guzik
  223.     FTImpl.Cmd_FGColor(0x880000); //--kolor guzika po wcisnieciu
  224.     //FTImpl.ColorRGB(0, 0, 255); //--kolor tekstu po wcisnieciu
  225.  
  226.     scena = 3;   //--scena nr.3
  227.     }
  228.  
  229.     FTImpl.Cmd_Button(6, 6, 23, 23, 27, tagoption, "S"); //--guzik
  230.     //const char Display_string[12] = "<--"; //--teks
  231.     //FTImpl.Cmd_Text(426, -7, 30, tagoption, Display_string);  //--tekst
  232.     FTImpl.TagMask(0);
  233.  
  234.     FTImpl.ColorRGB(255,255,255);
  235.     FTImpl.Cmd_Text(150, 5, 18, 0, mainboardString.c_str());     //**** Nazwa Płyty          
  236.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  237.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  238.   }
  239.  
  240. //------------------------------------------ CPU Name -------------------------------------------------------
  241. if (inputString.indexOf("CPU") > -1)
  242.   {
  243.     int cpuNameStart = inputString.indexOf("CPU:");  
  244.     int cpuNameEnd = inputString.indexOf("|", cpuNameStart);
  245.     String cpuString = inputString.substring(cpuNameStart +4, cpuNameEnd);
  246.          
  247.     //FTImpl.DLStart();
  248.     FTImpl.ColorRGB(255,255,255);
  249.     FTImpl.Cmd_Text(120, 20, 18, 0, cpuString.c_str());     //**** Nazwa Procesora          
  250.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  251.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  252.   }
  253.  
  254. //------------------------------------------ Core #1 - #6 Temperature ----------------------------------------
  255. if (inputString.indexOf("CPUtem") > -1)
  256.   {
  257.     int cpuTempStart = inputString.indexOf("CPUtem:");  
  258.     int cpuTempEnd = inputString.indexOf("|", cpuTempStart);
  259.     String cpuTempString = inputString.substring(cpuTempStart +7, cpuTempEnd);    
  260.    
  261.     String degreeChar = String(char(248));
  262.     const char tempC[12] = "C";
  263.     String CPU_temp = ("CPU Temp.  " + cpuTempString);
  264.    
  265.     sTagXY sTagxy;
  266.     FTImpl.GetTagXY(sTagxy);
  267.  
  268.     FTImpl.TagMask(1);            
  269.     FTImpl.Tag(1);
  270.     FTImpl.ColorRGB(0,255,0);
  271.     int tagoption = 0;
  272.     if (sTagxy.tag == 1) {
  273.     FTImpl.ColorRGB(0, 0, 255);
  274.  
  275.     scena = 2;   //--scena nr.2
  276.   }    
  277.     //FTImpl.DLStart();
  278.     FTImpl.ColorRGB(0,255,0);
  279.     FTImpl.Cmd_Text(170, 40, 28, tagoption, CPU_temp.c_str());     //**** Core #1 - #6 Temperature
  280.     FTImpl.Cmd_Text(350, 43, 19, 0, degreeChar.c_str()); //--degree
  281.     FTImpl.Cmd_Text(357, 40, 28, 0, tempC);
  282.     FTImpl.TagMask(0);  
  283.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  284.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  285.   }
  286.  
  287. //------------------------------------------ CPU Core #1 MHz -------------------------------------------------
  288. if (inputString.indexOf("CPUz1") > -1)
  289.   {
  290.     int cpu1ClockStart = inputString.indexOf("CPUz1:");  
  291.     int cpu1ClockEnd = inputString.indexOf("|", cpu1ClockStart);
  292.     String cpu1ClockString = inputString.substring(cpu1ClockStart +6, cpu1ClockEnd);
  293.     String CPU_1_MHz = ("CPU Core 1  " + cpu1ClockString + " MHz");
  294.          
  295.     //FTImpl.DLStart();
  296.     FTImpl.ColorRGB(255,255,255);
  297.     FTImpl.Cmd_Text(60, 65, 18, 0, CPU_1_MHz.c_str());     //**** CPU Core #1 MH          
  298.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  299.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  300.   }
  301.  
  302. //------------------------------------------ CPU Core #2 MHz -------------------------------------------------
  303. if (inputString.indexOf("CPUz2") > -1)
  304.   {
  305.     int cpu2ClockStart = inputString.indexOf("CPUz2:");  
  306.     int cpu2ClockEnd = inputString.indexOf("|", cpu2ClockStart);
  307.     String cpu2ClockString = inputString.substring(cpu2ClockStart +6, cpu2ClockEnd);
  308.     String CPU_2_MHz = ("CPU Core 2  " + cpu2ClockString + " MHz");
  309.          
  310.     //FTImpl.DLStart();
  311.     FTImpl.ColorRGB(255,255,255);
  312.     FTImpl.Cmd_Text(60, 80, 18, 0, CPU_2_MHz.c_str());     //**** CPU Core #2 MH          
  313.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  314.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  315.   }
  316.  
  317. //------------------------------------------ CPU Core #3 MHz -------------------------------------------------
  318. if (inputString.indexOf("CPUz3") > -1)
  319.   {
  320.     int cpu3ClockStart = inputString.indexOf("CPUz3:");  
  321.     int cpu3ClockEnd = inputString.indexOf("|", cpu3ClockStart);
  322.     String cpu3ClockString = inputString.substring(cpu3ClockStart +6, cpu3ClockEnd);
  323.     String CPU_3_MHz = ("CPU Core 3  " + cpu3ClockString + " MHz");
  324.          
  325.     //FTImpl.DLStart();
  326.     FTImpl.ColorRGB(255,255,255);
  327.     FTImpl.Cmd_Text(60, 95, 18, 0, CPU_3_MHz.c_str());     //**** CPU Core #3 MH          
  328.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  329.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  330.   }
  331.  
  332. //------------------------------------------ CPU Core #4 MHz -------------------------------------------------
  333. if (inputString.indexOf("CPUz4") > -1)
  334.   {
  335.     int cpu4ClockStart = inputString.indexOf("CPUz4:");  
  336.     int cpu4ClockEnd = inputString.indexOf("|", cpu4ClockStart);
  337.     String cpu4ClockString = inputString.substring(cpu4ClockStart +6, cpu4ClockEnd);
  338.     String CPU_4_MHz = ("CPU Core 4  " + cpu4ClockString + " MHz");
  339.          
  340.     //FTImpl.DLStart();
  341.     FTImpl.ColorRGB(255,255,255);
  342.     FTImpl.Cmd_Text(60, 110, 18, 0, CPU_4_MHz.c_str());     //**** CPU Core #4 MH          
  343.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  344.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  345.   }
  346.  
  347. //------------------------------------------ CPU Core #5 MHz -------------------------------------------------
  348. if (inputString.indexOf("CPUz5") > -1)
  349.   {
  350.     int cpu5ClockStart = inputString.indexOf("CPUz5:");  
  351.     int cpu5ClockEnd = inputString.indexOf("|", cpu5ClockStart);
  352.     String cpu5ClockString = inputString.substring(cpu5ClockStart +6, cpu5ClockEnd);
  353.     String CPU_5_MHz = ("CPU Core 5  " + cpu5ClockString + " MHz");
  354.          
  355.     //FTImpl.DLStart();
  356.     FTImpl.ColorRGB(255,255,255);
  357.     FTImpl.Cmd_Text(60, 125, 18, 0, CPU_5_MHz.c_str());     //**** CPU Core #5 MH          
  358.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  359.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  360.   }
  361.  
  362. //------------------------------------------ CPU Core #6 MHz -------------------------------------------------
  363. if (inputString.indexOf("CPUz6") > -1)
  364.   {
  365.     int cpu6ClockStart = inputString.indexOf("CPUz6:");  
  366.     int cpu6ClockEnd = inputString.indexOf("|", cpu6ClockStart);
  367.     String cpu6ClockString = inputString.substring(cpu6ClockStart +6, cpu6ClockEnd);
  368.     String CPU_6_MHz = ("CPU Core 6  " + cpu6ClockString + " MHz");
  369.          
  370.     //FTImpl.DLStart();
  371.     FTImpl.ColorRGB(255,255,255);
  372.     FTImpl.Cmd_Text(60, 140, 18, 0, CPU_6_MHz.c_str());     //**** CPU Core #6 MH          
  373.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  374.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  375.   }
  376.  
  377. //------------------------------------------ CPU Core #1 % -------------------------------------------------
  378. if (inputString.indexOf("CPUo1") > -1)
  379.   {
  380.     int cpu1LoadStart = inputString.indexOf("CPUo1:");  
  381.     int cpu1LoadEnd = inputString.indexOf("|", cpu1LoadStart);
  382.     String cpu1LoadString = inputString.substring(cpu1LoadStart +6, cpu1LoadEnd);
  383.     String CPU_1_p = ("CPU Core 1  " + cpu1LoadString + " %");
  384.          
  385.     //FTImpl.DLStart();
  386.     FTImpl.ColorRGB(255,255,255);
  387.     FTImpl.Cmd_Text(250, 65, 18, 0, CPU_1_p.c_str());     //**** CPU Core #1 %          
  388.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  389.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  390.   }
  391.  
  392. //------------------------------------------ CPU Core #2 % -------------------------------------------------
  393. if (inputString.indexOf("CPUo2") > -1)
  394.   {
  395.     int cpu2LoadStart = inputString.indexOf("CPUo2:");  
  396.     int cpu2LoadEnd = inputString.indexOf("|", cpu2LoadStart);
  397.     String cpu2LoadString = inputString.substring(cpu2LoadStart +6, cpu2LoadEnd);
  398.     String CPU_2_p = ("CPU Core 2  " + cpu2LoadString + " %");
  399.          
  400.     //FTImpl.DLStart();
  401.     FTImpl.ColorRGB(255,255,255);
  402.     FTImpl.Cmd_Text(250, 80, 18, 0, CPU_2_p.c_str());     //**** CPU Core #2 %          
  403.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  404.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  405.   }
  406.  
  407. //------------------------------------------ CPU Core #3 % -------------------------------------------------
  408. if (inputString.indexOf("CPUo3") > -1)
  409.   {
  410.     int cpu3LoadStart = inputString.indexOf("CPUo3:");  
  411.     int cpu3LoadEnd = inputString.indexOf("|", cpu3LoadStart);
  412.     String cpu3LoadString = inputString.substring(cpu3LoadStart +6, cpu3LoadEnd);
  413.     String CPU_3_p = ("CPU Core 3  " + cpu3LoadString + " %");
  414.          
  415.     //FTImpl.DLStart();
  416.     FTImpl.ColorRGB(255,255,255);
  417.     FTImpl.Cmd_Text(250, 95, 18, 0, CPU_3_p.c_str());     //**** CPU Core #3 %          
  418.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  419.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  420.   }
  421.  
  422. //------------------------------------------ CPU Core #4 % -------------------------------------------------
  423. if (inputString.indexOf("CPUo4") > -1)
  424.   {
  425.     int cpu4LoadStart = inputString.indexOf("CPUo4:");  
  426.     int cpu4LoadEnd = inputString.indexOf("|", cpu4LoadStart);
  427.     String cpu4LoadString = inputString.substring(cpu4LoadStart +6, cpu4LoadEnd);
  428.     String CPU_4_p = ("CPU Core 4  " + cpu4LoadString + " %");
  429.          
  430.     //FTImpl.DLStart();
  431.     FTImpl.ColorRGB(255,255,255);
  432.     FTImpl.Cmd_Text(250, 110, 18, 0, CPU_4_p.c_str());     //**** CPU Core #4 %          
  433.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  434.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  435.   }
  436.  
  437. //------------------------------------------ CPU Core #5 % -------------------------------------------------
  438. if (inputString.indexOf("CPUo5") > -1)
  439.   {
  440.     int cpu5LoadStart = inputString.indexOf("CPUo5:");  
  441.     int cpu5LoadEnd = inputString.indexOf("|", cpu5LoadStart);
  442.     String cpu5LoadString = inputString.substring(cpu5LoadStart +6, cpu5LoadEnd);
  443.     String CPU_5_p = ("CPU Core 5  " + cpu5LoadString + " %");
  444.          
  445.     //FTImpl.DLStart();
  446.     FTImpl.ColorRGB(255,255,255);
  447.     FTImpl.Cmd_Text(250, 125, 18, 0, CPU_5_p.c_str());     //**** CPU Core #5 %          
  448.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  449.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  450.   }
  451.  
  452. //------------------------------------------ CPU Core #6 % -------------------------------------------------
  453. if (inputString.indexOf("CPUo6") > -1)
  454.   {
  455.     int cpu6LoadStart = inputString.indexOf("CPUo6:");  
  456.     int cpu6LoadEnd = inputString.indexOf("|", cpu6LoadStart);
  457.     String cpu6LoadString = inputString.substring(cpu6LoadStart +6, cpu6LoadEnd);
  458.     String CPU_6_p = ("CPU Core 6  " + cpu6LoadString + " %");
  459.          
  460.     //FTImpl.DLStart();
  461.     FTImpl.ColorRGB(255,255,255);
  462.     FTImpl.Cmd_Text(250, 140, 18, 0, CPU_6_p.c_str());     //**** CPU Core #6 %          
  463.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  464.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  465.   }
  466.  
  467.  
  468. //------------------------------------------ CPU Bus Speed -------------------------------------------------
  469. if (inputString.indexOf("CPUbu") > -1)
  470.   {
  471.     int bsClockStart = inputString.indexOf("CPUbu:");  
  472.     int bsClockEnd = inputString.indexOf("|", bsClockStart);
  473.     String bsClockString = inputString.substring(bsClockStart +6, bsClockEnd);
  474.     String CPU_Bus_Speed = ("CPU Bus Speed  " + bsClockString + " MHz");
  475.          
  476.     //FTImpl.DLStart();
  477.     FTImpl.ColorRGB(255,255,255);
  478.     FTImpl.Cmd_Text(150, 155, 18, 0, CPU_Bus_Speed.c_str());     //**** CPU Bus Speed    
  479.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  480.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  481.   }
  482.  
  483. //------------------------------------------ GPU Name -------------------------------------------------
  484. if (inputString.indexOf("GPU") > -1)
  485.   {
  486.     int gpuNameStart = inputString.indexOf("GPU:");  
  487.     int gpuNameEnd = inputString.indexOf("|", gpuNameStart);
  488.     String gpuString = inputString.substring(gpuNameStart +4, gpuNameEnd);
  489.          
  490.     //FTImpl.DLStart();
  491.     FTImpl.ColorRGB(255,255,255);
  492.     FTImpl.Cmd_Text(140, 175, 18, 0, gpuString.c_str());     //**** Nazwa Karty Graficznej          
  493.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  494.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  495.   }
  496.  
  497. //------------------------------------------ GPU Temperature -------------------------------------------------
  498. if (inputString.indexOf("GPUtem") > -1)
  499.   {
  500.     int gpuTempStart = inputString.indexOf("GPUtem:");  
  501.     int gpuTempEnd = inputString.indexOf("|", gpuTempStart);
  502.     String gpuTempString = inputString.substring(gpuTempStart +7, gpuTempEnd);
  503.     String GPU_temp = ("GPU Temp.  " + gpuTempString);
  504.     String degreeChar2 = String(char(248));
  505.     const char tempGC[12] = "C";
  506.          
  507.     //FTImpl.DLStart();
  508.     FTImpl.ColorRGB(0,255,0);
  509.     FTImpl.Cmd_Text(170, 190, 28, 0, GPU_temp.c_str());     //**** GPU Temperature
  510.     FTImpl.Cmd_Text(350, 193, 19, 0, degreeChar2.c_str()); //--degree
  511.     FTImpl.Cmd_Text(357, 190, 28, 0, tempGC);    
  512.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  513.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  514.   }
  515.  
  516. //------------------------------------------ GPU Core Clock-------------------------------------------------
  517. if (inputString.indexOf("GPUz") > -1)
  518.   {
  519.     int gpuClockStart = inputString.indexOf("GPUz:");  
  520.     int gpuClockEnd = inputString.indexOf("|", gpuClockStart);
  521.     String gpuClockString = inputString.substring(gpuClockStart +5, gpuClockEnd);
  522.     String GPU_Clock = ("GPU Core Clock  " + gpuClockString + " MHz");
  523.          
  524.     //FTImpl.DLStart();
  525.     FTImpl.ColorRGB(255,255,255);
  526.     FTImpl.Cmd_Text(20, 215, 18, 0, GPU_Clock.c_str());     //**** GPU Core Clock    
  527.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  528.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  529.   }
  530.  
  531. //------------------------------------------ GPU Memory Clock -------------------------------------------------
  532. if (inputString.indexOf("GPUzm") > -1)
  533.   {
  534.     int gpuMemoryStart = inputString.indexOf("GPUzm:");  
  535.     int gpuMemoryEnd = inputString.indexOf("|", gpuMemoryStart);
  536.     String gpuMemoryString = inputString.substring(gpuMemoryStart +6, gpuMemoryEnd);
  537.     String GPU_Memory_Clock = ("GPU Memory Clock  " + gpuMemoryString + " MHz");
  538.          
  539.     //FTImpl.DLStart();
  540.     FTImpl.ColorRGB(255,255,255);
  541.     FTImpl.Cmd_Text(230, 215, 18, 0, GPU_Memory_Clock.c_str());     //**** GPU Memory Clock    
  542.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  543.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  544.   }
  545.  
  546. //------------------------------------------ RAM Used Memory -------------------------------------------------
  547.  
  548. if (inputString.indexOf("Ru") > -1)
  549.   {
  550.     int ramUsedStart = inputString.indexOf("Ru:");  
  551.     int ramUsedEnd = inputString.indexOf("|", ramUsedStart);
  552.     String ramUsedString = inputString.substring(ramUsedStart +3, ramUsedEnd);
  553.     String RAM_Used_Memory = ("RAM Used  " + ramUsedString + " GB");
  554.          
  555.     //FTImpl.DLStart();
  556.     FTImpl.ColorRGB(255,0,0);
  557.     FTImpl.Cmd_Text(230, 235, 18, 0, RAM_Used_Memory.c_str());     //**** RAM Used Memory    
  558.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  559.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  560.   }
  561.  
  562. //------------------------------------------ RAM Available Memory ----------------------------------------------
  563. if (inputString.indexOf("Rw") > -1)
  564.   {
  565.     int ramAvailablStart = inputString.indexOf("Rw:");  
  566.     int ramAvailablEnd = inputString.indexOf("|", ramAvailablStart);
  567.     String ramAvailablString = inputString.substring(ramAvailablStart +3, ramAvailablEnd);
  568.     String RAM_Available_Memory = ("RAM Available  " + ramAvailablString + " GB");
  569.          
  570.     //FTImpl.DLStart();
  571.     FTImpl.ColorRGB(0,85,255);
  572.     FTImpl.Cmd_Text(20, 235, 18, 0, RAM_Available_Memory.c_str());     //**** RAM Available Memory    
  573.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  574.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  575.   }
  576.  
  577. //------------------------------------------ HDD Name ----------------------------------------------------------
  578. if (inputString.indexOf("HDD") > -1)
  579.   {
  580.     int hddNameStart = inputString.indexOf("HDD:");  
  581.     int hddNameEnd = inputString.indexOf("|", hddNameStart);
  582.     String hddString = inputString.substring(hddNameStart +4, hddNameEnd);
  583.     String HDD_Name = ("HDD " + hddString);
  584.          
  585.     //FTImpl.DLStart();
  586.     FTImpl.ColorRGB(255,255,255);
  587.     FTImpl.Cmd_Text(20, 255, 18, 0, HDD_Name.c_str());     //**** Nazwa Dysku          
  588.     //FTImpl.DLEnd();// Zamykamy liste wyswietlania
  589.     //FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  590.   }
  591. //------------------------------------------ HDD Used ----------------------------------------------------------
  592. if (inputString.indexOf("HDDu") > -1)
  593.   {
  594.     int hddUsedStart = inputString.indexOf("HDDu:");  
  595.     int hddUsedEnd = inputString.indexOf("|", hddUsedStart);
  596.     String hdduString = inputString.substring(hddUsedStart +5, hddUsedEnd);
  597.     String HDD_Used = ("HDD Used  " + hdduString + " %");
  598.          
  599.     //FTImpl.DLStart();
  600.     FTImpl.ColorRGB(255,0,0);
  601.     FTImpl.Cmd_Text(230, 255, 18, 0, HDD_Used.c_str());     //**** Nazwa Dysku  
  602.     FTImpl.DLEnd();// Zamykamy liste wyswietlania
  603.     FTImpl.Finish();// Renderujemu liste i czekamy na ukonczenie    
  604.   }  
  605. }
  606. //------------------------------------------ Koniec wyświetlania odebranych danych ----------------------------------
  607. //-------------------------------------------Koniec SCENA-1----------------------------------------------------------
  608.  
  609.  
  610.  
  611.  
  612. //-------------------------------------------SCENA-2-----------------------------------------------------------------
  613. void Scena_2() {
  614.  
  615.   sTagXY sTagxy;
  616.   FTImpl.GetTagXY(sTagxy);
  617.   FTImpl.TagMask(1);        
  618.   FTImpl.DLStart();
  619.  
  620.   SeeJPG();
  621.  
  622.   FTImpl.Tag(2);
  623.   FTImpl.ColorRGB(255,255,255);
  624.   FTImpl.Cmd_FGColor(0x444444); //--kolor guzika po wcisnieciu
  625.    
  626.   int tagoption = 0;
  627.     if (sTagxy.tag == 2) {
  628.     tagoption = FT_OPT_FLAT; //--guzik
  629.     FTImpl.Cmd_FGColor(0x880000); //--kolor guzika po wcisnieciu
  630.     //FTImpl.ColorRGB(0, 0, 255); //--kolor tekstu po wcisnieciu
  631.  
  632.     scena = 1;   //--scena nr.1
  633.   }
  634.  
  635.   FTImpl.Cmd_Button(449, 6, 23, 23, 27, tagoption, "<"); //--guzik
  636.    //const char Display_string[12] = "<--"; //--teks
  637.   //FTImpl.Cmd_Text(426, -7, 30, tagoption, Display_string);  //--tekst
  638.   FTImpl.TagMask(0);
  639.  
  640.   if (stringComplete) {
  641.     if (inputString.indexOf("CPUtem") > -1) {
  642.       int cpuTempStart = inputString.indexOf("CPUtem:");  
  643.       int cpuTempEnd = inputString.indexOf("|", cpuTempStart);
  644.       String cpuTempString = inputString.substring(cpuTempStart +7, cpuTempEnd);
  645.  
  646.       FTImpl.ColorRGB(223,0,0);
  647.       const char Display_cputem[12] = "CPU Temp.";
  648.       FTImpl.Cmd_Text(45, 144, 30, 0, Display_cputem);
  649.  
  650.       const char Display_o[12] = "o";
  651.       FTImpl.ColorRGB(223,0,0);
  652.       FTImpl.Cmd_Text(365, 140, 27, 0, Display_o); //--o
  653.  
  654.       String CPU_temp = (cpuTempString);
  655.       FTImpl.ColorRGB(223,0,0);    
  656.       FTImpl.Cmd_Text(235, 140, 31, 0, CPU_temp.c_str());     //**** Core #1 - #6 Temperature
  657.  
  658.       const char Display_c[12] = "C";
  659.       FTImpl.ColorRGB(223,0,0);
  660.       FTImpl.Cmd_Text(370, 140, 31, 0, Display_c); //--c              
  661.     }
  662.   }
  663.  
  664.   inputString4 = (dht.getTemperature());
  665.  
  666.   if (inputString4.indexOf('\n')) {
  667.     FTImpl.ColorRGB(255,255,255);
  668.     const char Display_tem[12] = "Temperatura";
  669.     FTImpl.Cmd_Text(45, 50, 29, 0, Display_tem);
  670.  
  671.     const char Display_o[12] = "o";
  672.     FTImpl.ColorRGB(255,255,255);
  673.     FTImpl.Cmd_Text(345, 41, 27, 0, Display_o); //--o
  674.    
  675.     String temperatura = (inputString4 + " C");
  676.     FTImpl.ColorRGB(255,255,255);
  677.     FTImpl.Cmd_Text(235, 40, 31, 0, temperatura.c_str());     //**** Temperatura
  678.   }
  679.   FTImpl.DLEnd();
  680.   FTImpl.Finish();
  681. }
  682. //-------------------------------------------Koniec SCENA-2----------------------------------------------------------
  683.  
  684.  
  685.  
  686. //-------------------------------------------SCENA-3-----------------------------------------------------------------
  687. void Scena_3() {
  688.  
  689.   sTagXY sTagxy;
  690.   FTImpl.GetTagXY(sTagxy);
  691.   FTImpl.TagMask(1);        
  692.   FTImpl.DLStart();
  693.  
  694.   SeeJPG();
  695.      
  696.   FTImpl.Tag(3);
  697.   FTImpl.ColorRGB(255,255,255);
  698.   FTImpl.Cmd_FGColor(0x444444); //--kolor guzika po wcisnieciu
  699.    
  700.   int tagoption = 0;
  701.   if (sTagxy.tag == 3) {
  702.     tagoption = FT_OPT_FLAT; //--guzik
  703.     FTImpl.Cmd_FGColor(0x880000); //--kolor guzika po wcisnieciu
  704.     //FTImpl.ColorRGB(0, 0, 255); //--kolor tekstu po wcisnieciu
  705.    
  706.     scena = 1;   //--scena nr.1
  707.   }
  708.  
  709.   FTImpl.Cmd_Button(449, 6, 23, 23, 27, tagoption, "<"); //--guzik
  710.    //const char Display_string[12] = "<--"; //--teks
  711.   //FTImpl.Cmd_Text(426, -7, 30, tagoption, Display_string);  //--tekst
  712.   FTImpl.TagMask(0);
  713.  
  714.   inputString2 = (dht.getHumidity());
  715.   inputString3 = (dht.getTemperature());
  716.  
  717.  
  718.  if (inputString2.indexOf('\n')) {
  719.   FTImpl.ColorRGB(255,255,255);
  720.   const char Display_wil[12] = "Wilgotnosc";
  721.   FTImpl.Cmd_Text(55, 120, 29, 0, Display_wil);
  722.  
  723.   String wilgotnosc = (inputString2 + " %");
  724.   FTImpl.ColorRGB(255,255,255);
  725.   FTImpl.Cmd_Text(235, 110, 31, 0, wilgotnosc.c_str());     //**** Wilgotność      
  726.   }
  727.   if (inputString3.indexOf('\n')) {
  728.     FTImpl.ColorRGB(255,255,255);
  729.     const char Display_tem[12] = "Temperatura";
  730.     FTImpl.Cmd_Text(45, 50, 29, 0, Display_tem);
  731.  
  732.     const char Display_o[12] = "o";
  733.     FTImpl.ColorRGB(255,255,255);
  734.     FTImpl.Cmd_Text(345, 41, 27, 0, Display_o); //--o
  735.    
  736.     String temperatura = (inputString3 + " C");
  737.     FTImpl.ColorRGB(255,255,255);
  738.     FTImpl.Cmd_Text(235, 40, 31, 0, temperatura.c_str());     //**** Temperatura
  739.   }
  740.  
  741. int fotoPin = 0;    
  742. int fotoDane;
  743.  
  744. if (fotoDane = analogRead(fotoPin)) {
  745.   czujnikSwiatla = String(fotoDane); //********** int na string
  746. }
  747.  
  748.   if (czujnikSwiatla.indexOf('\n')) {
  749.     FTImpl.ColorRGB(255,255,255);
  750.     const char Display_nat[12] = "Natezenie";
  751.     FTImpl.Cmd_Text(60, 178, 29, 0, Display_nat);
  752.    
  753.     String lux = (czujnikSwiatla + " Lux");
  754.     FTImpl.ColorRGB(255,255,0);
  755.     FTImpl.Cmd_Text(235, 170, 31, 0, lux.c_str());     //**** Temperatura
  756.     //delay(500);
  757.   }
  758.   FTImpl.DLEnd();
  759.   FTImpl.Finish();
  760. }
  761. //-------------------------------------------Koniec SCENA-3----------------------------------------------------------
  762.  
  763.  
  764. //--------------------------------------- Load Spinner --------------------------------------------------------------
  765. void load()
  766. {
  767.   FTImpl.DLStart(); // Otwieramy liste wyswietlania  
  768.   FTImpl.Cmd_Gradient (-3,32,32767,347,162,8388352);
  769.   FTImpl.ColorRGB(255, 0, 0);
  770.   FTImpl.Cmd_Text(117, 80, 28, 0, "Czekam na dane z com ");
  771.   FTImpl.Cmd_Spinner(228, 140, 1, 0);  
  772.   FTImpl.DLEnd(); // Zamykamy liste wyswietlania
  773.   FTImpl.Finish(); // Renderujemu liste i czekamy na ukonczenie
  774. }  
  775. //--------------------------------------- Koniec Load Spinner --------------------------------------------------------
  776.  
  777.  
  778.  
  779.  
  780. void setup()
  781. {
  782.         Serial.begin(9600);  
  783.   inputString.reserve(200);
  784.   dht.setup(2); // data pin 2
  785.  
  786. //******************** Kalibracja *******************************************    
  787.     //kalibracja(); // tylko raz zobacz film https://www.youtube.com/watch?v=TLOuicryrKM
  788.     // Jesli mamy juz skalibrowany
  789.    
  790.     while (!DisplayInit()) {}    
  791.     FTImpl.SetCTouchMode(FT_CTOUCH_MODE_EXTENDED);    
  792.     for (uint8_t i = 0; i < 24; i++)
  793.    {
  794.      FTImpl.Write(REG_CTOUCH_TRANSFORM_A + i, touchCallibration[i]);
  795.    }  
  796. //******************** Koniec Kalibracji ***********************************
  797.  
  798.   sd_present = FtSd.Init(); //--Odpalenie SD
  799.   CheckStorageDevicePrecence(); //--Sprawdzenie SD
  800.  
  801.   OpenJPGSD();
  802.   load();
  803.   scena = 1;   //--scena nr.1
  804. }
  805.  
  806.  
  807.  
  808. void loop()
  809. {
  810.   odbior_danych_com();
  811.  
  812.   switch (scena)
  813.    {
  814.     case 1:
  815.       if (stringComplete) {
  816.       Scena_1();
  817.       inputString = "";
  818.       stringComplete = false;
  819.       }  
  820.       break;
  821.     case 2:
  822.       if (stringComplete) {
  823.         Scena_2();
  824.         inputString = "";
  825.         String inputString2 = "";
  826.         String inputString3 = "";
  827.         String inputString4 = "";
  828.         String czujnikSwiatla = "";
  829.         stringComplete = false;
  830.         }
  831.       break;
  832.      case 3:
  833.      if (stringComplete) {
  834.         Scena_3();
  835.         inputString = "";
  836.         String inputString2 = "";
  837.         String inputString3 = "";
  838.         String czujnikSwiatla = "";
  839.         stringComplete = false;
  840.         }
  841.      break;
  842.     default:
  843.       if (stringComplete) {
  844.       Scena_1();
  845.       inputString = "";
  846.       stringComplete = false;
  847.       }  
  848.   }
  849. }
  850. /* Nothing beyond this */