Toto je má konečná verze maturitního projektu

Dependencies:   mbed mbed-rtos UTouch_vyrobek UniGraphic

Files at this revision

API Documentation at this revision

Comitter:
smejky
Date:
Tue Feb 01 13:37:40 2022 +0000
Parent:
10:0176705be216
Child:
12:9bc02f9e16e3
Commit message:
Pridani led pasku k projetku, fungujici efekty: Staticky

Changed in this revision

UniGraphic.lib Show annotated file Show diff for this revision Revisions of this file
display.cpp Show annotated file Show diff for this revision Revisions of this file
display.h Show annotated file Show diff for this revision Revisions of this file
--- a/UniGraphic.lib	Sun Jan 16 12:06:03 2022 +0000
+++ b/UniGraphic.lib	Tue Feb 01 13:37:40 2022 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/GraphicsDisplay/code/UniGraphic/#6bb78c73f47d
+http://mbed.org/teams/GraphicsDisplay/code/UniGraphic/#5d47cf21a85a
--- a/display.cpp	Sun Jan 16 12:06:03 2022 +0000
+++ b/display.cpp	Tue Feb 01 13:37:40 2022 +0000
@@ -1,24 +1,36 @@
 #include "display.h"
-#include "rtos.h"
+
 
-UTouch touch(D4,D9,D3,D2,D5);//clk,chip_select,MOSI,miso,irq
-ILI9341 spi(SPI_8,320000000,PTD2,PTD3,PTD1,PTC12, PTC3, PTC2, "TFT",240,320);// mosi, miso, sclk, chip_select, reset, dc
+UTouch touch(D5,D4,D3,D2,D1);//clk,chip_select,MOSI,miso,irq
+ILI9341 spi(SPI_8,320000000,PTD2,PTD3,PTD1,PTE24, PTE25, PTC4, "TFT",240,320);// mosi, miso, sclk, chip_select, reset, dc
 DigitalOut my_green(LED2);
 DigitalOut my_red(LED4);
 DigitalOut my_blue(LED3);
 DigitalOut led2(LED2);
 Thread thread;
+Thread thread_h;
 PwmOut br(D10);
 
+
+
+PwmOut r(PTC10);
+PwmOut g(PTC3);
+PwmOut b(PTC2);
+
+float led_jas = 80;
 float lcd_jas = 0.50f;
-int jas[] = {Green,Red};
+int jas[] = {Cyan,White};
 int jas_s = 2;
 int jazyk_s = 0;
 int cas_hodiny = 0;
 int cas_minuty = 0;
+int cas_hodiny_on = 0;
+int cas_minuty_on = 0;
+int cas_hodiny_off = 0;
+int cas_minuty_off = 0;
 int cas_nastavit = 1037059200;
-int time_on = 1037074920;
-int time_off = 1037075100;
+int time_on = 1037059200;
+int time_off = 1037059200;
 int lang = 0;
 char minutka[32];
 char hodinka[32];
@@ -51,17 +63,27 @@
               }
     
     }
-
+    
+void send_color(float color_r = 255,float color_g = 255, float color_b = 255, float brightness = 0){
+    
+    brightness = 100 - brightness;
+    
+    color_r = color_r * 0.00387855; //příklad 255*0,0039 se rovná 0.9945 což znamená že je to 1 barevný bod; 0.9945 vezmeme a vynásobíme 0,0039 což nám vznikne tady toto, funguje to nevim jak to funguje
+    color_g = color_g * 0.00387855; // example 255*0,0039 equals to 0.9945 which means that this is one color point out of 255; we take the 0.9945 and multiply it by 0,0039 which results to this, it works I dunno how
+    color_b = color_b * 0.00387855;
+    
+    color_r = color_r - ((color_r*0.01)*brightness); //jas vypocitame tak ze si vezmeme kolik je jedno procento vybraných barevných bodů a to vynásobíme cislem jak moc chceme omezit tento jas
+    color_g = color_g - ((color_g*0.01)*brightness); //we calculate the brightness by taking the choosen color points and getting how much is 1% then we just make it how much do we want to lower the brightness
+    color_b = color_b - ((color_b*0.01)*brightness);
+    write_color(color_r,color_g,color_b);
+    }
 
-void led2_thread()
-{
-    while (true) {
-        led2 = !led2;
-        Thread::wait(1000);
-    }
+void write_color(float red,float green, float blue){
+    r.write(red);
+    g.write(green);
+    b.write(blue);
 }
 
-
 /*
  v ILI9341.cpp zmeneny framerate ze 70 na 100, toto pomohlo problemu blikání displeje
  velikost fotky pro čudlik 180x70
@@ -69,14 +91,11 @@
 
 4x doprava jas pro cudliky v menu
 
-
+predelat na konci jmena cudliku
 */
 
 
-void grafika(unsigned short int press = 0){  
-    int spodni_pravy[] = {239,200,320,240,Black};
-      
-      
+void grafika(unsigned short int press = 0){   
      switch(press)
 {
     case 1:
@@ -105,20 +124,17 @@
         spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek);           
         break;
     case 3:
-        spi.Bitmap(0,200,80,40,(unsigned char*)gImage_spodni_levy);
+        spi.fillrect(0,200,106,240,Black);
+    spi.Bitmap(13,200,80,40,(unsigned char*)gImage_spodni_levy);
         break;
     case 4:
-        spi.Bitmap(80,200,80,40,(unsigned char*)gImage_stredni_levy);        
+        spi.fillrect(107,200,213,240,Black);
+    spi.Bitmap(120,200,80,40,(unsigned char*)gImage_stredni_levy);//prostredni       
         break;        
     case 5:
-        spi.Bitmap(160,200,80,40,(unsigned char*)gImage_stredni_pravy);
-        break;        
-    case 6:
-        spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]);                //pravy kraj spodni
-        break;           
-    case 8:
-        spi.Bitmap(0,200,80,40,(unsigned char*)gImage_spodni_levy);    
-        break;
+        spi.fillrect(214,200,320,240,Black);
+    spi.Bitmap(227,200,80,40,(unsigned char*)gImage_stredni_pravy);//pravy spodni
+        break;                  
         
     default:
    spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi);
@@ -138,12 +154,15 @@
         spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek);
         spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek);
           
-
-    //spi.Bitmap(160,200,80,40,(unsigned char*)gImage_stredni_levy);                                        
-    spi.Bitmap(0,200,80,40,(unsigned char*)gImage_spodni_levy);
-    spi.Bitmap(80,200,80,40,(unsigned char*)gImage_stredni_levy);
-    spi.Bitmap(160,200,80,40,(unsigned char*)gImage_stredni_pravy);           //stred pravy spodni
-    spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]);                //pravy kraj spodni
+    spi.fillrect(0,200,106,240,Black);
+    spi.Bitmap(13,200,80,40,(unsigned char*)gImage_spodni_levy);
+    
+    spi.fillrect(107,200,213,240,Black);
+    spi.Bitmap(120,200,80,40,(unsigned char*)gImage_stredni_levy);//prostredni
+    
+    spi.fillrect(214,200,320,240,Black);
+    spi.Bitmap(227,200,80,40,(unsigned char*)gImage_stredni_pravy);//pravy spodni
+    
 }  
 }
 
@@ -183,10 +202,9 @@
     int levy[] = {34,274,165,320}; //levý čudlík
     //int cudlik[] = {20,80,42,130,Orange}; //slider    nepovedeny projekt
     //int stred_cudliku[] = {30,105,Blue};  //střed čudliku
-    int spodni_levy[] = {200,240,240,320}; // levy spodni cudlik
-    int stredni_levy[] = {200,160,240,239}; //stred levy spodni cudlik
-    int stredni_pravy[] = {200,80,240,158}; //stred pravy spodni cudlik
-    int spodni_pravy[] = {200,0,240,77}; // pravy spodni cudlik
+    int spodni_levy[] = {200,214,240,320}; // pravy spodni cudlik
+    int stredni_levy[] = {200,107,240,213}; //stred spodni cudlik
+    int stredni_pravy[] = {200,0,240,106}; //stred levy spodni cudlik
     
     int cudlik_1[] = {10,213,58,260};
     int cudlik_2[] = {10,137,58,184};
@@ -232,7 +250,6 @@
             hold();
               grafika(1);
               Menu(m);
-               wait(0.2); 
             }
                    
             //pravý čudlik
@@ -256,22 +273,23 @@
             
             hold();
               grafika(2);
-              wait(0.2);
+
               Menu(m);
             }  
             //levý čudlik
 
             //levý spodni čudlik
             if ((touch_x > spodni_levy[0]) && (touch_x < spodni_levy[2]) && (touch_y < spodni_levy[3]) && (touch_y > spodni_levy[1])){
-            spi.Bitmap(0,200,80,40,(unsigned char*)gImage_spodni_levy_s);
+            spi.fillrect(0,200,106,240,Select);
+            spi.Bitmap(13,200,80,40,(unsigned char*)gImage_spodni_levy_s);
               
             hold();
                 
               grafika(9);
-              grafika(8);
+              grafika(3);
               grafika(7);
               nastaveni();
-               wait(0.2);
+
             }  
             //levý spodni čudlik
             
@@ -279,42 +297,29 @@
             //stred levy spodni cudlik
             if ((touch_x > stredni_levy[0]) && (touch_x < stredni_levy[2]) && (touch_y < stredni_levy[3]) && (touch_y > stredni_levy[1])){
 
-            
-            spi.Bitmap(80,200,80,40,(unsigned char*)gImage_stredni_levy_s);
+            spi.fillrect(107,200,213,240,Select);
+            spi.Bitmap(120,200,80,40,(unsigned char*)gImage_stredni_levy_s);
 
             
-            thread.start(led2_thread);
+            on_off();
             
             hold();
               grafika(4);
-               wait(0.2);
+
             }
             //stred levy spodni cudlik
 
                         
             //stred pravy spodni cudlik
             if ((touch_x > stredni_pravy[0]) && (touch_x < stredni_pravy[2]) && (touch_y < stredni_pravy[3]) && (touch_y > stredni_pravy[1])){
-            spi.Bitmap(160,200,80,40,(unsigned char*)gImage_stredni_pravy_s);
-            
-            thread.terminate();    
-            hold();
+            spi.fillrect(214,200,320,240,Select);
+            spi.Bitmap(227,200,80,40,(unsigned char*)gImage_stredni_pravy_s);
+             hold();
               grafika(5);
-               wait(0.2);
+            color_picker();
+        
             }  
             //stred pravy spodni cudlik
-
-            //kraj pravy spodni cudlik
-            if ((touch_x > spodni_pravy[0]) && (touch_x < spodni_pravy[2]) && (touch_y < spodni_pravy[3]) && (touch_y > spodni_pravy[1])){
-            
-            hold();
-            
-            spi.locate(255,210);
-            spi.printf("%s",buffer);
-            
-             // grafika(6);
-               wait(0.2);
-            } 
-            //kraj pravy spodni cudlik
           
 //MENU CUDLIKY**********************************************************************************************************************************************************************************
             //prvni
@@ -411,28 +416,20 @@
     }
 
 void Static(){
-    int red1[] = {213,76,260,124};
-    int green1[] = {137,76,184,124};
-    int blue1[] = {60,76,107,124};
-   
+
+    int green1[] = {109,40,212,143};
+    int green[] = {40,109,143,212};
     
-    int red[] = {76,213,124,260};
-    int green[] = {76,137,124,184};
-    int blue[] = {76,60,124,107};
-
-
+    int stredni_pravy[] = {200,0,240,106}; //stred levy spodni cudlik
     int pravy[] = {34,0,165,46}; //pravý čudlík
     int levy[] = {34,274,165,320}; //levý čudlík
     
     spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi);
-    spi.fillrect(red1[0],red1[1],red1[2],red1[3],Red); 
-    spi.fillrect(green1[0],green1[1],green1[2],green1[3],Green);
-    spi.fillrect(blue1[0],blue1[1],blue1[2],blue1[3],Blue); 
+
+    spi.fillrect(green1[0],green1[1],green1[2],green1[3],White);
+
+    int color_pick = White;
     
-    
-    int r = 1;
-    int g = 1;
-    int b = 1;
     while(1)
     {
       if (touch.DataAvailable())
@@ -452,13 +449,51 @@
             spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s);
             //GRAFIKA**************************************************
             hold();
-            my_red = r;
-            my_green = g;
-            my_blue = b;
+            thread.terminate();
+            switch (color_pick){
+    case Red:
+     send_color(255,0,0,led_jas);
+      break;
+    case Orange:
+      send_color(255,128,0,led_jas);
+      break;
+    case Yellow:
+     send_color(255,255,0,led_jas);
+      break;
+    case GreenYellow:
+      send_color(127,255,0,led_jas);
+      break;
+    case Green:
+     send_color(0,255,0,led_jas);
+      break;
+    case White:
+      send_color(255,255,255,led_jas);
+      break;
+    case Cyan:
+     send_color(0,255,255,led_jas);
+      break;
+    case DarkCyan:
+     send_color(0,127,255,led_jas);
+      break;
+    case Blue:
+     send_color(0,0,255,led_jas);
+      break;
+    case Purple:
+    send_color(127,0,255,led_jas);
+      break;
+    case Magenta:
+     send_color(255,0,255,led_jas);
+      break;
+    case Pink:
+     send_color(255,0,127,led_jas);
+      break;
+    default:
+    send_color(255,255,255,led_jas);
+}
+     
               grafika(1);
               grafika(2);
               Menu();
-            wait(0.2); 
             }       
             //pravý čudlik
             
@@ -474,38 +509,153 @@
             hold();
               grafika(2);
               grafika(1);
-              wait(0.2);
               Menu();
             }  
             //levý čudlik
           
-if((touch_x > red[0]) && (touch_x < red[2]) && (touch_y < red[3]) && (touch_y > red[1])){
-            hold();   
-            r = !r;
-            printf("%d",r); 
-            wait(0.2);     
-}
-
+          //stred pravy spodni cudlik
+            if ((touch_x > stredni_pravy[0]) && (touch_x < stredni_pravy[2]) && (touch_y < stredni_pravy[3]) && (touch_y > stredni_pravy[1])){
+            spi.fillrect(214,200,320,240,Select);
+            spi.Bitmap(227,200,80,40,(unsigned char*)gImage_stredni_pravy_s);
+             hold();
+              grafika(5);
+            color_picker();
+        
+            }  
+            //stred pravy spodni cudlik
+          
 if((touch_x > green[0]) && (touch_x < green[2]) && (touch_y < green[3]) && (touch_y > green[1])){  
             hold(); 
-            g = !g;
-            printf("%d",g); 
-            wait(0.2);     
+            color_pick = color_picker(); 
+            spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi);
+            spi.fillrect(green1[0],green1[1],green1[2],green1[3],color_pick);  
+ 
 }
-
-if((touch_x > blue[0]) && (touch_x < blue[2]) && (touch_y < blue[3]) && (touch_y > blue[1])){
-            hold();   
-            b = !b;
-            printf("%d",b); 
-            wait(0.2);     
-}
-
          }
     } 
   }
 
 }
 
+int color_picker(){
+    
+    int pole1[] = {69,29,116,76};
+    int pole2[] = {117,29,163,76};
+    int pole3[] = {164,29,210,76};
+    int pole4[] = {211,29,257,76};
+    int pole5[] = {69,77,116,123};
+    int pole6[] = {117,77,163,123};
+    int pole7[] = {164,77,210,123};
+    int pole8[] = {211,77,257,123};
+    int pole9[] = {69,124,116,170};
+    int pole10[] = {117,124,163,170};
+    int pole11[] = {164,124,210,170};
+    int pole12[] = {211,124,257,170};
+    
+    
+    int pole4t[] = {29,69,76,116};
+    int pole3t[] = {29,117,76,163};
+    int pole2t[] = {29,164,76,210};
+    int pole1t[] = {29,211,76,257};
+    int pole8t[] = {77,69,123,116};
+    int pole7t[] = {77,117,123,163};
+    int pole6t[] = {77,164,123,210};
+    int pole5t[] = {77,211,123,257};
+    int pole12t[] = {124,69,170,116};
+    int pole11t[] = {124,117,170,163};
+    int pole10t[] = {124,164,170,210};
+    int pole9t[] = {124,211,170,257};
+    
+    spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi);
+    spi.fillrect(pole1[0],pole1[1],pole1[2],pole1[3],Red); 
+    spi.fillrect(pole2[0],pole2[1],pole2[2],pole2[3],Orange);
+    spi.fillrect(pole3[0],pole3[1],pole3[2],pole3[3],Yellow); 
+    spi.fillrect(pole4[0],pole4[1],pole4[2],pole4[3],GreenYellow);
+    spi.fillrect(pole5[0],pole5[1],pole5[2],pole5[3],Green); 
+    spi.fillrect(pole6[0],pole6[1],pole6[2],pole6[3],White);
+    spi.fillrect(pole7[0],pole7[1],pole7[2],pole7[3],Cyan); 
+    spi.fillrect(pole8[0],pole8[1],pole8[2],pole8[3],DarkCyan);
+    spi.fillrect(pole9[0],pole9[1],pole9[2],pole9[3],Blue); 
+    spi.fillrect(pole10[0],pole10[1],pole10[2],pole10[3],Purple);
+    spi.fillrect(pole11[0],pole11[1],pole11[2],pole11[3],Magenta); 
+    spi.fillrect(pole12[0],pole12[1],pole12[2],pole12[3],Pink); 
+    
+
+    while(1)
+    {
+      if (touch.DataAvailable())
+      {
+        if(touch.Read())
+        {
+         unsigned short int touch_y = touch.GetX();  // 0-320
+         unsigned short int  touch_x = touch.GetY(); // 0-240
+     
+if((touch_x > pole1t[0]) && (touch_x < pole1t[2]) && (touch_y < pole1t[3]) && (touch_y > pole1t[1])){
+            hold();
+            return Red;   
+}
+
+if((touch_x > pole2t[0]) && (touch_x < pole2t[2]) && (touch_y < pole2t[3]) && (touch_y > pole2t[1])){  
+            hold(); 
+            return Orange;   
+}
+
+if((touch_x > pole3t[0]) && (touch_x < pole3t[2]) && (touch_y < pole3t[3]) && (touch_y > pole3t[1])){
+            hold();   
+            return Yellow;      
+}
+
+if((touch_x > pole4t[0]) && (touch_x < pole4t[2]) && (touch_y < pole4t[3]) && (touch_y > pole4t[1])){
+            hold();
+           return GreenYellow;    
+}
+
+if((touch_x > pole5t[0]) && (touch_x < pole5t[2]) && (touch_y < pole5t[3]) && (touch_y > pole5t[1])){
+            hold();
+            return Green;      
+}
+
+if((touch_x > pole6t[0]) && (touch_x < pole6t[2]) && (touch_y < pole6t[3]) && (touch_y > pole6t[1])){
+            hold();
+            return White;    
+}
+
+if((touch_x > pole7t[0]) && (touch_x < pole7t[2]) && (touch_y < pole7t[3]) && (touch_y > pole7t[1])){
+            hold();
+            return Cyan;   
+}
+
+if((touch_x > pole8t[0]) && (touch_x < pole8t[2]) && (touch_y < pole8t[3]) && (touch_y > pole8t[1])){
+            hold();
+            return DarkCyan;    
+}
+
+if((touch_x > pole9t[0]) && (touch_x < pole9t[2]) && (touch_y < pole9t[3]) && (touch_y > pole9t[1])){
+            hold();
+            return Blue;    
+}
+
+if((touch_x > pole10t[0]) && (touch_x < pole10t[2]) && (touch_y < pole10t[3]) && (touch_y > pole10t[1])){
+            hold();
+            return Purple;    
+}
+
+if((touch_x > pole11t[0]) && (touch_x < pole11t[2]) && (touch_y < pole11t[3]) && (touch_y > pole11t[1])){
+            hold();
+            return Magenta;    
+}
+
+if((touch_x > pole12t[0]) && (touch_x < pole12t[2]) && (touch_y < pole12t[3]) && (touch_y > pole12t[1])){
+            hold();
+            return Pink;    
+}
+         }
+    } 
+  }
+
+}
+
+
 void nastaveni(){   
     int pravy[] = {34,0,165,46}; //pravý čudlík
     int levy[] = {34,274,165,320}; //levý čudlík
@@ -789,7 +939,424 @@
 }
 }
 
+void on_off(){
+    int pravy[] = {34,0,165,46}; //pravý čudlík
+    int levy[] = {34,274,165,320}; //levý čudlík
+    
+    int up1[] = {172,28,258,57};  
+    int down1[] = {172,142,258,171};  
+    
+    int up2[] = {62,28,148,57};  
+    int down2[] = {62,142,148,171};    
+    
+    bool a = true;  
+    
+    cas_hodiny_on = 0; 
+    cas_minuty_on = 0; 
+    cas_hodiny_off = 0; 
+    cas_minuty_off = 0; 
+    
+    int h1_on = cas_hodiny_on / 10;
+    int h2_on = cas_hodiny_on % 10;
 
+    int h1_off = cas_hodiny_off / 10;
+    int h2_off = cas_hodiny_off % 10;
+
+    char cisla[10][3] = {
+                         "0",
+                         "1",
+                         "2",
+                         "3",
+                         "4",
+                         "5",
+                         "6",
+                         "7",
+                         "8",
+                         "9"
+                     };
+
+    int m1_on = cas_minuty_on / 10;
+    int m2_on = cas_minuty_on % 10;
+    
+    int m1_off = cas_minuty_off / 10;
+    int m2_off = cas_minuty_off % 10;
+    
+    int blue1[] = {71,65,249,134};
+    int bar2[] = {159,200,320,240};
+    int bar1[] = {0,200,160,240};
+    
+    int b1[] = {200,159,240,320}; 
+    int b2[] = {200,0,240,160};
+    spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi);
+    spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru);
+    spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu);
+        
+    spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru);
+    spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu); 
+    
+    
+    spi.fillrect(bar1[0],bar1[1],bar1[2],bar1[3],Select);
+    spi.fillrect(bar2[0],bar2[1],bar2[2],bar2[3],Black);
+    spi.fillrect(blue1[0],blue1[1],blue1[2],blue1[3],MojeSeda);
+    
+    spi.set_font((unsigned char*) Arial21x21);
+    spi.background(Select);
+    spi.locate(55,210);
+    spi.printf(" ON");
+    spi.background(Black);
+    spi.locate(215,210);
+    spi.printf(" OFF");
+    
+    spi.set_font((unsigned char*) Arial48x47);
+    spi.background(MojeSeda);
+    spi.locate(80,80);
+    spi.printf(cisla[h1_on]);
+    spi.locate(110,80);
+    spi.printf(cisla[h2_on]);
+    spi.locate(155,80);
+    spi.printf(":");
+    spi.locate(189,80);
+    spi.printf(cisla[m1_on]);
+    spi.locate(219,80);
+    spi.printf(cisla[m2_on]);
+    
+    grafika(9);
+    grafika(7);
+    while(1){
+if (touch.DataAvailable())
+      {
+        if(touch.Read())
+        {
+         unsigned short int touch_y = touch.GetX();  // 0-320
+         unsigned short int  touch_x = touch.GetY(); // 0-240
+         
+          //pravý čudlik
+            if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){
+            
+            //GRAFIKA**************************************************
+            spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s);
+            spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit_s);
+            spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s);
+            spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s);
+            //GRAFIKA**************************************************
+            hold();
+             
+             time_on = 1037059200 + (cas_hodiny_on * 3600) +  (cas_minuty_on * 60);
+             time_off = 1037059200 + (cas_hodiny_off * 3600) +  (cas_minuty_off * 60);
+              
+              grafika();
+              Button();
+            wait(0.2); 
+            }       
+            //pravý čudlik
+            
+            //levý čudlik 
+            if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){
+            //GRAFIKA**************************************************
+        spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s);
+        spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit_s);// levy
+        spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s);
+        spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s);
+            //GRAFIKA**************************************************
+            
+            hold();
+              grafika();
+              Button();
+            wait(0.2);
+            }  
+            //levý čudlik
+            
+            //ON 
+            if ((touch_x > b1[0]) && (touch_x < b1[2]) && (touch_y < b1[3]) && (touch_y > b1[1])){
+           
+            spi.fillrect(bar1[0],bar1[1],bar1[2],bar1[3],Select);
+            spi.set_font((unsigned char*) Arial21x21);
+            spi.background(Select);
+            spi.locate(55,210);
+            spi.printf(" ON");  
+            
+              spi.set_font((unsigned char*) Arial48x47);
+              spi.background(MojeSeda);
+              spi.locate(80,80);
+              spi.printf(cisla[h1_on]);
+              spi.locate(110,80);
+              spi.printf(cisla[h2_on]);
+              spi.locate(189,80);
+              spi.printf(cisla[m1_on]);
+              spi.locate(219,80);
+              spi.printf(cisla[m2_on]);
+            
+            spi.fillrect(bar2[0],bar2[1],bar2[2],bar2[3],Black);
+            spi.set_font((unsigned char*) Arial21x21);
+            spi.background(Black);
+            spi.locate(215,210);
+            spi.printf(" OFF");
+            
+            a = true;
+            hold();
+            wait(0.2);
+            }  
+            //ON
+            
+            //OFF 
+            if ((touch_x > b2[0]) && (touch_x < b2[2]) && (touch_y < b2[3]) && (touch_y > b2[1])){
+            spi.fillrect(bar1[0],bar1[1],bar1[2],bar1[3],Black);
+            spi.set_font((unsigned char*) Arial21x21);
+            spi.background(Black);
+            spi.locate(55,210);
+            spi.printf(" ON");  
+            
+            spi.set_font((unsigned char*) Arial48x47);
+              spi.background(MojeSeda);
+              spi.locate(80,80);
+              spi.printf(cisla[h1_off]);
+              spi.locate(110,80);
+              spi.printf(cisla[h2_off]);
+              spi.locate(189,80);
+              spi.printf(cisla[m1_off]);
+              spi.locate(219,80);
+              spi.printf(cisla[m2_off]);
+            
+            
+            spi.fillrect(bar2[0],bar2[1],bar2[2],bar2[3],Select);
+            spi.set_font((unsigned char*) Arial21x21);
+            spi.background(Select);
+            spi.locate(215,210);
+            spi.printf(" OFF");
+            a = false;
+            hold();
+            wait(0.2);
+            }  
+            //OFF
+            
+if(a == true){////////////////////////////////////ON
+if((touch_x > up1[1]) && (touch_x < up1[3]) && (touch_y < up1[2]) && (touch_y > up1[0])){
+            spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru_s);
+     while ((touch.DataAvailable()) && (h2_on < 10)){
+            h2_on++;
+            cas_hodiny_on++;
+            if(cas_hodiny_on == 24){
+            cas_hodiny_on = 0;
+            }
+            if(h2_on == 10){
+            h2_on = 0;
+            h1_on++;
+            }
+            if((h1_on == 2)&&(h2_on == 4)){
+            h2_on = 0;
+            h1_on = 0;
+            }
+             spi.set_font((unsigned char*) Arial48x47);
+              spi.background(MojeSeda);
+              spi.locate(80,80);
+              spi.printf(cisla[h1_on]);
+              spi.locate(110,80);
+              spi.printf(cisla[h2_on]); 
+
+              
+              wait(0.1); 
+    }
+            spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru);     
+}
+if((touch_x > down1[1]) && (touch_x < down1[3]) && (touch_y < down1[2]) && (touch_y > down1[0])){
+            spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu_s); 
+    while ((touch.DataAvailable()) && (h2_on < 10)){
+            h2_on--;
+            if((h2_on < 0)&&(h1_on == 0)){
+            h2_on = 3;
+            h1_on = 2;
+            }
+            if(h2_on < 0){
+            h2_on = 9;
+            h1_on--;
+            }
+            cas_hodiny_on--;
+            if(cas_hodiny_on < 0){
+            cas_hodiny_on = 23;
+            }
+            spi.set_font((unsigned char*) Arial48x47);
+              spi.background(MojeSeda);
+              spi.locate(80,80);
+              spi.printf(cisla[h1_on]);
+              spi.locate(110,80);
+              spi.printf(cisla[h2_on]);
+            wait(0.1);
+    }
+            spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu); 
+} 
+if((touch_x > up2[1]) && (touch_x < up2[3]) && (touch_y < up2[2]) && (touch_y > up2[0])){
+            spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru_s);
+    while ((touch.DataAvailable()) && (m2_on < 10)){
+            m2_on++;
+            cas_minuty_on++;
+            if(cas_minuty_on == 60){
+            cas_minuty_on = 0;
+            }
+            if((m1_on == 5)&&(m2_on == 10)){
+            m2_on = 0;
+            m1_on = 0;
+            }
+            if(m2_on == 10){
+            m2_on = 0;
+            m1_on++;
+            }
+            spi.set_font((unsigned char*) Arial48x47);
+              spi.background(MojeSeda);
+              spi.locate(189,80);
+              spi.printf(cisla[m1_on]);
+              spi.locate(219,80);
+              spi.printf(cisla[m2_on]);
+            wait(0.1);
+    }
+            
+            spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru);    
+}
+if((touch_x > down2[1]) && (touch_x < down2[3]) && (touch_y < down2[2]) && (touch_y > down2[0])){
+            spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu_s); 
+    while ((touch.DataAvailable()) && (m2_on < 10)){
+            m2_on--;
+            if((m2_on < 0)&&(m1_on == 0)){
+            m2_on = 9;
+            m1_on = 5;
+            }
+            if(m2_on < 0){
+            m2_on = 9;
+            m1_on--;
+            }
+            cas_minuty_on--;
+            if(cas_minuty_on < 0){
+            cas_minuty_on = 59;
+            }
+            spi.set_font((unsigned char*) Arial48x47);
+              spi.background(MojeSeda);
+              spi.locate(189,80);
+              spi.printf(cisla[m1_on]);
+              spi.locate(219,80);
+              spi.printf(cisla[m2_on]);
+            wait(0.1);
+    }
+            
+            spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu);   
+} 
+            
+}
+else{////////////////////////////////////OFF
+if((touch_x > up1[1]) && (touch_x < up1[3]) && (touch_y < up1[2]) && (touch_y > up1[0])){
+            spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru_s);
+     while ((touch.DataAvailable()) && (h2_off < 10)){
+            h2_off++;
+            cas_hodiny_off++;
+            if(cas_hodiny_off == 24){
+            cas_hodiny_off = 0;
+            }
+            if(h2_off == 10){
+            h2_off = 0;
+            h1_off++;
+            }
+            if((h1_off == 2)&&(h2_off == 4)){
+            h2_off = 0;
+            h1_off = 0;
+            }
+             spi.set_font((unsigned char*) Arial48x47);
+              spi.background(MojeSeda);
+              spi.locate(80,80);
+              spi.printf(cisla[h1_off]);
+              spi.locate(110,80);
+              spi.printf(cisla[h2_off]); 
+
+              
+              wait(0.1); 
+    }
+            spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru);     
+}
+if((touch_x > down1[1]) && (touch_x < down1[3]) && (touch_y < down1[2]) && (touch_y > down1[0])){
+            spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu_s); 
+    while ((touch.DataAvailable()) && (h2_off < 10)){
+            h2_off--;
+            if((h2_off < 0)&&(h1_off == 0)){
+            h2_off = 3;
+            h1_off = 2;
+            }
+            if(h2_off < 0){
+            h2_off = 9;
+            h1_off--;
+            }
+            cas_hodiny_off--;
+            if(cas_hodiny_off < 0){
+            cas_hodiny_off = 23;
+            }
+            spi.set_font((unsigned char*) Arial48x47);
+              spi.background(MojeSeda);
+              spi.locate(80,80);
+              spi.printf(cisla[h1_off]);
+              spi.locate(110,80);
+              spi.printf(cisla[h2_off]);
+            wait(0.1);
+    }
+            spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu); 
+} 
+if((touch_x > up2[1]) && (touch_x < up2[3]) && (touch_y < up2[2]) && (touch_y > up2[0])){
+            spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru_s);
+    while ((touch.DataAvailable()) && (m2_off < 10)){
+            m2_off++;
+            cas_minuty_off++;
+            if(cas_minuty_off == 60){
+            cas_minuty_off = 0;
+            }
+            if((m1_off == 5)&&(m2_off == 10)){
+            m2_off = 0;
+            m1_off = 0;
+            }
+            if(m2_off == 10){
+            m2_off = 0;
+            m1_off++;
+            }
+            spi.set_font((unsigned char*) Arial48x47);
+              spi.background(MojeSeda);
+              spi.locate(189,80);
+              spi.printf(cisla[m1_off]);
+              spi.locate(219,80);
+              spi.printf(cisla[m2_off]);
+            wait(0.1);
+    }
+            
+            spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru);    
+}
+if((touch_x > down2[1]) && (touch_x < down2[3]) && (touch_y < down2[2]) && (touch_y > down2[0])){
+            spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu_s); 
+    while ((touch.DataAvailable()) && (m2_off < 10)){
+            m2_off--;
+            if((m2_off < 0)&&(m1_off == 0)){
+            m2_off = 9;
+            m1_off = 5;
+            }
+            if(m2_off < 0){
+            m2_off = 9;
+            m1_off--;
+            }
+            cas_minuty_off--;
+            if(cas_minuty_off < 0){
+            cas_minuty_off = 59;
+            }
+            spi.set_font((unsigned char*) Arial48x47);
+              spi.background(MojeSeda);
+              spi.locate(189,80);
+              spi.printf(cisla[m1_off]);
+              spi.locate(219,80);
+              spi.printf(cisla[m2_off]);
+            wait(0.1);
+    }
+            
+            spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu);   
+}    
+    
+}
+
+
+    }
+}
+}
+}
 
 void nastavit_hodiny(){
     int pravy[] = {34,0,165,46}; //pravý čudlík
@@ -869,9 +1436,9 @@
             spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s);
             //GRAFIKA**************************************************
             hold();
-             thread.terminate();
+             thread_h.terminate();
              cas_nastavit = 1037059200 + (cas_hodiny * 3600) +  (cas_minuty * 60);
-             thread.start(hodiny);
+             thread_h.start(hodiny);
               grafika(9);
               nastaveni();
             wait(0.2); 
@@ -1028,6 +1595,9 @@
     }
 
 main(){
+r.period_us(1000);
+g.period_us(1000);
+b.period_us(1000);
 
 my_red = 1;
 my_green = 1;
@@ -1039,16 +1609,13 @@
     spi.background(Black);
     spi.foreground(White);
     spi.cls();
-
+    send_color(255,20,147,100);
 
     grafika();
     
     br.period_us(1000);
     br.write(lcd_jas);
 
-    
- /*   nastavit_hodiny();
-    thread.start(hodiny);*/
     Button();
 
     
--- a/display.h	Sun Jan 16 12:06:03 2022 +0000
+++ b/display.h	Tue Feb 01 13:37:40 2022 +0000
@@ -1,7 +1,9 @@
 #include "mbed.h"
+#include "rtos.h"
 #include "UTouch.h"
 #include "ILI9341.h"
 #include "../Font/Arial19x19.h"
+#include "../Font/Arial21x21.h"
 #include "../Font/Arial28x28.h"
 #include "../Font/Arial48x47.h"
 #include "../grafika/pozadi.c"
@@ -39,11 +41,13 @@
 #include "../grafika/dolu.c"
 #include "../grafika/dolu_s.c"
 
-
+int color_picker();
+void write_color(float red,float green, float blue);
 void Menu(int strana);
 void grafika(unsigned short int press);
 void Button(int strana);
 void Static();
+void on_off();
 void nastaveni();
 void brightness();
 void nastavit_hodiny();