PowerTGS440

ESP32-WeatherStation_tft_0.22

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