Toto je má konečná verze maturitního projektu
Dependencies: mbed mbed-rtos UTouch_vyrobek UniGraphic
Diff: display.cpp
- Revision:
- 9:d1385f7171af
- Parent:
- 8:b6e7401fdcfc
- Child:
- 10:0176705be216
diff -r b6e7401fdcfc -r d1385f7171af display.cpp --- a/display.cpp Mon Dec 27 15:33:50 2021 +0000 +++ b/display.cpp Sat Jan 08 10:54:51 2022 +0000 @@ -1,13 +1,44 @@ #include "display.h" #include "rtos.h" -UTouch touch(D4,D9,D3,D2,D5);//clk,chip_select,MOSI,miso,irq(pripojeno je ale nevim co to dela) +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() { @@ -27,73 +58,75 @@ void grafika(unsigned short int press = 0){ - //int levy[] = {34,274,165,320,Blue}; - // int cudlik[] = {20,80,38,130,Red}; - //int spodni_levy[] = {200,240,240,320,Green}; - //int stredni_levy[] = {200,159,240,239,Red}; - int stredni_pravy[] = {200,78,240,158,Purple}; - int spodni_pravy[] = {200,0,240,77,Yellow}; + int spodni_pravy[] = {239,200,320,240,Black}; switch(press) { case 1: - //spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]);// pravy - - spi.Bitmap(34,0,38,46,(unsigned char*)gImage_vrch); - spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik);// pravy - spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek); - spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek); + 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.fillrect(levy[0],levy[1],levy[2],levy[3],levy[4]);// levy - spi.Bitmap(34,274,38,46,(unsigned char*)gImage_vrch); - spi.Bitmap(72,274,42,46,(unsigned char*)gImage_cudlik_otoc);// levy - spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek); - spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek); + 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(200,240,40,80,(unsigned char*)gImage_spodni_levy);// levy kraj spodni - - //spi.fillrect(spodni_levy[0],spodni_levy[1],spodni_levy[2],spodni_levy[3],spodni_levy[4]);// levy kraj spodni + spi.Bitmap(0,200,80,40,(unsigned char*)gImage_spodni_levy); break; case 4: - //spi.fillrect(stredni_levy[0],stredni_levy[1],stredni_levy[2],stredni_levy[3],stredni_levy[4]);// stred levy spodni - spi.Bitmap(200,160,40,80,(unsigned char*)gImage_stredni_levy); - + spi.Bitmap(80,200,80,40,(unsigned char*)gImage_stredni_levy); break; case 5: - spi.fillrect(stredni_pravy[0],stredni_pravy[1],stredni_pravy[2],stredni_pravy[3],stredni_pravy[4]);//stred pravy spodni + 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(0,46,200,228,(unsigned char*)gImage_pozadi); + spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); - spi.Bitmap(0,0,36,46,(unsigned char*)gImage_vypln); - spi.Bitmap(165,0,36,46,(unsigned char*)gImage_vypln); - spi.Bitmap(0,274,36,46,(unsigned char*)gImage_vypln); - spi.Bitmap(165,274,36,46,(unsigned char*)gImage_vypln); + 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(34,0,38,46,(unsigned char*)gImage_vrch); - spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik); // pravy - spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek); - spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek); //pravy + 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(34,274,38,46,(unsigned char*)gImage_vrch); - spi.Bitmap(72,274,42,46,(unsigned char*)gImage_cudlik_otoc);// levy - spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek); - spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek); - - spi.Bitmap(200,240,40,80,(unsigned char*)gImage_spodni_levy); - spi.Bitmap(200,160,40,80,(unsigned char*)gImage_stredni_levy); + 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.fillrect(stredni_pravy[0],stredni_pravy[1],stredni_pravy[2],stredni_pravy[3],stredni_pravy[4]); //stred pravy spodni + //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 } } @@ -131,13 +164,13 @@ void Button(int strana = 0){ int pravy[] = {34,0,165,46}; //pravý čudlík - int levy[] = {34,274,165,320,Black}; //levý č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,Red}; // levy spodni cudlik - int stredni_levy[] = {200,159,240,239,Green}; //stred levy spodni cudlik - int stredni_pravy[] = {200,78,240,158,Yellow}; //stred pravy spodni cudlik - int spodni_pravy[] = {200,0,240,77,Purple}; // pravy spodni cudlik + 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}; @@ -145,19 +178,7 @@ - switch(strana){ - case 0: - printf("default"); - break; - case 1: - spodni_levy[4] = Purple; - stredni_levy[4] = Red; - stredni_pravy[4] = Green; - spodni_pravy[4] = Yellow; - break; - default: - printf("default"); - } + while(1) { if (touch.DataAvailable()) @@ -186,16 +207,13 @@ default: m = 0; } - int i = touch.DataAvailable(); //GRAFIKA************************************************** - spi.Bitmap(34,0,38,46,(unsigned char*)gImage_vrch_s); - spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik_stred_s); - spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek_s); - spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek_s); + 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************************************************** - while (i){ - i = touch.DataAvailable(); - } + hold(); grafika(1); Menu(m); wait(0.2); @@ -214,16 +232,13 @@ m = 1; } //GRAFIKA************************************************** - spi.Bitmap(34,274,38,46,(unsigned char*)gImage_vrch_s); - spi.Bitmap(72,274,42,46,(unsigned char*)gImage_stred_otoc_s); - spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek_s); - spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek_s); + 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************************************************** - int i = touch.DataAvailable(); - while (i){ - i = touch.DataAvailable(); - } + hold(); grafika(2); wait(0.2); Menu(m); @@ -232,18 +247,14 @@ //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(200,240,40,80,(unsigned char*)gImage_spodni_levy_s); - - - - int i = touch.DataAvailable(); - //int e = 0; - while (i){ - i = touch.DataAvailable(); - //e++; - } - //printf("%d",e); - grafika(3); + 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 @@ -251,16 +262,14 @@ //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])){ - int i = touch.DataAvailable(); + - spi.Bitmap(200,160,40,80,(unsigned char*)gImage_stredni_levy_s); - + spi.Bitmap(80,200,80,40,(unsigned char*)gImage_stredni_levy_s); + thread.start(led2_thread); - while (i){ - i = touch.DataAvailable(); - } + hold(); grafika(4); wait(0.2); } @@ -269,14 +278,10 @@ //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(); - - int i = touch.DataAvailable(); - while (i){ - spi.fillrect(stredni_pravy[0],stredni_pravy[1],stredni_pravy[2],stredni_pravy[3],stredni_pravy[4]); - i = touch.DataAvailable(); - } + hold(); grafika(5); wait(0.2); } @@ -284,12 +289,13 @@ //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])){ - int i = touch.DataAvailable(); - while (i){ - spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]); - i = touch.DataAvailable(); - } - grafika(6); + + hold(); + + spi.locate(255,210); + spi.printf("%s",buffer); + + // grafika(6); wait(0.2); } //kraj pravy spodni cudlik @@ -297,14 +303,11 @@ //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(10,213,24,47,(unsigned char*)gImage_cudlik1s_vrch); - spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1s_spodek); - int i = touch.DataAvailable(); - while (i){ - i = touch.DataAvailable(); - } - spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1_vrch); - spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1_spodek); + 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(); } @@ -313,14 +316,11 @@ //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(10,213,24,47,(unsigned char*)gImage_cudlik1s_vrch); - spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1s_spodek); - int i = touch.DataAvailable(); - while (i){ - i = touch.DataAvailable(); - } - spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1_vrch); - spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1_spodek); + 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); } @@ -341,41 +341,42 @@ switch(strana) { case 1: - spi.Bitmap(0,46,200,228,(unsigned char*)gImage_pozadi); + spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); //CUDLIKY******************************************************************************* //prvni rada - spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1_vrch); - spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1_spodek); + spi.Bitmap(213,10,48,24,(unsigned char*)gImage_cudlik3_vrch); + spi.Bitmap(213,34,48,24,(unsigned char*)gImage_cudlik3_spodek); - spi.Bitmap(10,137,24,47,(unsigned char*)gImage_cudlik2_vrch); - spi.Bitmap(34,137,24,47,(unsigned char*)gImage_cudlik2_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(10,60,24,47,(unsigned char*)gImage_cudlik3_vrch); - spi.Bitmap(34,60,24,47,(unsigned char*)gImage_cudlik3_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(76,213,24,47,(unsigned char*)gImage_cudlik4_vrch); - spi.Bitmap(100,213,24,47,(unsigned char*)gImage_cudlik4_spodek); + spi.Bitmap(213,76,48,24,(unsigned char*)gImage_cudlik1_vrch); + spi.Bitmap(213,100,48,24,(unsigned char*)gImage_cudlik1_spodek); - spi.Bitmap(76,137,24,47,(unsigned char*)gImage_cudlik1_vrch); - spi.Bitmap(100,137,24,47,(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(76,60,24,47,(unsigned char*)gImage_cudlik1_vrch); - spi.Bitmap(100,60,24,47,(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(142,213,24,47,(unsigned char*)gImage_cudlik1_vrch); - spi.Bitmap(166,213,24,47,(unsigned char*)gImage_cudlik1_spodek); + spi.Bitmap(213,142,48,24,(unsigned char*)gImage_cudlik1_vrch); + spi.Bitmap(213,166,48,24,(unsigned char*)gImage_cudlik1_spodek); - spi.Bitmap(142,137,24,47,(unsigned char*)gImage_cudlik1_vrch); - spi.Bitmap(166,137,24,47,(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(142,60,24,47,(unsigned char*)gImage_cudlik1_vrch); - spi.Bitmap(166,60,24,47,(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******************************************************************************* @@ -385,25 +386,30 @@ break; default: - spi.Bitmap(0,46,200,228,(unsigned char*)gImage_pozadi); + 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(0,46,200,228,(unsigned char*)gImage_pozadi); - spi.fillrect(red[0],red[1],red[2],red[3],Red); - spi.fillrect(green[0],green[1],green[2],green[3],Green); - spi.fillrect(blue[0],blue[1],blue[2],blue[3],Blue); + 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; @@ -420,16 +426,14 @@ //pravý čudlik if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ - int i = touch.DataAvailable(); + //GRAFIKA************************************************** - spi.Bitmap(34,0,38,46,(unsigned char*)gImage_vrch_s); - spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik_stred_s); - spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek_s); - spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek_s); + 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************************************************** - while (i){ - i = touch.DataAvailable(); - } + hold(); my_red = r; my_green = g; my_blue = b; @@ -442,35 +446,35 @@ //levý čudlik if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ //GRAFIKA************************************************** - spi.Bitmap(34,274,38,46,(unsigned char*)gImage_vrch_s); - spi.Bitmap(72,274,42,46,(unsigned char*)gImage_stred_otoc_s); - spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek_s); - spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek_s); + 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************************************************** - int i = touch.DataAvailable(); - while (i){ - i = touch.DataAvailable(); - } + 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])){ +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])){ +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])){ +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); @@ -482,37 +486,253 @@ } +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(971208480); - spi.set_font((unsigned char*)Arial19x19); + set_time(cas_nastavit); while(1){ time_t seconds = time(NULL); - seconds = seconds + 7200; - char buffer[32]; + //seconds = seconds + 7200; strftime(buffer, 32, "%R", localtime(&seconds)); - spi.set_orientation(3); - spi.locate(255,210); - spi.printf("%s",buffer); - spi.set_orientation(0); - wait_ms(1000); + 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(); - //spi.circle(240,320,20,Black); - //wait_us(); + 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();