Advertisement
PowerTGS440

ESP32-WeatherStation_tft_0.20

Mar 28th, 2021
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 98.50 KB | None | 0 0
  1. extern TFT_eSPI tft;
  2. extern TPogoda pogoda;
  3. extern Tools tools;
  4.  
  5. // =========================================================================================================== //
  6. //
  7. // Plik        : esp32_tft.h                                                                
  8. // Wersja      : 0.20 Beta                                                                      
  9. // Data        : 27.03.2021                                                                    
  10. // Autor       : TRANSLINE GROUP, Tomasz Majcher, Lubin                                        
  11. //
  12. //
  13. // E-Mail      : transline.majcher@gmail.com    
  14. //  
  15. //                                                        
  16. // Licencja v1 : Donationware. Oprogramowanie na tej licencji może być dowolnie modyfikowane, kopiowane    
  17. //               i dystrybuowane pod warunkiem, że licencjobiorca zapłaci autorowi symboliczną kwotę.      
  18. //               Wielkość opłaty zależy od licencjobiorcy.
  19. //                                                
  20. //                                                                                                        
  21. // Licencja v2 : OpenSource. Oprogramowanie na tej licencji może być dowolnie modyfikowane, kopiowane      
  22. //               i dystrybuowane pod warenkiem, że licencjobiorca jest członkiem grupy: ESP Projekty      
  23. //               oraz ESP Polska                                                                          
  24. //                                                                                                        
  25. // =========================================================================================================== //
  26. // === H I S T O R I A   W E R S J I ========================================================================= //
  27. // =========================================================================================================== //
  28. //
  29. // wersja 0.20 STABLE - BETA (28.03.2021) - obłusga 32bitowych Bitmap
  30. // wersja 0.19 STABLE - BETA (28.03.2021) - obłusga 16bitowych Bitmap
  31. // wersja 0.18 STABLE - BETA (28.03.2021) - dodano bitmapy dla Cisnienie
  32. // wersja 0.17 STABLE - BETA (28.03.2021) - dodano bitmapy dla Wilgotnosc
  33. // wersja 0.16 STABLE - BETA (27.03.2021) - zmieniono kolory dla Wilgotnosc
  34. // wersja 0.15 STABLE - BETA (27.03.2021) - dodano DrawWilgotnoscColor
  35. // wersja 0.14 STABLE - BETA (27.03.2021) - dodano DrawTemperatureColor
  36. // wersja 0.13 STABLE - BETA (27.03.2021) - dodano panel v1 Pokaz Lokalizacje
  37. // wersja 0.12 STABLE - BETA (27.03.2021) - dodano panel v1 Zachód Słońca
  38. // wersja 0.11 STABLE - BETA (27.03.2021) - dodano panel v1 Wschod Słońca
  39. // wersja 0.10 STABLE - BETA (27.03.2021) - dodano panel v1 Predkosc Wiatru
  40. // wersja 0.09 STABLE - BETA (27.03.2021) - dodano panel v1 Wilgotnosc
  41. // wersja 0.08 STABLE - BETA (27.03.2021) - dodano panel v1 Zachmurzenie
  42. // wersja 0.07 STABLE - BETA (27.03.2021) - dodano panel v1 Code MSG
  43. // wersja 0.06 STABLE - BETA (27.03.2021) - dodano panel v1 Cisnienie
  44. // wersja 0.05 STABLE - BETA (27.03.2021) - dodano obsługę Terminal
  45. // wersja 0.04 SIMPLE - BETA (27.03.2021) - rozbudowa panel v1
  46. // wersja 0.03 SIMPLE - BETA (27.03.2021) - dodano panel Zegar RTC
  47. // wersja 0.02 SIMPLE - BETA (26.03.2021) - dodano panel v1 Temperatura
  48. // wersja 0.01 SIMPLE - BETA (26.03.2021) - budowa klasy TFTPanel          
  49. //                                                                                                             //
  50. // =========================================================================================================== //
  51. // === D E F I N I C J E ===================================================================================== //
  52. // =========================================================================================================== //
  53.  
  54. #define Color_Bakground   TFT_BLACK    
  55. #define Color_Line        tft.color565(37, 205, 245)
  56. #define TFT_kolor_zegara  tft.color565(37, 205, 245)
  57. #define TFT_BLUE2         tft.color565(0, 128, 255)
  58. #define TFT_GREEN1        tft.color565(51, 255, 153)
  59. #define TFT_tlo_zegara    TFT_BLACK    
  60.  
  61. #define Terminal          1                                         // terminal USB
  62.  
  63. // =========================================================================================================== //
  64. // === P R O T O T Y P Y ===================================================================================== //
  65. // =========================================================================================================== //
  66.  
  67. struct OKNO_v1
  68. {
  69.     int       value_min   = 0;
  70.     int       value_max   = 0;
  71.     int       value_step  = 0;
  72.     String    value_name;
  73.  
  74.     int pos_y = 0;
  75.  
  76.     float ltx = 0;                
  77.     uint16_t osx = 120, osy = 120;
  78.     int old_analog =  -999;      
  79.     int old_value = 0;
  80.     int d = 0;  
  81. }
  82. Window_TFT_up, Window_TFT_down;
  83.  
  84. // =========================================================================================================== //
  85. // === K L A S A   T F T P a n e l =========================================================================== //
  86. // =========================================================================================================== //
  87.  
  88. class TFTPanel
  89. {
  90.     private: // metody i zmienne prywatne -------------------------------------------------------------------- //
  91.  
  92.         TFT_eSPI & tft;
  93.  
  94.         uint16_t  screen_min_x   =  0;                                      // minimalny punkt x
  95.         uint16_t  screen_min_y   =  0;                                      // minimalny punkt y
  96.         uint16_t  screen_max_x   =  240;                                    // maksymalny punkt x
  97.         uint16_t  screen_max_y   =  320;                                    // maksymalny punkt y
  98.         uint16_t  window_min_x   =  1;                                      // minimalny punkt x OKNA
  99.         uint16_t  window_min_y   =  1;                                      // minimalny punkt y OKNA
  100.         uint16_t  window_max_x   =  239;                                    // maksymalny punkt x OKNA
  101.         uint16_t  window_max_y   =  319;                                    // maksymalny punkt y OKNA
  102.        
  103.         uint16_t  window_size_x  =  window_max_x - window_min_x;            // maksymalna szerokość OKNA
  104.         uint16_t  window_size_y  =  window_max_y - window_min_y;            // maksymalna wysokość OKNA
  105.  
  106.         uint16_t  window_up_v1   =  70;                                     // pozycja y dla OKNA górnego v1
  107.         uint16_t  window_down_v1 = 190;                                     // pozycja y dla OKNA dolnego v1            
  108.  
  109.         uint8_t   Godzina        = 0;                                       // czas z zegara RTC
  110.         uint8_t   Minuta         = 0;                                       // czas z zegara RTC
  111.         uint8_t   Sekunda        = 0;                                       // czas z zegara RTC
  112.         String    AmPm           = "";                                      // AM / PM
  113.         String    Data           = "";                                      // data z RTC
  114.        
  115.         // ---------------------------------------------------------------------------------------------------- //
  116.         // --- F U N K C J E   P R Y W A T N E ---------------------------------------------------------------- //
  117.         // ---------------------------------------------------------------------------------------------------- //
  118.  
  119.           inline void DrawMaxWindow();            // rysuj maksymalne okno (-1px) na wyświetlaczu
  120.           inline void DrawDownWindow126();        // rysuj dolne okno o wysokości 126 punktów
  121.           inline void DrawUpWindow126();          // rysuj górne okno o wysokości 126 punktów
  122.           void DrawAnalogWindow126(uint16_t start_y, int value_start, int value_step, byte color_mode);
  123.           void ShowAnalogWindow126();
  124.           inline void SetupUpAnalogWindow126( int v_min, int v_step, String v_name);
  125.           inline void SetupDownAnalogWindow126( int v_min, int v_step, String v_name);
  126.           void AnalogPanelUp_v1_Show126(int value);
  127.           void AnalogPanelDown_v1_Show126(int value);  
  128.           void DrawTemperatureColor(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int i);    
  129.           void DrawWilgotnoscColor(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int i);    
  130.           void DrawCisnienieColor(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int i);    
  131.           void DrawZachmurzenieColor(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int i);    
  132.           void drawBmp(const char *filename, int16_t x, int16_t y);
  133.           uint16_t read16(fs::File &f);          
  134.           uint32_t read32(fs::File &f);
  135.  
  136.     public:  // metody i zmienne publiczne ------------------------------------------------------------------- //
  137.  
  138.           TFTPanel(TFT_eSPI & adresTFT) : tft (adresTFT) { }            // konstruktor klasy TFTPanel
  139.          
  140.           void PanelInit();                                             // funkcja konfigurująca dla klasy TFTPanel                
  141.           void AnalogPanel_v1_Create();                                 // funkcja tworząca panel wyświetlacza v1  
  142.           void AnalogPanel_v2_Create();                                 // funkcja tworząca panel wyświetlacza v2
  143.           void AnalogPanel_v1_Show(int Wilgotnosc, int Temperatura);    // funkcja pokazująca panel wyświetlacza v1
  144.           void AnalogPanel_v2_Show(int Cisnienie, int Zachmurzenie);    // funkcja pokazująca panel wyświetlacza v2
  145.           void DigitalClock_v1_Show(ESP32Time & clock, uint8_t x, uint8_t y);    // pokaz zegar dla Panel v1
  146.           void DigitalDate_v1_Show(ESP32Time & clock, uint8_t x, uint8_t y);     // pokaz datę  dla Panel v1
  147.           void DigitalTemperature_v1_Show(uint8_t x, uint8_t y);                 // pokaż temperaturę dla Panel v1
  148.           void DigitalCisnienie_v1_Show(uint8_t x, uint8_t y);                   // pokaż ciśnienie dla Panel v1
  149.           void DigitalWilgotnosc_v1_Show(uint8_t x, uint8_t y);                  // pokaż wilgotność dla Panel v1
  150.           void DigitalZachmurzenie_v1_Show(uint8_t x, uint8_t y);                // pokaż zachmurzenie dla Panel v1
  151.           void DigitalPredkoscWiatru_v1_Show(uint8_t x, uint8_t y);              // pokaż predkosc wiatru dla Panel v1
  152.           void DigitalWschodSlonca_v1_Show(uint8_t x, uint8_t y);                // pokaż wschód słońca dla Panel v1
  153.           void DigitalZachodSlonca_v1_Show(uint8_t x, uint8_t y);                // pokaż zachód słońca dla Panel v1
  154.           void DigitalLokalizacja_v1_Show(uint8_t x, uint8_t y);                 // pokaż lokalizację dla Panel v1
  155.           void CodeMsg_v1_Show(uint8_t x, uint8_t y);                            // pokaż info o Autorze Panel v1
  156.           void MultiSwitchPanel_v1(ESP32Time & clock, uint8_t x, uint8_t y);     // multi przełącznik
  157. };
  158.  
  159. // =========================================================================================================== //
  160. // === M E T O D Y   P R Y W A T N E ========================================================================= //
  161. // =========================================================================================================== //
  162. //
  163. // --- S P I S   M E T O D    P R Y W A T N Y C H ---
  164. //
  165. // inline void TFTPanel :: DrawMaxWindow()
  166. // inline void TFTPanel :: DrawDownWindow126()
  167. // inline void TFTPanel :: DrawUpWindow126()
  168. // void DrawAnalogWindow126(uint16_t start_y, int value_start, int value_step, byte color_mode)
  169. // inline void SetupUpAnalogWindow126( int v_min, int v_step, String v_name)
  170. // inline void SetupDownAnalogWindow126( int v_min, int v_step, String v_name)
  171. // void AnalogPanel_v1_Show(int Wilgotnosc, int Temperatura)
  172. // void AnalogPanel_v2_Show(int Cisnienie, int Zachmurzenie)
  173. // void DrawTemperatureColor(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int i)
  174. // void DrawWilgotnoscColor(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int i);  
  175. // void TFTPanel :: drawBmp(const char *filename, int16_t x, int16_t y)
  176. //
  177. //
  178. // *********************************************************************************************************** //
  179. // ***                                 Wczytaj BITMAPĘ z SPIFFS                                            *** //
  180. // *********************************************************************************************************** //
  181. //
  182. void TFTPanel :: drawBmp(const char *filename, int16_t x, int16_t y)
  183. {
  184.     if ((x >= tft.width()) || (y >= tft.height())) return;
  185.  
  186.     fs::File bmpFS;
  187.  
  188.     bmpFS = SPIFFS.open(filename, "r");
  189.  
  190.     uint32_t seekOffset;
  191.     uint16_t w, h, row, col;
  192.     uint8_t  r, g, b;  
  193.  
  194.     if (read16(bmpFS) == 0x4D42)
  195.     {
  196.         read32(bmpFS);
  197.         read32(bmpFS);
  198.         seekOffset = read32(bmpFS);
  199.         read32(bmpFS);
  200.         w = read32(bmpFS);
  201.         h = read32(bmpFS);
  202.  
  203.         if ((read16(bmpFS) == 1) && (read16(bmpFS) == 24) && (read32(bmpFS) == 0))
  204.         {
  205.             y += h - 1;
  206.  
  207.           bool oldSwapBytes = tft.getSwapBytes();
  208.           tft.setSwapBytes(true);
  209.           bmpFS.seek(seekOffset);
  210.  
  211.           uint16_t padding = (4 - ((w * 3) & 3)) & 3;
  212.           uint8_t lineBuffer[w * 3 + padding];
  213.  
  214.           for (row = 0; row < h; row++)
  215.           {
  216.               bmpFS.read(lineBuffer, sizeof(lineBuffer));
  217.               uint8_t*  bptr = lineBuffer;
  218.               uint16_t* tptr = (uint16_t*)lineBuffer;
  219.          
  220.               for (uint16_t col = 0; col < w; col++)
  221.               {
  222.                 b = *bptr++;
  223.                 g = *bptr++;
  224.                 r = *bptr++;
  225.                 *tptr++ = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
  226.               }
  227.        
  228.               tft.pushImage(x, y--, w, 1, (uint16_t*)lineBuffer);
  229.           }
  230.      
  231.           tft.setSwapBytes(oldSwapBytes);
  232.      }
  233.       else tools.PokazWiadomosc("TFT","Load BMP","Nie rozpoznano formatu");
  234.   }
  235.   bmpFS.close();
  236. }
  237. //
  238. // *********************************************************************************************************** //
  239. // ***                                 Wczytaj BITMAPĘ 16                                                  *** //
  240. // *********************************************************************************************************** //
  241. //
  242. uint16_t TFTPanel :: read16(fs::File &f) {
  243.   uint16_t result;
  244.   ((uint8_t *)&result)[0] = f.read(); // LSB
  245.   ((uint8_t *)&result)[1] = f.read(); // MSB
  246.   return result;
  247. }
  248. // *********************************************************************************************************** //
  249. // ***                                 Wczytaj BITMAPĘ 32                                                  *** //
  250. // *********************************************************************************************************** //
  251. uint32_t TFTPanel :: read32(fs::File &f) {
  252.   uint32_t result;
  253.   ((uint8_t *)&result)[0] = f.read(); // LSB
  254.   ((uint8_t *)&result)[1] = f.read();
  255.   ((uint8_t *)&result)[2] = f.read();
  256.   ((uint8_t *)&result)[3] = f.read(); // MSB
  257.   return result;
  258. }
  259. //
  260. // *********************************************************************************************************** //
  261. // ***                                 Narysuj maksymalne okno                                             *** //
  262. // *********************************************************************************************************** //
  263. //
  264. inline void TFTPanel :: DrawMaxWindow()
  265. {
  266.     tft.drawRect(window_min_x, window_min_y, window_size_x, window_size_y, Color_Line);       // ramka ekranu
  267.     tft.drawFastHLine(window_min_x, window_min_y + 35, window_size_y, Color_Line);            // rysuj linię
  268. }
  269. //
  270. // *********************************************************************************************************** //
  271. // ***                                 Narysuj ramkę dolną                                                 *** //
  272. // *********************************************************************************************************** //
  273. //
  274. inline void TFTPanel :: DrawDownWindow126()
  275. {
  276.     tft.drawRect(window_min_x, window_max_y - 126, window_size_x, 126, Color_Line);           // ramka dolna    
  277. }
  278. //
  279. // *********************************************************************************************************** //
  280. // ***                                 Narysuj ramkę górną                                                 *** //
  281. // *********************************************************************************************************** //
  282. //
  283. inline void TFTPanel :: DrawUpWindow126()
  284. {
  285.     tft.drawRect(window_min_x, window_max_y - (2 * 126) + 2, window_size_x, 126, Color_Line);   // ramka górna
  286. }
  287. //
  288. // *********************************************************************************************************** //
  289. // ***                             Zapamiętaj ustawienia okna UP                                           *** //
  290. // *********************************************************************************************************** //
  291. //
  292. inline void TFTPanel :: SetupUpAnalogWindow126( int v_min, int v_step, String v_name)
  293. {
  294.     Window_TFT_up.value_min = v_min;                          // minimalna wartość ANALOG METER          
  295.     Window_TFT_up.value_step = v_step;                        // zwiekszaj wartość ANALOG METER o V_STEP
  296.     Window_TFT_up.value_max = v_min + ( 4 * v_step );         // maksymalna wartość ANALOG METER
  297.     Window_TFT_up.value_name = v_name;                        // przypisz nazwę dla ANALOG METER
  298. }
  299. //
  300. // *********************************************************************************************************** //
  301. // ***                             Zapamiętaj ustawienia okna DOWN                                         *** //
  302. // *********************************************************************************************************** //
  303. //
  304. inline void TFTPanel :: SetupDownAnalogWindow126( int v_min, int v_step, String v_name)
  305. {
  306.     Window_TFT_down.value_min = v_min;                        // minimalna wartość ANALOG METER            
  307.     Window_TFT_down.value_step = v_step;                      // zwiększaj wartość ANALOG METER o V_STEP
  308.     Window_TFT_down.value_max = v_min + ( 4 * v_step );       // maksymalna wartość ANALOG METER
  309.     Window_TFT_down.value_name = v_name;                      // przypisz nazwę dla ANALOG METER
  310. }
  311. //
  312. // *********************************************************************************************************** //
  313. // ***                                 Temperatura color mode                                              *** //
  314. // *********************************************************************************************************** //
  315. //
  316. void TFTPanel :: DrawTemperatureColor(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int i)
  317. {
  318.         if (i >= -50 && i < -45)                                                    // początek IF
  319.         {
  320.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 191, 255));
  321.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 191, 255));
  322.         }                                                                           // koniec IF
  323.         else                                                                        // lub
  324.         if (i >= -45 && i < -40)                                                    // początek IF
  325.         {
  326.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 220, 255));
  327.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 220, 255));      
  328.         }                                                                           // koniec IF
  329.         else                                                                        // lub
  330.         if (i >= -40 && i < -35)                                                    // początek IF
  331.         {
  332.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 255, 255));
  333.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 255, 255));      
  334.         }                                                                           // koniec IF
  335.         else                                                                        // lub
  336.         if (i >= -35 && i < -30)                                                    // początek IF
  337.         {
  338.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 255, 191));
  339.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 255, 191));      
  340.         }                                                                           // koniec IF
  341.         else                                                                        // lub
  342.         if (i >= -30 && i < -25)                                                    // początek IF
  343.         {
  344.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 255, 128));
  345.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 255, 128));      
  346.         }                                                                           // koniec IF
  347.         else                                                                        // lub
  348.         if (i >= -25 && i < -20)                                                    // początek IF
  349.         {
  350.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 255, 64));
  351.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 255, 64));      
  352.         }
  353.         else                                                                        // lub    
  354.         if (i >= -20 && i < -15)                                                    // początek IF
  355.         {
  356.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 255, 0));
  357.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 255, 0));
  358.         }                                                                           // koniec IF
  359.         else                                                                        // lub
  360.         if (i >= -15 && i < -10)                                                    // początek IF
  361.         {
  362.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(20, 255, 0));
  363.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(20, 255, 0));
  364.         }                                                                           // koniec IF
  365.         else                                                                        // lub
  366.         if (i >= -10 && i < -5)                                                     // początek IF
  367.         {
  368.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(40, 255, 0));
  369.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(40, 255, 0));
  370.         }                                                                           // koniec IF
  371.         else                                                                        // lub
  372.         if (i >= -5 && i < 0)                                                       // początek IF
  373.         {
  374.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(64, 255, 0));
  375.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(64, 255, 0));
  376.         }                                                                           // koniec IF
  377.         else                                                                        // lub
  378.         if (i >= 0 && i < 5)                                                        // początek IF
  379.         {
  380.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(128, 255, 0));
  381.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(128, 255, 0));
  382.         }                                                                           // koniec IF
  383.         else                                                                        // lub
  384.         if (i >= 5 && i < 10)                                                       // początek IF
  385.         {
  386.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(160, 255, 0));
  387.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(160, 255, 0));
  388.         }                                                                           // koniec IF
  389.         else                                                                        // lub
  390.         if (i >= 10 && i < 15)                                                      // początek IF
  391.         {
  392.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(160, 255, 0));
  393.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(160, 255, 0));
  394.         }                                                                           // koniec IF
  395.         else                                                                        // lub
  396.         if (i >= 15 && i < 20)                                                      // początek IF
  397.         {
  398.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(190, 255, 0));
  399.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(190, 255, 0));
  400.         }                                                                           // koniec IF
  401.         else                                                                        // lub
  402.         if (i >= 20 && i < 25)                                                      // początek IF
  403.         {
  404.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(220, 255, 0));
  405.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(220, 255, 0));
  406.         }                                                                           // koniec IF
  407.         else                                                                        // lub
  408.         if (i >= 25 && i < 30)                                                      // początek IF
  409.         {
  410.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(255, 255, 0));
  411.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(255, 255, 0));
  412.         }                                                                           // koniec IF
  413.         else                                                                        // lub
  414.         if (i >= 30 && i < 35)                                                      // początek IF
  415.         {
  416.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(230, 230, 0));
  417.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(230, 230, 0));
  418.         }                                                                           // koniec IF
  419.         else                                                                        // lub
  420.         if (i >= 35 && i < 40)                                                      // początek IF
  421.         {
  422.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(204, 204, 0));
  423.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(204, 204, 0));
  424.         }                                                                           // koniec IF
  425.         else                                                                        // lub
  426.         if (i >= 40 && i < 45)                                                      // początek IF
  427.         {
  428.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(179, 179, 0));
  429.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(179, 179, 0));
  430.         }                                                                           // koniec IF
  431.         else                                                                        // lub
  432.         if (i >= 45 && i < 50)                                                      // początek IF
  433.         {
  434.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(153, 153, 0));
  435.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(153, 153, 0));
  436.         }        
  437. }
  438. //
  439. // *********************************************************************************************************** //
  440. // ***                                 Temperatura color mode                                              *** //
  441. // *********************************************************************************************************** //
  442. //
  443. void TFTPanel :: DrawWilgotnoscColor(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int i)
  444. {
  445.         if (i >= -50 && i < -45)                                                    // początek IF
  446.         {
  447.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(230, 255, 242));
  448.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(230, 255, 242));
  449.         }                                                                           // koniec IF
  450.         else                                                                        // lub
  451.         if (i >= -45 && i < -40)                                                    // początek IF
  452.         {
  453.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(204, 255, 230));
  454.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(204, 255, 230));      
  455.         }                                                                           // koniec IF
  456.         else                                                                        // lub
  457.         if (i >= -40 && i < -35)                                                    // początek IF
  458.         {
  459.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(179, 255, 217));
  460.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(179, 255, 217));      
  461.         }                                                                           // koniec IF
  462.         else                                                                        // lub
  463.         if (i >= -35 && i < -30)                                                    // początek IF
  464.         {
  465.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(153, 255, 204));
  466.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(153, 255, 204));      
  467.         }                                                                           // koniec IF
  468.         else                                                                        // lub
  469.         if (i >= -30 && i < -25)                                                    // początek IF
  470.         {
  471.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(128, 255, 191));
  472.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(128, 255, 191));      
  473.         }                                                                           // koniec IF
  474.         else                                                                        // lub
  475.         if (i >= -25 && i < -20)                                                    // początek IF
  476.         {
  477.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(102, 255, 179));
  478.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(102, 255, 179));      
  479.         }
  480.         else                                                                        // lub    
  481.         if (i >= -20 && i < -15)                                                    // początek IF
  482.         {
  483.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(77, 255, 166));
  484.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(77, 255, 166));
  485.         }                                                                           // koniec IF
  486.         else                                                                        // lub
  487.         if (i >= -15 && i < -10)                                                    // początek IF
  488.         {
  489.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(51, 255, 153));
  490.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(51, 255, 153));
  491.         }                                                                           // koniec IF
  492.         else                                                                        // lub
  493.         if (i >= -10 && i < -5)                                                     // początek IF
  494.         {
  495.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(26, 255, 140));
  496.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(26, 255, 140));
  497.         }                                                                           // koniec IF
  498.         else                                                                        // lub
  499.         if (i >= -5 && i < 0)                                                       // początek IF
  500.         {
  501.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(51, 255, 153));
  502.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(51, 255, 153));
  503.         }                                                                           // koniec IF
  504.         else                                                                        // lub
  505.         if (i >= 0 && i < 5)                                                        // początek IF
  506.         {
  507.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(26, 255, 140));
  508.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(26, 255, 140));
  509.         }                                                                           // koniec IF
  510.         else                                                                        // lub
  511.         if (i >= 5 && i < 10)                                                       // początek IF
  512.         {
  513.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 255, 128));
  514.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 255, 128));
  515.         }                                                                           // koniec IF
  516.         else                                                                        // lub
  517.         if (i >= 10 && i < 15)                                                      // początek IF
  518.         {
  519.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 230, 115));
  520.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 230, 115));
  521.         }                                                                           // koniec IF
  522.         else                                                                        // lub
  523.         if (i >= 15 && i < 20)                                                      // początek IF
  524.         {
  525.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 204, 102));
  526.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 204, 102));
  527.         }                                                                           // koniec IF
  528.         else                                                                        // lub
  529.         if (i >= 20 && i < 25)                                                      // początek IF
  530.         {
  531.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 179, 89));
  532.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 179, 89));
  533.         }                                                                           // koniec IF
  534.         else                                                                        // lub
  535.         if (i >= 25 && i < 30)                                                      // początek IF
  536.         {
  537.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 153, 77));
  538.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 153, 77));
  539.         }                                                                           // koniec IF
  540.         else                                                                        // lub
  541.         if (i >= 30 && i < 35)                                                      // początek IF
  542.         {
  543.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 128, 64));
  544.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 128, 64));
  545.         }                                                                           // koniec IF
  546.         else                                                                        // lub
  547.         if (i >= 35 && i < 40)                                                      // początek IF
  548.         {
  549.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 102, 51));
  550.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 102, 51));
  551.         }                                                                           // koniec IF
  552.         else                                                                        // lub
  553.         if (i >= 40 && i < 45)                                                      // początek IF
  554.         {
  555.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 77, 38));
  556.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 77, 38));
  557.         }                                                                           // koniec IF
  558.         else                                                                        // lub
  559.         if (i >= 45 && i < 50)                                                      // początek IF
  560.         {
  561.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 51, 26));
  562.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 51, 26));
  563.         }        
  564. }
  565. //
  566. // *********************************************************************************************************** //
  567. // ***                                 Zachmurzenie color mode                                             *** //
  568. // *********************************************************************************************************** //
  569. //
  570. void TFTPanel :: DrawZachmurzenieColor(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int i)
  571. {
  572.         if (i >= -50 && i < -45)                                                    // początek IF
  573.         {
  574.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(255, 255, 255));
  575.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(255, 255, 255));
  576.         }                                                                           // koniec IF
  577.         else                                                                        // lub
  578.         if (i >= -45 && i < -40)                                                    // początek IF
  579.         {
  580.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(230, 242, 255));
  581.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(230, 242, 255));      
  582.         }                                                                           // koniec IF
  583.         else                                                                        // lub
  584.         if (i >= -40 && i < -35)                                                    // początek IF
  585.         {
  586.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(204, 230, 255));
  587.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(204, 230, 255));      
  588.         }                                                                           // koniec IF
  589.         else                                                                        // lub
  590.         if (i >= -35 && i < -30)                                                    // początek IF
  591.         {
  592.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(179, 217, 255));
  593.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(179, 217, 255));      
  594.         }                                                                           // koniec IF
  595.         else                                                                        // lub
  596.         if (i >= -30 && i < -25)                                                    // początek IF
  597.         {
  598.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(153, 204, 255));
  599.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(153, 204, 255));      
  600.         }                                                                           // koniec IF
  601.         else                                                                        // lub
  602.         if (i >= -25 && i < -20)                                                    // początek IF
  603.         {
  604.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(128, 191, 255));
  605.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(128, 191, 255));      
  606.         }
  607.         else                                                                        // lub    
  608.         if (i >= -20 && i < -15)                                                    // początek IF
  609.         {
  610.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(102, 179, 255));
  611.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(102, 179, 255));
  612.         }                                                                           // koniec IF
  613.         else                                                                        // lub
  614.         if (i >= -15 && i < -10)                                                    // początek IF
  615.         {
  616.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(77, 166, 255));
  617.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(77, 166, 255));
  618.         }                                                                           // koniec IF
  619.         else                                                                        // lub
  620.         if (i >= -10 && i < -5)                                                     // początek IF
  621.         {
  622.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(51, 153, 255));
  623.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(51, 153, 255));
  624.         }                                                                           // koniec IF
  625.         else                                                                        // lub
  626.         if (i >= -5 && i < 0)                                                       // początek IF
  627.         {
  628.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(26, 140, 255));
  629.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(26, 140, 255));
  630.         }                                                                           // koniec IF
  631.         else                                                                        // lub
  632.         if (i >= 0 && i < 5)                                                        // początek IF
  633.         {
  634.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 128, 255));
  635.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 128, 255));
  636.         }                                                                           // koniec IF
  637.         else                                                                        // lub
  638.         if (i >= 5 && i < 10)                                                       // początek IF
  639.         {
  640.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 115, 230));
  641.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 115, 230));
  642.         }                                                                           // koniec IF
  643.         else                                                                        // lub
  644.         if (i >= 10 && i < 15)                                                      // początek IF
  645.         {
  646.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 102, 204));
  647.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 102, 204));
  648.         }                                                                           // koniec IF
  649.         else                                                                        // lub
  650.         if (i >= 15 && i < 20)                                                      // początek IF
  651.         {
  652.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 89, 179));
  653.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 89, 179));
  654.         }                                                                           // koniec IF
  655.         else                                                                        // lub
  656.         if (i >= 20 && i < 25)                                                      // początek IF
  657.         {
  658.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 77, 153));
  659.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 77, 153));
  660.         }                                                                           // koniec IF
  661.         else                                                                        // lub
  662.         if (i >= 25 && i < 30)                                                      // początek IF
  663.         {
  664.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 64, 128));
  665.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 64, 128));
  666.         }                                                                           // koniec IF
  667.         else                                                                        // lub
  668.         if (i >= 30 && i < 35)                                                      // początek IF
  669.         {
  670.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 59, 102));
  671.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 59, 102));
  672.         }                                                                           // koniec IF
  673.         else                                                                        // lub
  674.         if (i >= 35 && i < 40)                                                      // początek IF
  675.         {
  676.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 50, 102));
  677.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 50, 102));
  678.         }                                                                           // koniec IF
  679.         else                                                                        // lub
  680.         if (i >= 40 && i < 45)                                                      // początek IF
  681.         {
  682.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 40, 102));
  683.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 40, 102));
  684.         }                                                                           // koniec IF
  685.         else                                                                        // lub
  686.         if (i >= 45 && i < 50)                                                      // początek IF
  687.         {
  688.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 38, 77));
  689.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 38, 77));
  690.         }        
  691. }
  692. //
  693. // *********************************************************************************************************** //
  694. // ***                                 Cisnienie color mode                                                *** //
  695. // *********************************************************************************************************** //
  696. //
  697. void TFTPanel :: DrawCisnienieColor(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int i)
  698. {
  699.         if (i >= -50 && i < -45)                                                    // początek IF
  700.         {
  701.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 0, 255));
  702.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 0, 255));
  703.         }                                                                           // koniec IF
  704.         else                                                                        // lub
  705.         if (i >= -45 && i < -40)                                                    // początek IF
  706.         {
  707.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 40, 255));
  708.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 40, 255));      
  709.         }                                                                           // koniec IF
  710.         else                                                                        // lub
  711.         if (i >= -40 && i < -35)                                                    // początek IF
  712.         {
  713.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 80, 255));
  714.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 80, 255));      
  715.         }                                                                           // koniec IF
  716.         else                                                                        // lub
  717.         if (i >= -35 && i < -30)                                                    // początek IF
  718.         {
  719.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 128, 255));
  720.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 128, 255));      
  721.         }                                                                           // koniec IF
  722.         else                                                                        // lub
  723.         if (i >= -30 && i < -25)                                                    // początek IF
  724.         {
  725.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 191, 255));
  726.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 191, 255));      
  727.         }                                                                           // koniec IF
  728.         else                                                                        // lub
  729.         if (i >= -25 && i < -20)                                                    // początek IF
  730.         {
  731.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 210, 255));
  732.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 210, 255));      
  733.         }
  734.         else                                                                        // lub    
  735.         if (i >= -20 && i < -15)                                                    // początek IF
  736.         {
  737.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 235, 191));
  738.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 235, 191));
  739.         }                                                                           // koniec IF
  740.         else                                                                        // lub
  741.         if (i >= -15 && i < -10)                                                    // początek IF
  742.         {
  743.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 255, 205));
  744.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 255, 205));
  745.         }                                                                           // koniec IF
  746.         else                                                                        // lub
  747.         if (i >= -10 && i < -5)                                                     // początek IF
  748.         {
  749.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(100, 255, 180));
  750.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(100, 255, 180));
  751.         }                                                                           // koniec IF
  752.         else                                                                        // lub
  753.         if (i >= -5 && i < 0)                                                       // początek IF
  754.         {
  755.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(122, 255, 153));
  756.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(122, 255, 153));
  757.         }                                                                           // koniec IF
  758.         else                                                                        // lub
  759.         if (i >= 0 && i < 5)                                                        // początek IF
  760.         {
  761.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(122, 255, 153));
  762.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(122, 255, 153));
  763.         }                                                                           // koniec IF
  764.         else                                                                        // lub
  765.         if (i >= 5 && i < 10)                                                       // początek IF
  766.         {
  767.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(102, 255, 153));
  768.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(102, 255, 153));
  769.         }                                                                           // koniec IF
  770.         else                                                                        // lub
  771.         if (i >= 10 && i < 15)                                                      // początek IF
  772.         {
  773.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(77, 255, 136));
  774.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(77, 255, 136));
  775.         }                                                                           // koniec IF
  776.         else                                                                        // lub
  777.         if (i >= 15 && i < 20)                                                      // początek IF
  778.         {
  779.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(51, 255, 119));
  780.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(51, 255, 119));
  781.         }                                                                           // koniec IF
  782.         else                                                                        // lub
  783.         if (i >= 20 && i < 25)                                                      // początek IF
  784.         {
  785.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(26, 255, 102));
  786.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(26, 255, 102));
  787.         }                                                                           // koniec IF
  788.         else                                                                        // lub
  789.         if (i >= 25 && i < 30)                                                      // początek IF
  790.         {
  791.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 255, 85));
  792.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 255, 85));
  793.         }                                                                           // koniec IF
  794.         else                                                                        // lub
  795.         if (i >= 30 && i < 35)                                                      // początek IF
  796.         {
  797.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 204, 68));
  798.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 204, 68));
  799.         }                                                                           // koniec IF
  800.         else                                                                        // lub
  801.         if (i >= 35 && i < 40)                                                      // początek IF
  802.         {
  803.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 179, 60));
  804.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 179, 60));
  805.         }                                                                           // koniec IF
  806.         else                                                                        // lub
  807.         if (i >= 40 && i < 45)                                                      // początek IF
  808.         {
  809.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 153, 51));
  810.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 153, 51));
  811.         }                                                                           // koniec IF
  812.         else                                                                        // lub
  813.         if (i >= 45 && i < 50)                                                      // początek IF
  814.         {
  815.             tft.fillTriangle(x0, y0, x1, y1, x2, y2, tft.color565(0, 128, 43));
  816.             tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, 128, 43));
  817.         }        
  818. }
  819. //
  820.  
  821.  
  822. // *********************************************************************************************************** //
  823. // ***                                 Narysuj miernik analogowy                                           *** //
  824. // *********************************************************************************************************** //
  825. //
  826. void TFTPanel :: DrawAnalogWindow126(uint16_t start_y, int value_start, int value_step, byte color_mode)
  827. {
  828.     tft.setTextColor(TFT_WHITE);        
  829.    
  830.    
  831.     if ( window_up_v1 == start_y )  
  832.     {
  833.         tft.drawRightString ( Window_TFT_up.value_name, 220, 119 - 20 + start_y, 2);
  834.         Window_TFT_up.pos_y = start_y;
  835.     }
  836.     else
  837.     if (window_down_v1 == start_y)  
  838.     {
  839.         tft.drawRightString ( Window_TFT_down.value_name, 220, 119 - 20 + start_y, 2);        
  840.         Window_TFT_down.pos_y = start_y;
  841.     }
  842.  
  843.     for (int i = -50; i < 51; i += 5)                                               // pętla od - 50 do 50
  844.     {                                                                               // początek FOR
  845.         int tl = 15;                                                                // tl równa się 15
  846.         float sx = cos((i - 90) * 0.0174532925);                                    // wyznacz sx
  847.         float sy = sin((i - 90) * 0.0174532925);                                    // wyznacz sy
  848.         uint16_t x0 = sx * (100 + tl) + 120;                                        // wyznacz x0
  849.         uint16_t y0 = sy * (100 + tl) + 140+start_y;                                // wyznacz y0
  850.         uint16_t x1 = sx * 100 + 120;                                               // wyznacz x1
  851.         uint16_t y1 = sy * 100 + 140+start_y;                                       // wyznacz y1
  852.         float sx2 = cos((i + 5 - 90) * 0.0174532925);                               // wyznacz sx2
  853.         float sy2 = sin((i + 5 - 90) * 0.0174532925);                               // wyznacz sy2
  854.         int x2 = sx2 * (100 + tl) + 120;                                            // wyznacz x2
  855.         int y2 = sy2 * (100 + tl) + 140+start_y;                                    // wyznacz y2
  856.         int x3 = sx2 * 100 + 120;                                                   // wyznacz x3
  857.         int y3 = sy2 * 100 + 140+start_y;                                           // wyznacz y3
  858.                                                                                     // fake line auto-generater
  859.         switch ( color_mode )
  860.         {
  861.             case  0 :  DrawTemperatureColor(x0, y0, x1, y1, x2, y2, x3, y3, i); break;
  862.             case  1 :  DrawWilgotnoscColor(x0, y0, x1, y1, x2, y2, x3, y3, i);  break;
  863.             case  2 :  DrawZachmurzenieColor(x0, y0, x1, y1, x2, y2, x3, y3, i);  break;
  864.             case  3 :  DrawCisnienieColor(x0, y0, x1, y1, x2, y2, x3, y3, i);  break;
  865.         }                                                                                
  866.                                                                                     // fake line auto-generate
  867.         if (i % 25 != 0) tl = 8;                                                    // jeśli reszta z dzielenia rózna od 0
  868.                                                                                     // fake line auto-generate
  869.         x0 = sx * (100 + tl) + 120;                                                 // oblicz x0
  870.         y0 = sy * (100 + tl) + 140+start_y;                                         // oblicz y0
  871.         x1 = sx * 100 + 120;                                                        // oblicz x1
  872.         y1 = sy * 100 + 140+start_y;                                                // oblicz y1
  873.                                                                                     // fake line auto-generate
  874.         tft.drawLine(x0, y0, x1, y1, TFT_BLACK);                                    // drukuj ticka
  875.                                                                                     // fake line auto-generate
  876.         if (i % 25 == 0)                                                            // jeśli reszta z dzielenia to 0
  877.         {                                                                           // to
  878.             x0 = sx * (100 + tl + 10) + 120;                                        // wyznacz x0
  879.             y0 = sy * (100 + tl + 10) + 140+start_y;                                // wyznacz y0
  880.                                                                                     // fake line auto-generate
  881.             int    FValue;                                                          // zapisz tu skok skali
  882.                                                                                     // fake line auto-generate
  883.             switch (i / 25)                                                         // liczba całkowita z dzielenia / 25
  884.             {                                                                       // przełącznik logiczny
  885.                 case -2:  FValue = value_start + ( 0 * value_step );                // oblicz dla -2 wartość FVALUE
  886.                           tft.drawCentreString(String(FValue), x0, y0 - 12, 2);     // konwertuj do STRING pokaż na TFT
  887.                           break;                                                    // przerwij
  888.                 case -1:  FValue = value_start + ( 1 * value_step );                // oblicz dla -1 wartość FVALUE
  889.                           tft.drawCentreString(String(FValue), x0, y0 - 9, 2);      // konwertuj do STRING pokaż na TFT
  890.                           break;                                                    // przerwij
  891.                 case 0:   FValue = value_start + ( 2 * value_step );                // oblicz dla  0 wartość FVALUE
  892.                           tft.drawCentreString(String(FValue), x0, y0 - 6, 2);      // konwertuj do STRING pokaż na TFT
  893.                           break;                                                    // przerwij
  894.                 case 1:   FValue = value_start + ( 3 * value_step );                // oblicz dla +1 wartość FVALUE
  895.                           tft.drawCentreString(String(FValue), x0, y0 - 9, 2);      // konwertuj do STRING pokaż na TFT
  896.                           break;                                                    // przerwij
  897.                 case 2:   FValue = value_start + ( 4 * value_step );                // oblicz dla +2 wartość FVALUE
  898.                           tft.drawCentreString(String(FValue), x0, y0 - 12, 2);     // konwertuj do STRING pokaż na TFT
  899.                           break;                                                    // przerwij
  900.             }                                                                       // K O N I E C   P R Z E Ł A C Z N I K
  901.         }                                                                           // K O N I E C   R E S Z T A   %   0
  902.                                                                                     // fake line auto-generate
  903.         sx = cos((i + 5 - 90) * 0.0174532925);                                      // wyznacz sx z cosinusa DT I 0.1714
  904.         sy = sin((i + 5 - 90) * 0.0174532925);                                      // wyznacz sy z sinusa   DT I 0.1714
  905.         x0 = sx * 100 + 120;                                                        // podstaw pod x0
  906.         y0 = sy * 100 + 140+start_y;                                                // podstaw pod y0
  907.         if (i < 50) tft.drawLine(x0, y0, x1, y1, TFT_BLACK);                        // drukuj skalę
  908.     }                                                                               // K O N I E C   P Ę T L I   F O R    
  909. }                                                                                   // K O N I E C   F U N K C J I
  910. //
  911. // *********************************************************************************************************** //
  912. // ***                                 Pokaz miernik analogowy UP                                          *** //
  913. // *********************************************************************************************************** //
  914. //
  915. void TFTPanel :: AnalogPanelUp_v1_Show126(int value)
  916. {
  917.     int y = Window_TFT_up.pos_y;                                              // wyznacz oś y ze struktury UP
  918.     int ms_delay = 0;
  919.     char buf[8];                                                              // bufor tekstowy
  920.     dtostrf(value, 4, 0, buf);                                                // kopiuj wartość typu INT do CHAR
  921.                                                                               // fake line auto-generated
  922.     tft.setTextColor(TFT_WHITE, TFT_BLACK);                                   // ustaw kolor czcionki / tła
  923.     tft.drawRightString(buf, 50, 119 - 20+y, 2);                              // drukuj zawartość bufora CHAR
  924.     tft.drawRightString(Window_TFT_up.value_name, 220, 119 - 20+y, 2);        // drukuj zawartość dla UP
  925.                                                                               // fake line auto-generated
  926.     if (value < Window_TFT_up.value_min) value = Window_TFT_up.value_min;     // ustaw wartość minimalną
  927.     if (value > Window_TFT_up.value_max) value = Window_TFT_up.value_max;     // ustaw wartość maxymalną
  928.                                                                               // fake line auto-generated
  929.     while (!(value == Window_TFT_up.old_analog))                              // jesli wartości się zmieniły
  930.     {                                                                         // początek pętli WHILE
  931.         if (Window_TFT_up.old_analog < value) Window_TFT_up.old_analog++;     // sprawdź
  932.         else Window_TFT_up.old_analog--;                                      // jeśli FAŁSZ odejmij 1
  933.                                                                               // fake line auto-generated
  934.         if (ms_delay == 0) Window_TFT_up.old_analog = value;                  // fake flicker
  935.                                                                               // fake line auto-generated
  936.         float sdeg = map(Window_TFT_up.old_analog, Window_TFT_up.value_min, Window_TFT_up.value_max, -150, -30);  // skalowanie to wartości MIN / MAX
  937.                                                                               // fale line auto-generated      
  938.         float sx = cos(sdeg * 0.0174532925);                                  // oblicz nowe wartości dla sx
  939.         float sy = sin(sdeg * 0.0174532925);                                  // oblicz nowe wartości dla xy
  940.         float tx = tan((sdeg + 90) * 0.0174532925);                           // oblicz DELTĘ
  941.                                                                               // fake line auto-generated
  942.         tft.drawLine(120 + 20 * Window_TFT_up.ltx - 1, 140 - 20+y, Window_TFT_up.osx - 1, Window_TFT_up.osy+y,   TFT_BLACK); // skasuj starą wskazówkę
  943.         tft.drawLine(120 + 20 * Window_TFT_up.ltx,     140 - 20+y, Window_TFT_up.osx,     Window_TFT_up.osy+y,   TFT_BLACK); // skasuj starą wskazówkę
  944.         tft.drawLine(120 + 20 * Window_TFT_up.ltx + 1, 140 - 20+y, Window_TFT_up.osx + 1, Window_TFT_up.osy+y,   TFT_BLACK); // skasuj starą wskazówkę
  945.         tft.setTextColor(TFT_WHITE);                                          // ustaw kolor znaków / pikseli
  946.                                                                               // fake line auto-generated  
  947.         Window_TFT_up.ltx = tx;                                               // zapisz nowe tx
  948.         Window_TFT_up.osx = sx * 98 + 120;                                    // zapisz nowe sx
  949.         Window_TFT_up.osy = sy * 98 + 140;                                    // zapisz nowe sy
  950.                                                                               // fake line auto-generated
  951.         tft.drawLine(120 + 20 * Window_TFT_up.ltx - 1, 140 - 20+y,   Window_TFT_up.osx - 1, Window_TFT_up.osy +y, TFT_WHITE); // pokaz nową wskazówkę
  952.         tft.drawLine(120 + 20 * Window_TFT_up.ltx,     140 - 20+y,   Window_TFT_up.osx,     Window_TFT_up.osy +y, TFT_WHITE); // pokaz nową wskazówkę
  953.         tft.drawLine(120 + 20 * Window_TFT_up.ltx + 1, 140 - 20+y,   Window_TFT_up.osx + 1, Window_TFT_up.osy +y, TFT_WHITE); // pokaz nową wskazówkę
  954.                                                                                     // fake line auto-generated
  955.         if (abs(Window_TFT_up.old_analog - value) < 10) ms_delay += ms_delay / 5;   // fake flicker
  956.         delay(ms_delay);                                                            // fake flicker
  957.     }                                                                               // K O N I E C   W H I L E
  958. }
  959. //
  960. // *********************************************************************************************************** //
  961. // ***                                 Narysuj miernik analogowy DOWN                                      *** //
  962. // *********************************************************************************************************** //
  963. //
  964. void TFTPanel :: AnalogPanelDown_v1_Show126(int value)
  965. {
  966.  int y = Window_TFT_down.pos_y;                                               // wyznacz oś y ze struktury UP
  967.     int ms_delay = 0;
  968.     char buf[8];                                                              // bufor tekstowy
  969.     dtostrf(value, 4, 0, buf);                                                // kopiuj wartość typu INT do CHAR
  970.                                                                               // fake line auto-generated
  971.     tft.setTextColor(TFT_WHITE, TFT_BLACK);                                   // ustaw kolor czcionki / tła
  972.     tft.drawRightString(buf, 40, 119 - 20+y, 2);                              // drukuj zawartość bufora CHAR
  973.     tft.drawRightString(Window_TFT_down.value_name, 220, 119 - 20+y, 2);      // drukuj zawartość dla UP
  974.                                                                               // fake line auto-generated
  975.     if (value < Window_TFT_down.value_min) value = Window_TFT_down.value_min; // ustaw wartość minimalną
  976.     if (value > Window_TFT_down.value_max) value = Window_TFT_down.value_max; // ustaw wartość maxymalną
  977.                                                                               // fake line auto-generated
  978.     while (!(value == Window_TFT_down.old_analog))                            // jesli wartości się zmieniły
  979.     {                                                                         // początek pętli WHILE
  980.         if (Window_TFT_down.old_analog < value) Window_TFT_down.old_analog++; // sprawdź
  981.         else Window_TFT_down.old_analog--;                                    // jeśli FAŁSZ odejmij 1
  982.                                                                               // fake line auto-generated
  983.         if (ms_delay == 0) Window_TFT_down.old_analog = value;                // fake flicker
  984.                                                                               // fake line auto-generated
  985.         float sdeg = map(Window_TFT_down.old_analog, Window_TFT_down.value_min-5, Window_TFT_down.value_max+5, -150, -30);  // skalowanie to wartości MIN / MAX
  986.                                                                               // fale line auto-generated      
  987.         float sx = cos(sdeg * 0.0174532925);                                  // oblicz nowe wartości dla sx
  988.         float sy = sin(sdeg * 0.0174532925);                                  // oblicz nowe wartości dla xy
  989.         float tx = tan((sdeg + 90) * 0.0174532925);                           // oblicz DELTĘ
  990.                                                                               // fake line auto-generated
  991.         tft.drawLine(120 + 20 * Window_TFT_down.ltx - 1, 140 - 20+y, Window_TFT_down.osx - 1, Window_TFT_down.osy+y,   TFT_BLACK); // skasuj starą wskazówkę
  992.         tft.drawLine(120 + 20 * Window_TFT_down.ltx,     140 - 20+y, Window_TFT_down.osx,     Window_TFT_down.osy+y,   TFT_BLACK); // skasuj starą wskazówkę
  993.         tft.drawLine(120 + 20 * Window_TFT_down.ltx + 1, 140 - 20+y, Window_TFT_down.osx + 1, Window_TFT_down.osy+y,   TFT_BLACK); // skasuj starą wskazówkę
  994.         tft.setTextColor(TFT_WHITE);                                          // ustaw kolor znaków / pikseli
  995.                                                                               // fake line auto-generated  
  996.         Window_TFT_down.ltx = tx;                                             // zapisz nowe tx
  997.         Window_TFT_down.osx = sx * 98 + 120;                                  // zapisz nowe sx
  998.         Window_TFT_down.osy = sy * 98 + 140;                                  // zapisz nowe sy
  999.                                                                               // fake line auto-generated
  1000.         tft.drawLine(120 + 20 * Window_TFT_down.ltx - 1, 140 - 20+y,   Window_TFT_down.osx - 1, Window_TFT_down.osy +y, TFT_WHITE); // pokaz nową wskazówkę
  1001.         tft.drawLine(120 + 20 * Window_TFT_down.ltx,     140 - 20+y,   Window_TFT_down.osx,     Window_TFT_down.osy +y, TFT_WHITE); // pokaz nową wskazówkę
  1002.         tft.drawLine(120 + 20 * Window_TFT_down.ltx + 1, 140 - 20+y,   Window_TFT_down.osx + 1, Window_TFT_down.osy +y, TFT_WHITE); // pokaz nową wskazówkę
  1003.                                                                                        // fake line auto-generated
  1004.         if (abs(Window_TFT_down.old_analog - value) < 10) ms_delay += ms_delay / 5;    // fake flicker
  1005.         delay(ms_delay);                                                               // fake flicker
  1006.     }                
  1007. }
  1008.  
  1009.  
  1010. // =========================================================================================================== //
  1011. // === M E T O D Y   P U B L I C Z N E ======================================================================= //
  1012. // =========================================================================================================== //
  1013. //
  1014. //
  1015. // --- S P I S   M E T O D    P R Y W A T N Y C H ---
  1016. //
  1017. // void TFTPanel :: PanelInit()
  1018. // void TFTPanel :: AnalogPanel_v1_Create()
  1019. // void TFTPanel :: AnalogPanel_v1_Show(int Temperatura, int Wilgotnosc)
  1020. // void TFTPanel :: DigitalClock_v1_Show(ESP32Time & clock, uint8_t x = 10, uint8_t y = 10)
  1021. // void TFTPanel :: DigitalDate_v1_Show(ESP32Time & clock, uint8_t x = 5, uint8_t y = 8)
  1022. // void TFTPanel :: MultiSwitchPanel_v1(ESP32Time & clock, uint8_t x = 5, uint8_t y = 42)
  1023. // void TFTPanel :: DigitalTemperature_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1024. // void TFTPanel :: CodeMsg_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1025. // void TFTPanel :: DigitalCisnienie_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1026. // void TFTPanel :: DigitalWilgotnosc_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1027. // void TFTPanel :: DigitalZachmurzenie_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1028. // void TFTPanel :: DigitalPredkoscWiatru_v1_Show(uint8_t x = 120, uint8_t y = 42);
  1029. // void TFTPanel :: DigitalWschodSlonca_v1_Show(uint8_t x = 120, uint8_t y = 42);
  1030. // void TFTPanel :: DigitalZachodSlonca_v1_Show(uint8_t x = 120, uint8_t y = 42);
  1031. // void TFTPanel :: DigitalLokalizacja_v1_Show(uint8_t x = 120, uint8_t y = 42);
  1032. //
  1033. // *********************************************************************************************************** //
  1034. // ***                       G ł ó w n a   F u n k c j a   K o n f i g u r a c y j n a                     *** //
  1035. // *********************************************************************************************************** //
  1036. //
  1037. void TFTPanel :: PanelInit()
  1038. {
  1039.     tft.init();                                // inicjalizuj ekran
  1040.     tft.setRotation(0);                        // ustaw rotację
  1041.     tft.fillScreen(Color_Bakground);           // ustaw tło okna    
  1042. }
  1043. //
  1044. // *********************************************************************************************************** //
  1045. // ***                           A N A L O G   P A N E L   C R E A T E     V 1                             *** //
  1046. // *********************************************************************************************************** //
  1047. //
  1048. void TFTPanel :: AnalogPanel_v1_Create()
  1049. {
  1050.     DrawMaxWindow();                                  // rysuj ramkę dla maksymalnego okna głównego
  1051.     DrawDownWindow126();                              // rysuj ramkę dolną dla modułu ANALOG METER ( DOWN )
  1052.     SetupDownAnalogWindow126( 0, 25, "Wilgotnosc");   // ustaw parametry dla ANALOG METER ( DOWN )
  1053.     DrawUpWindow126();                                // rysuj ramkę górną dla modułu ANALOG METER (  UP  )
  1054.     SetupUpAnalogWindow126( -10, 10, "Temperatura");  // ustaw parametry dla ANALOG METER (  UP  )    
  1055.     DrawAnalogWindow126( window_up_v1,   -10,  10, 0);   // rysuj analogowy wskaźnik (  UP  ) ( min value ) ( max value )
  1056.     DrawAnalogWindow126( window_down_v1,   0,  25, 1);   // rysuj analogowy wskaźnik ( DOWN ) ( min value ) ( max value )
  1057. }
  1058. //
  1059. // *********************************************************************************************************** //
  1060. // ***                           A N A L O G   P A N E L   C R E A T E     V 2                             *** //
  1061. // *********************************************************************************************************** //
  1062. //
  1063. void TFTPanel :: AnalogPanel_v2_Create()
  1064. {
  1065.     DrawMaxWindow();                                  // rysuj ramkę dla maksymalnego okna głównego
  1066.     DrawDownWindow126();                              // rysuj ramkę dolną dla modułu ANALOG METER ( DOWN )
  1067.     SetupDownAnalogWindow126( 0, 25, "Zachmurzenie"); // ustaw parametry dla ANALOG METER ( DOWN )
  1068.     DrawUpWindow126();                                // rysuj ramkę górną dla modułu ANALOG METER (  UP  )
  1069.     SetupUpAnalogWindow126( 920, 40, "Cisnienie");    // ustaw parametry dla ANALOG METER (  UP  )    
  1070.     DrawAnalogWindow126( window_up_v1,   920,  40, 3);   // rysuj analogowy wskaźnik (  UP  ) ( min value ) ( max value )
  1071.     DrawAnalogWindow126( window_down_v1,   0,  25, 2);   // rysuj analogowy wskaźnik ( DOWN ) ( min value ) ( max value )
  1072. }
  1073. //
  1074. // *********************************************************************************************************** //
  1075. // ***                           A N A L O G   P A N E L   S H O W     V 1                                 *** //
  1076. // *********************************************************************************************************** //
  1077. //
  1078. void TFTPanel :: AnalogPanel_v1_Show(int Temperatura, int Wilgotnosc)
  1079. {
  1080.     AnalogPanelUp_v1_Show126(Temperatura);
  1081.     AnalogPanelDown_v1_Show126(Wilgotnosc);
  1082. }
  1083. //
  1084. // *********************************************************************************************************** //
  1085. // ***                           A N A L O G   P A N E L   S H O W     V 2                                 *** //
  1086. // *********************************************************************************************************** //
  1087. //
  1088. void TFTPanel :: AnalogPanel_v2_Show(int Cisnienie, int Zachmurzenie)
  1089. {
  1090.     if (Zachmurzenie==100) Zachmurzenie = 90;
  1091.    
  1092.     AnalogPanelUp_v1_Show126(Cisnienie);
  1093.     AnalogPanelDown_v1_Show126(Zachmurzenie);
  1094.     drawBmp("/chmurka.bmp", 183, 203);
  1095.     drawBmp("/slonko.bmp",   7, 198);
  1096.    
  1097.     drawBmp("/higrometr.bmp",   64, 126);
  1098.     drawBmp("/deszcz.bmp",   5, 74);
  1099.     drawBmp("/slonko2.bmp",  190, 75);
  1100. }
  1101. //
  1102. // *********************************************************************************************************** //
  1103. // ***                                 D I G I T A L   C L O C K     V 1                                   *** //
  1104. // *********************************************************************************************************** //
  1105. //
  1106. void TFTPanel :: DigitalClock_v1_Show(ESP32Time & clock, uint8_t x = 40, uint8_t y = 8)
  1107. {
  1108.     // położenie x - wartość domyślna to : 40
  1109.     // położenie y - wartość domyślna to : 8
  1110.    
  1111.     char showBufor[4];                // buforek typu char    
  1112.     char tempBufor[4];                // buforek typu char
  1113.     static bool FlagaZmiany = false;  // flaga do zmiany co 1 sekundę
  1114.  
  1115.     // sprawdź warunki czy coś do zrobienia (optymalizacja) ----------------------------------
  1116.  
  1117.     if ( AmPm != clock.getAmPm() )                          // jeśli zmienił się AM i PM
  1118.     {                                                       // początek IF
  1119.         AmPm = clock.getAmPm(false);                        // zapisz nowy AM/PM pod zmienną
  1120.     }                                                       // ten warunek ma być pierwszy !!!
  1121.    
  1122.     if ( Godzina != clock.getHour(true) )                   // jeśli zmieniła się godzina
  1123.     {                                                       // początek IF
  1124.         Godzina = clock.getHour(true);                      // zapisz nową godzinę pod zmienną
  1125.  
  1126.         if ( Godzina < 10 )                                  // jeśli minuta mniejsze niz 10
  1127.         {                                                   // początek IF
  1128.             strcpy(showBufor, "0");                         // kopiuj do showBufor 0
  1129.             sprintf(tempBufor, "%d", Godzina);              // konwersja do char
  1130.             strcat(showBufor, tempBufor);                   // doklej do showBufor tempBufor
  1131.         }                                                   // koniec IF
  1132.         else                                                // jeśli minuta większa niz 10
  1133.         {                                                   // początek IF
  1134.             sprintf( tempBufor, "%d", Godzina );            // konwersja do char
  1135.             strcpy( showBufor, tempBufor );                 // skopiuj do showBufor tempBufor
  1136.         }                                                   // koniec IF
  1137.        
  1138.         tft.setTextColor(TFT_kolor_zegara, TFT_tlo_zegara); // ustaw kolor czcionki / tła        
  1139.         tft.drawString(showBufor, x, y, 4);                 // drukuj Godzinę jeśli się zmieniła
  1140.         tft.setTextColor(TFT_BLUE2, TFT_tlo_zegara);        // ustaw kolor czcionki / tła        
  1141.         tft.drawString(AmPm, x + 115, y, 4);                // wyświetl na TFT
  1142.     }                                                       // koniec IF
  1143.  
  1144.     if ( Minuta != clock.getMinute() )                      // jeśli zmieniła się minuta
  1145.     {                                                       // początek IF
  1146.         Minuta  = clock.getMinute();                        // zapisz nową minutę pod zmienną  
  1147.        
  1148.         if ( Minuta < 10 )                                  // jeśli minuta mniejsze niz 10
  1149.         {                                                   // początek IF
  1150.             strcpy(showBufor, "0");                         // kopiuj do showBufor 0
  1151.             sprintf(tempBufor, "%d", Minuta);               // konwersja do char
  1152.             strcat(showBufor, tempBufor);                   // doklej do showBufor tempBufor
  1153.         }                                                   // koniec IF
  1154.         else                                                // jeśli minuta większa niz 10
  1155.         {                                                   // początek IF
  1156.             sprintf( tempBufor, "%d", Minuta );             // konwersja do char
  1157.             strcpy( showBufor, tempBufor );                 // skopiuj do showBufor tempBufor
  1158.         }                                                   // koniec IF
  1159.        
  1160.         tft.setTextColor(TFT_kolor_zegara, TFT_tlo_zegara); // ustaw kolor czcionki / tła                
  1161.         tft.drawString(showBufor, x + 40, y, 4);            // drukuj Minutę jeśli się zmieniła                          
  1162.     }                                                       // koniec IF
  1163.  
  1164.     if ( Sekunda != clock.getSecond() )                     // jeśli zmieniła się sekunda        
  1165.     {                                                       // początek IF
  1166.         Sekunda = clock.getSecond();                        // zapisz nową sekundę pod zmienną
  1167.  
  1168.         if ( Sekunda < 10 )                                 // jeśli minuta mniejsze niz 10
  1169.         {                                                   // początek IF
  1170.             strcpy(showBufor, "0");                         // kopiuj do showBufor 0
  1171.             sprintf(tempBufor, "%d", Sekunda);              // konwersja do char
  1172.             strcat(showBufor, tempBufor);                   // doklej do showBufor tempBufor
  1173.         }                                                   // koniec IF
  1174.         else                                                // jeśli minuta większa niz 10
  1175.         {                                                   // początek IF
  1176.             sprintf( tempBufor, "%d", Sekunda );            // konwersja do char
  1177.             strcpy( showBufor, tempBufor );                 // skopiuj do showBufor tempBufor
  1178.         }                                                   // koniec IF
  1179.        
  1180.         tft.setTextColor(TFT_kolor_zegara, TFT_tlo_zegara); // ustaw kolor czcionki / tła                
  1181.         tft.drawString(showBufor, x + 80, y, 4);            // drukuj Minutę jeśli się zmieniła
  1182.  
  1183.         if ( FlagaZmiany ) FlagaZmiany = false;             // zmien wartosc flagi co 1 sekunde
  1184.         else                                                // lub
  1185.         if (!FlagaZmiany ) FlagaZmiany = true;              // zmien wartosc flagi co 1 sekunde
  1186.     }                                                       // koniec IF
  1187.                                                      
  1188.     // koniec sprawdzania warunków RTC -------------------------------------------------------
  1189.  
  1190.     if( FlagaZmiany )
  1191.     {
  1192.         tft.setTextColor(TFT_kolor_zegara, TFT_tlo_zegara); // ustaw kolor czcionki / tła                
  1193.         tft.drawString(":", x + 30, y, 4);                  // drukuj dwukropek zegara
  1194.         tft.setTextColor(TFT_kolor_zegara, TFT_tlo_zegara); // ustaw kolor czcionki / tła                
  1195.         tft.drawString(".", x + 70, y, 4);                  // drukuj dwukropek zegara
  1196.     }
  1197.     else
  1198.     {
  1199.         tft.setTextColor(TFT_BLUE, TFT_tlo_zegara);         // ustaw kolor czcionki / tła                
  1200.         tft.drawString(":", x + 30, y, 4);                  // zamaż dwukropke zegara
  1201.         tft.setTextColor(TFT_BLUE, TFT_tlo_zegara);         // ustaw kolor czcionki / tła                
  1202.         tft.drawString(".", x + 70, y, 4);                  // drukuj dwukropek zegara
  1203.     }  
  1204. }
  1205. //
  1206. // *********************************************************************************************************** //
  1207. // ***                                 D I G I T A L   D A T E     V 1                                     *** //
  1208. // *********************************************************************************************************** //
  1209. //
  1210. void TFTPanel :: DigitalDate_v1_Show(ESP32Time & clock, uint8_t x = 120, uint8_t y = 42)
  1211. {
  1212.     // położenie x - wartość domyślna to : 120
  1213.     // położenie y - wartość domyślna to : 42
  1214.        
  1215.     if ( Data != clock.getDate(false) )                     // sprawdź czy data się zmieniła (optymalizacja)
  1216.     {                                                       // początek IF      
  1217.         Data = clock.getDate(false);                        // zapisz pod zmienną Data nową datę z RTC        
  1218.     }                                                       // koniec IF
  1219.     else
  1220.     {
  1221.         tft.setTextColor(TFT_kolor_zegara, TFT_tlo_zegara); // ustaw kolor czcionki / tła    
  1222.         tft.drawCentreString(Data, x, y, 4);                // pokaż datę (angielska wersja)
  1223.     }    
  1224.  
  1225.     #if Terminal
  1226.         tools.PokazWiadomosc("TFT","DigitalDate_v1 Wyswietlam",Data.c_str());
  1227.     #endif  
  1228. }
  1229. //
  1230. // *********************************************************************************************************** //
  1231. // ***                        D I G I T A L   T E M P E R A T U R A     V 1                                *** //
  1232. // *********************************************************************************************************** //
  1233. //
  1234. void TFTPanel :: DigitalTemperature_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1235. {
  1236.     String bufor = "Temp.Out " + String(pogoda.PublicPobierzTemperature()) + " C";  // załaduj do bufora    
  1237.     tft.drawCentreString(bufor, x, y, 4);                                           // wyświetl tekst
  1238.  
  1239.     #if Terminal
  1240.         tools.PokazWiadomosc("TFT","DigitalTemperature_v1 Wyswietlam",bufor.c_str());
  1241.     #endif  
  1242. }
  1243. //
  1244. // *********************************************************************************************************** //
  1245. // ***                          D I G I T A L   W I L G O T N O S C     V 1                                *** //
  1246. // *********************************************************************************************************** //
  1247. //
  1248. void TFTPanel :: DigitalWilgotnosc_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1249. {
  1250.     String bufor = "Wilgotnosc " + String(pogoda.PublicPobierzWilgotnosc()) + " %";  // załaduj do bufora    
  1251.     tft.drawCentreString(bufor, x, y, 4);                                            // wyświetl tekst
  1252.  
  1253.     #if Terminal
  1254.         tools.PokazWiadomosc("TFT","DigitalWilgotnosc_v1 Wyswietlam",bufor.c_str());
  1255.     #endif  
  1256. }
  1257. //
  1258. // *********************************************************************************************************** //
  1259. // ***                      D I G I T A L   Z A C H M U R Z E N I E     V 1                                *** //
  1260. // *********************************************************************************************************** //
  1261. //
  1262. void TFTPanel :: DigitalZachmurzenie_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1263. {
  1264.     String bufor = "Zachmurzenie " + String(pogoda.PublicPobierzZachmurzenie()) + " %";  // załaduj do bufora    
  1265.     tft.drawCentreString(bufor, x, y, 4);                                                // wyświetl tekst
  1266.  
  1267.     #if Terminal
  1268.         tools.PokazWiadomosc("TFT","DigitalZachmurzenie_v1 Wyswietlam",bufor.c_str());
  1269.     #endif  
  1270. }
  1271. //
  1272. // *********************************************************************************************************** //
  1273. // ***                D I G I T A L   P R Ę D K O Ś Ć   W I A T R U     V 1                                *** //
  1274. // *********************************************************************************************************** //
  1275. //
  1276. void TFTPanel :: DigitalPredkoscWiatru_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1277. {
  1278.     String bufor = "Wiatr " + String(pogoda.PublicPobierzPredkoscWiatru()) + " km/h";  // załaduj do bufora    
  1279.     tft.drawCentreString(bufor, x, y, 4);                                              // wyświetl tekst
  1280.  
  1281.     #if Terminal
  1282.         tools.PokazWiadomosc("TFT","DigitalPredkoscWiatru_v1 Wyswietlam",bufor.c_str());
  1283.     #endif  
  1284. }
  1285. //
  1286. // *********************************************************************************************************** //
  1287. // ***                           D I G I T A L   C I S N I E N I E     V 1                                 *** //
  1288. // *********************************************************************************************************** //
  1289. //
  1290. void TFTPanel :: DigitalCisnienie_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1291. {
  1292.     String bufor = "Cisnienie " + String(pogoda.PublicPobierzCisnienie()) + " mPa"; // załaduj do bufora      
  1293.     tft.drawCentreString(bufor, x, y, 4);                                           // wyświetl tekst
  1294.  
  1295.     #if Terminal
  1296.         tools.PokazWiadomosc("TFT","DigitalCisnienie_v1 Wyswietlam",bufor.c_str());
  1297.     #endif  
  1298. }
  1299. //
  1300. // *********************************************************************************************************** //
  1301. // ***                           D I G I T A L   W S C H O D   S L O N C A     V 1                         *** //
  1302. // *********************************************************************************************************** //
  1303. //
  1304. void TFTPanel :: DigitalWschodSlonca_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1305. {
  1306.     String bufor = "Wschod " + String(pogoda.PublicPobierzWschodSlonca());          // załaduj do bufora      
  1307.     tft.drawCentreString(bufor, x, y, 4);                                           // wyświetl tekst
  1308.  
  1309.     #if Terminal
  1310.         tools.PokazWiadomosc("TFT","DigitalWschodSlonca_v1 Wyswietlam",bufor.c_str());
  1311.     #endif  
  1312. }
  1313. //
  1314. // *********************************************************************************************************** //
  1315. // ***                           D I G I T A L   Z A C H O D   S L O N C A     V 1                         *** //
  1316. // *********************************************************************************************************** //
  1317. //
  1318. void TFTPanel :: DigitalZachodSlonca_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1319. {
  1320.     String bufor = "Zachod " + String(pogoda.PublicPobierzZachodSlonca());          // załaduj do bufora      
  1321.     tft.drawCentreString(bufor, x, y, 4);                                           // wyświetl tekst
  1322.  
  1323.     #if Terminal
  1324.         tools.PokazWiadomosc("TFT","DigitalZachodSlonca_v1 Wyswietlam",bufor.c_str());
  1325.     #endif  
  1326. }
  1327. //
  1328. // *********************************************************************************************************** //
  1329. // ***                               D I G I T A L   L O K A L I Z A C J E     V 1                         *** //
  1330. // *********************************************************************************************************** //
  1331. //
  1332. void TFTPanel :: DigitalLokalizacja_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1333. {    
  1334.     tft.drawCentreString(pogoda.PublicPobierzLokalizacje(), x, y, 4);                       // wyświetl tekst
  1335.  
  1336.     #if Terminal
  1337.         tools.PokazWiadomosc("TFT","DigitalZachodSlonca_v1 Wyswietlam",pogoda.PublicPobierzLokalizacje().c_str());
  1338.     #endif  
  1339. }
  1340. //
  1341. // *********************************************************************************************************** //
  1342. // ***                                         C O D E   M S G   V 1                                       *** //
  1343. // *********************************************************************************************************** //
  1344. //
  1345. void TFTPanel :: CodeMsg_v1_Show(uint8_t x = 120, uint8_t y = 42)
  1346. {
  1347.     tft.drawCentreString("Code by Transline", x, y, 4);                             // wyświetl tekst
  1348.    
  1349.     #if Terminal
  1350.         tools.PokazWiadomosc("TFT","CodeMsg v1 Wyswietlam","Code by Transline");
  1351.     #endif  
  1352. }
  1353.  
  1354. //
  1355. // *********************************************************************************************************** //
  1356. // ***                         D I G I T A L   M U L T I   S W I T C H     V 1                             *** //
  1357. // *********************************************************************************************************** //
  1358. //
  1359. void TFTPanel :: MultiSwitchPanel_v1(ESP32Time & clock, uint8_t x = 5, uint8_t y = 42)
  1360. {
  1361.     static byte przelacznik = 0;                                      // przelacznik dla switch
  1362.  
  1363.     #if Terminal
  1364.         tools.PokazWiadomosc("TFT","MultiSwitchPanel v1 - Przelacznik",String(przelacznik).c_str());
  1365.     #endif
  1366.  
  1367.     tft.fillRect(window_min_x+1, window_min_y + 36, window_size_x - 2, 30, TFT_BLACK);  // posprzątaj
  1368.     tft.setTextColor(TFT_GREEN1, TFT_tlo_zegara);                     // ustaw kolor czcionki / tła
  1369.  
  1370.     switch ( przelacznik )                                            // przelacznik komunikatow
  1371.     {                                                                 // początek SWITCH
  1372.      
  1373.         case    0 :   DigitalDate_v1_Show(clock);                     // wyświetl DATĘ
  1374.                       przelacznik ++;                                 // dodaj 1 do przelacznik
  1375.                       break;                                          // przerwij warunek 0
  1376.  
  1377.         case    1 :   DigitalTemperature_v1_Show();                   // wyświetl CZAS
  1378.                       przelacznik ++;                                 // dodaj 1 do przelacznik
  1379.                       break;                                          // przerwij warunek 1
  1380.  
  1381.         case    2 :   DigitalCisnienie_v1_Show();                     // wyświetl CIŚNIENIE
  1382.                       przelacznik ++;                                 // dodaj 1 do przełącznik
  1383.                       break;                                          // przerwij warunek 2
  1384.  
  1385.         case    3 :   DigitalWilgotnosc_v1_Show();                    // wyświetl WILGOTNOŚĆ
  1386.                       przelacznik ++;                                 // dodaj 1 do przełącznik
  1387.                       break;                                          // przerwij warunek 3
  1388.  
  1389.         case    4 :   DigitalZachmurzenie_v1_Show();                  // wyświetl ZACHMURZENIE
  1390.                       przelacznik ++;                                 // dodaj 1 do przełącznik
  1391.                       break;                                          // przerwij warunek 4
  1392.                      
  1393.         case    5 :   DigitalPredkoscWiatru_v1_Show();                // wyświetl PREDKOSC WIATRU
  1394.                       przelacznik ++;                                 // dodaj 1 do przełącznik
  1395.                       break;                                          // przerwij warunek 5
  1396.  
  1397.         case    6 :   DigitalWschodSlonca_v1_Show();                  // wyświetl WSCHÓD SŁOŃCA
  1398.                       przelacznik ++;                                 // dodaj 1 do przełącznik
  1399.                       break;                                          // przerwij warunek 6                  
  1400.  
  1401.         case    7 :   DigitalZachodSlonca_v1_Show();                  // wyświetl ZACHÓD SŁOŃCA
  1402.                       przelacznik ++;                                 // dodaj 1 do przełącznik
  1403.                       break;                                          // przerwij warunek 7                                            
  1404.  
  1405.         case    8 :   DigitalLokalizacja_v1_Show();                   // wyświetl LOKALIZACJE
  1406.                       przelacznik ++;                                 // dodaj 1 do przełącznik
  1407.                       break;                                          // przerwij warunek 7              
  1408.                      
  1409.         default   :   CodeMsg_v1_Show();                              // wyświetl MSG
  1410.                       przelacznik = 0;                                // dodaj 1 do przelacznik
  1411.                       break;                                          // przerwij warunek DEFAULT
  1412.                        
  1413.     }                                                                 // koniec SWITCH                                              
  1414.    
  1415. }                                                                     // koniec MultiSwitchPanel_v1
  1416. //
  1417. // *********************************************************************************************************** //
  1418. // ***                                 E N D                                                               *** //
  1419. // *********************************************************************************************************** //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement