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

Dependencies:   mbed mbed-rtos UTouch_vyrobek UniGraphic

display.cpp

Committer:
smejky
Date:
2022-01-08
Revision:
9:d1385f7171af
Parent:
8:b6e7401fdcfc
Child:
10:0176705be216

File content as of revision 9:d1385f7171af:

#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
DigitalOut my_green(LED2);
DigitalOut my_red(LED4);
DigitalOut my_blue(LED3);
DigitalOut led2(LED2);
Thread thread;
PwmOut br(D9);

int cas_nastavit = 1037059200;
int lang = 0;
char buffer[32];
char jazyk [3][20] = {
                         "Czech",
                         "English",
                         "  Set Time"
                     };   
char en[3][20] = {
                         "Czech",
                         "English",
                         "  Set Time"
                     };
char cz[3][20] = {
                         "Cestina",
                         "Anglictina",
                         "Nastavit cas"
                     };



void hold(){
    int i = touch.DataAvailable();
     while (i){
              i = touch.DataAvailable();
              }
    
    }


void led2_thread()
{
    while (true) {
        led2 = !led2;
        Thread::wait(1000);
    }
}


/*
 v ILI9341.cpp zmeneny framerate ze 70 na 100, toto pomohlo problemu blikání displeje
 velikost fotky pro čudlik 180x70
x0 = od leveho horniho rohu(240max) y=0 od leveho horniho rohu x1 = od pravého spodniho rohu(240max) mel by byt vetsi nez x0 y1 = od pravého spodniho rohu mel by byt vetsi nez y0

*/


void grafika(unsigned short int press = 0){  
    int spodni_pravy[] = {239,200,320,240,Black};
      
      
     switch(press)
{
    case 1:
        spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch);
        spi.Bitmap(274,72,46,42,(unsigned char*)gImage_cudlik_otoc);             // pravy
        spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek);
        spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek);           //pravy 
        
        break;
    case 2:
        spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch);
        spi.Bitmap(0,72,46,42,(unsigned char*)gImage_cudlik);// levy
        spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek);
        spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek);
        break;
    case 7: //zrusit
        spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch);
        spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit);// levy
        spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek);
        spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek);
        break;
    case 9: //potvrdit
        spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch);
        spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit);             // pravy
        spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek);
        spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek);           //pravy 
        break;
    case 3:
        spi.Bitmap(0,200,80,40,(unsigned char*)gImage_spodni_levy);
        break;
    case 4:
        spi.Bitmap(80,200,80,40,(unsigned char*)gImage_stredni_levy);        
        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;
        
    default:
   spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi);
    
    spi.Bitmap(274,0,46,36,(unsigned char*)gImage_vypln);//pravy
    spi.Bitmap(274,165,46,36,(unsigned char*)gImage_vypln);//pravy
    spi.Bitmap(0,0,46,36,(unsigned char*)gImage_vypln);//levy
    spi.Bitmap(0,165,46,36,(unsigned char*)gImage_vypln);//levy
    
        spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch);
        spi.Bitmap(274,72,46,42,(unsigned char*)gImage_cudlik_otoc);             // pravy
        spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek);
        spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek);           //pravy   
        
        spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch);
        spi.Bitmap(0,72,46,42,(unsigned char*)gImage_cudlik);// levy
        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
}  
}

void malovani(){
    
    while(1==1)
    {
      if (touch.DataAvailable())
      {
        if(touch.Read())
        {
         unsigned short int touch_y = touch.GetX();
         unsigned short int  touch_x = touch.GetY();
         touch_x = touch_x - 10;
         touch_y = touch_y + 10;
         spi.pixel(touch_x,touch_y,Blue);           
        }
     }
    }
}

/*
else if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy [1])){
              R_is_pressed = 1;
              spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]);
               wait(0.1);   
            } 

*/





void Button(int strana = 0){
    int pravy[] = {34,0,165,46}; //pravý čudlík
    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 cudlik_1[] = {10,213,58,260};
    int cudlik_2[] = {10,137,58,184};



      
  
    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
         touch_x = touch_x - 5;
         touch_y = touch_y + 10;
         //spi.pixel(touch_x,touch_y,Blue);
         //printf("x %d ,y %d\r\n",touch_x,touch_y);
         
            //pravý čudlik
            if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){
            int m = strana;   
    switch(strana){
            case 0:
                m++;
            break;
            case 1:
                m++;
            break;
            default:
            m = 0;
   }
            //GRAFIKA**************************************************
            spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s);
            spi.Bitmap(274,72,46,42,(unsigned char*)gImage_cudlik_otoc_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();
              grafika(1);
              Menu(m);
               wait(0.2); 
            }
                   
            //pravý čudlik
            
            //levý čudlik 
            if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){
            int m = strana;   
    switch(strana){
            case 1:
                m--;
            break;
            default:
            m = 1;       
   }
            //GRAFIKA**************************************************
        spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s);
        spi.Bitmap(0,72,46,42,(unsigned char*)gImage_cudlik_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(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);
              
            hold();
                
              grafika(9);
              grafika(8);
              grafika(7);
              nastaveni();
               wait(0.2);
            }  
            //levý spodni čudlik
            
            
            //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);

            
            thread.start(led2_thread);
            
            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();
              grafika(5);
               wait(0.2);
            }  
            //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
            if ((touch_x > cudlik_1[0]) && (touch_x < cudlik_1[2]) && (touch_y < cudlik_1[3]) && (touch_y > cudlik_1[1]) && (strana == 1)){
            spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1s_vrch);
            spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1s_spodek);
            hold();
            spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1_vrch);
            spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1_spodek);
               wait(0.2);
            Static();
            } 

            
            //prvni
          //druhy
            if ((touch_x > cudlik_2[0]) && (touch_x < cudlik_2[2]) && (touch_y < cudlik_2[3]) && (touch_y > cudlik_2[1]) && (strana == 1)){
            spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1s_vrch);
            spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1s_spodek);
            hold();
            spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1_vrch);
            spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1_spodek);
               wait(0.2);
           
            } 

            
            //druhy
                      
        }
      }
    }    
}





void Menu(int strana = 0){   
    switch(strana)
{
    case 1:
    spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi);
    
    
    //CUDLIKY*******************************************************************************
    //prvni rada
    spi.Bitmap(213,10,48,24,(unsigned char*)gImage_cudlik3_vrch);
    spi.Bitmap(213,34,48,24,(unsigned char*)gImage_cudlik3_spodek);
    
    spi.Bitmap(137,10,48,24,(unsigned char*)gImage_cudlik2_vrch);
    spi.Bitmap(137,34,48,24,(unsigned char*)gImage_cudlik2_spodek);

    spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1_vrch);
    spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1_spodek);
    
    //prvni rada
    
    //druha rada
    spi.Bitmap(213,76,48,24,(unsigned char*)gImage_cudlik1_vrch);
    spi.Bitmap(213,100,48,24,(unsigned char*)gImage_cudlik1_spodek);
    
    spi.Bitmap(137,76,48,24,(unsigned char*)gImage_cudlik1_vrch);
    spi.Bitmap(137,100,48,24,(unsigned char*)gImage_cudlik1_spodek);
    
    spi.Bitmap(60,76,48,24,(unsigned char*)gImage_cudlik4_vrch);
    spi.Bitmap(60,100,48,24,(unsigned char*)gImage_cudlik4_spodek);
    // druha rada
    
    //treti rada
    spi.Bitmap(213,142,48,24,(unsigned char*)gImage_cudlik1_vrch);
    spi.Bitmap(213,166,48,24,(unsigned char*)gImage_cudlik1_spodek);
    
    spi.Bitmap(137,142,48,24,(unsigned char*)gImage_cudlik1_vrch);
    spi.Bitmap(137,166,48,24,(unsigned char*)gImage_cudlik1_spodek);
    
    spi.Bitmap(60,142,48,24,(unsigned char*)gImage_cudlik1_vrch);
    spi.Bitmap(60,166,48,24,(unsigned char*)gImage_cudlik1_spodek);
    // treti rada
    
    //CUDLIKY*******************************************************************************

    strana = 1;
    Button(strana);
                
        break;
    default:
    spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi);
    strana = 0;
    Button(strana);
} 
    }

void Static(){
    int red1[] = {213,76,260,124};
    int green1[] = {137,76,184,124};
    int blue1[] = {60,76,107,124};
   
    
    int red[] = {76,213,124,260};
    int green[] = {76,137,124,184};
    int blue[] = {76,60,124,107};


    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); 
    
    
    int r = 1;
    int g = 1;
    int b = 1;
    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_cudlik_otoc_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();
            my_red = r;
            my_green = g;
            my_blue = b;
              grafika(1);
              Menu();
            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_cudlik_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(2);
              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);     
}

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);     
}

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);     
}

         }
    } 
  }

}

void nastaveni(){   
    int pravy[] = {34,0,165,46}; //pravý čudlík
    int levy[] = {34,274,165,320}; //levý čudlík
    int i = 0;
    int jazyk_s = 0;
        
    spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi);
    int check1[] = {66,10,96,40};
    int check2[] = {66,56,96,86};

    int prvni[] = {46,0,273,46}; //pravý čudlík
    int druhy[] = {46,46,273,92}; //pravý čudlík
    int treti[] = {46,92,273,138}; //pravý čudlík
    
    spi.background(MojeSeda);
    spi.fillrect(prvni[0],prvni[1],prvni[2],prvni[3],MojeSeda); //prvni
    spi.rect(prvni[0],prvni[1],prvni[2],prvni[3],White); //prvni
    //spi.fillrect(check1[0],check1[1],check1[2],check1[3],Red);
    spi.set_font((unsigned char*) Arial28x28);
    spi.locate(140,14);
    spi.printf(jazyk[0]);
    
    spi.fillrect(druhy[0],druhy[1],druhy[2],druhy[3],MojeSeda); //druhy
    spi.rect(druhy[0],druhy[1],druhy[2],druhy[3],White); //druhy
   // spi.fillrect(check2[0],check2[1],check2[2],check2[3],Red);
    spi.locate(140,60);
    spi.printf(jazyk[1]);
    
switch(lang)
{
            case 1:
            spi.fillrect(check1[0],check1[1],check1[2],check1[3],Green);
            spi.fillrect(check2[0],check2[1],check2[2],check2[3],Red);
            break;
            default:
            spi.fillrect(check1[0],check1[1],check1[2],check1[3],Red);
            spi.fillrect(check2[0],check2[1],check2[2],check2[3],Green);
}    
    
    
    spi.fillrect(treti[0],treti[1],treti[2],treti[3],MojeSeda); //treti
    spi.rect(treti[0],treti[1],treti[2],treti[3],White); //treti
    spi.locate(90,106);
    spi.printf(jazyk[2]);
    
    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();
             switch(jazyk_s)
{
            case 1:
                    while(i < 3){
                        strcpy(jazyk[i], cz[i]);
                        i++;
                        }
            break;
            default:
                    while(i < 3){
                        strcpy(jazyk[i], en[i]);
                        i++;
                        }
}            
            i = 0;
              grafika(1);
              grafika(2);
              Menu();
            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(2);
              grafika(1);
              Menu();
            wait(0.2);
            }  
            //levý čudlik
          
if((touch_x > prvni[1]) && (touch_x < prvni[3]) && (touch_y < prvni[2]) && (touch_y > prvni[0])){
            hold();
            jazyk_s = 1;
            lang = jazyk_s; 
            spi.fillrect(check1[0],check1[1],check1[2],check1[3],Green);
            spi.fillrect(check2[0],check2[1],check2[2],check2[3],Red);
            wait(0.2);     
}
if((touch_x > druhy[1]) && (touch_x < druhy[3]) && (touch_y < druhy[2]) && (touch_y > druhy[0])){
            hold();
            jazyk_s = 0; 
            lang = jazyk_s; 
            spi.fillrect(check1[0],check1[1],check1[2],check1[3],Red);
            spi.fillrect(check2[0],check2[1],check2[2],check2[3],Green);
            wait(0.2);     
}
if((touch_x > treti[1]) && (touch_x < treti[3]) && (touch_y < treti[2]) && (touch_y > treti[0])){
            hold();
            nastavit_hodiny();  
}



         }
    }
        }
    
}

void nastavit_hodiny(){
    int pravy[] = {34,0,165,46}; //pravý čudlík
    int levy[] = {34,274,165,320}; //levý čudlík
    

    int green1[] = {180,65,249,134};
    int blue1[] = {71,65,140,134};
/*
    int nahoru1[] = {71,34,140,57};
    int dolu1[] = {71,142,140,165};
    
    int nahoru2[] = {};
    int dolu2[] = {};
    */
spi.Bitmap(71,34,69,23,(unsigned char*)gImage_nahoru);

    //spi.fillrect(nahoru1[0],nahoru1[1],nahoru1[2],nahoru1[3],Green);
    //spi.fillrect(dolu1[0],dolu1[1],dolu1[2],dolu1[3],Green);
    spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi);
    
    spi.fillrect(green1[0],green1[1],green1[2],green1[3],Green);
    spi.fillrect(blue1[0],blue1[1],blue1[2],blue1[3],Blue); 
    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();
             
              grafika(9);
              nastaveni();
            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(7);
              nastaveni();
            wait(0.2);
            }  
            //levý čudlik
            

    }
}
}
}


void hodiny(){
        set_time(cas_nastavit);
    while(1){
        time_t seconds = time(NULL);
        //seconds = seconds + 7200;
        strftime(buffer, 32, "%R", localtime(&seconds));
        Thread::wait(1000);
        }
    }

main(){

my_red = 1;
my_green = 1;
my_blue = 1;
    spi.set_orientation(3);
    spi.FastWindow(true);
    touch.InitTouch();
    touch.SetPrecision(PREC_EXTREME);
    spi.background(Black);
    spi.foreground(White);
    spi.cls();


    grafika();
    
    br.period_us(1000);
    br.write(0.50f);
   /* wait_ms(3000);
    
    br.write(0.25f);
    wait_ms(3000);
    br.write(0.0f);
    wait_ms(3000);
    br.write(0.25f);
    wait_ms(3000);
    br.write(0.50f);
    wait_ms(5000);
    br.write(0.80f);
    */
    
    grafika(7);
    grafika(9);    
    //nastaveni();
    nastavit_hodiny();
    thread.start(hodiny);
    Button();

    
}




/*  fail projekty
          //slider  
            if ((touch_x > cudlik[0]) && (touch_x < cudlik[2]) && (touch_y > cudlik[1]) && (touch_y < cudlik[3]) && (pressure > 0)){
            
            
        //if je udelany tady pro nastavení minima a maxima
           if ((touch_x > 25) && (touch_x < 140)){           
            
            unsigned short int y0 = cudlik[1];
            unsigned short int y1 = cudlik[3];      
            unsigned short int x_zadelavani_chyby = cudlik[0];
            unsigned short int x0 = x_zadelavani_chyby - 8;
              
              //printf("%d\r\n",touch_x);                  
              stred_cudliku[0] = touch_x;
              
              cudlik[0] = stred_cudliku[0] - 10;
              cudlik[1] = stred_cudliku[1] - 25;
              cudlik[2] = stred_cudliku[0] + 10;
              cudlik[3] = stred_cudliku[1] + 25;
              
                              
               
          if (touch_x > 34){    
              x0 = x_zadelavani_chyby + 8;
                spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Green);
              
              }else{
spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Black);
                  }
              
         if (touch_x < 34){    
              spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Black);
              
              }else{
                x0 = x_zadelavani_chyby + 8;
                spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Green);
                  }     
              spi.fillrect(cudlik[0],cudlik[1],cudlik[2],cudlik[3],cudlik[4]);
              
              
              
              }
            } 
            
            //slider */