Toto je má konečná verze maturitního projektu
Dependencies: mbed mbed-rtos UTouch_vyrobek UniGraphic
display.cpp@11:4ca8388080c6, 2022-02-01 (annotated)
- Committer:
- smejky
- Date:
- Tue Feb 01 13:37:40 2022 +0000
- Revision:
- 11:4ca8388080c6
- Parent:
- 10:0176705be216
- Child:
- 12:9bc02f9e16e3
Pridani led pasku k projetku, fungujici efekty: Staticky
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
smejky | 7:91b982ccf255 | 1 | #include "display.h" |
smejky | 11:4ca8388080c6 | 2 | |
smejky | 8:b6e7401fdcfc | 3 | |
smejky | 11:4ca8388080c6 | 4 | UTouch touch(D5,D4,D3,D2,D1);//clk,chip_select,MOSI,miso,irq |
smejky | 11:4ca8388080c6 | 5 | ILI9341 spi(SPI_8,320000000,PTD2,PTD3,PTD1,PTE24, PTE25, PTC4, "TFT",240,320);// mosi, miso, sclk, chip_select, reset, dc |
smejky | 8:b6e7401fdcfc | 6 | DigitalOut my_green(LED2); |
smejky | 8:b6e7401fdcfc | 7 | DigitalOut my_red(LED4); |
smejky | 8:b6e7401fdcfc | 8 | DigitalOut my_blue(LED3); |
smejky | 7:91b982ccf255 | 9 | DigitalOut led2(LED2); |
smejky | 7:91b982ccf255 | 10 | Thread thread; |
smejky | 11:4ca8388080c6 | 11 | Thread thread_h; |
smejky | 10:0176705be216 | 12 | PwmOut br(D10); |
smejky | 9:d1385f7171af | 13 | |
smejky | 11:4ca8388080c6 | 14 | |
smejky | 11:4ca8388080c6 | 15 | |
smejky | 11:4ca8388080c6 | 16 | PwmOut r(PTC10); |
smejky | 11:4ca8388080c6 | 17 | PwmOut g(PTC3); |
smejky | 11:4ca8388080c6 | 18 | PwmOut b(PTC2); |
smejky | 11:4ca8388080c6 | 19 | |
smejky | 11:4ca8388080c6 | 20 | float led_jas = 80; |
smejky | 10:0176705be216 | 21 | float lcd_jas = 0.50f; |
smejky | 11:4ca8388080c6 | 22 | int jas[] = {Cyan,White}; |
smejky | 10:0176705be216 | 23 | int jas_s = 2; |
smejky | 10:0176705be216 | 24 | int jazyk_s = 0; |
smejky | 10:0176705be216 | 25 | int cas_hodiny = 0; |
smejky | 10:0176705be216 | 26 | int cas_minuty = 0; |
smejky | 11:4ca8388080c6 | 27 | int cas_hodiny_on = 0; |
smejky | 11:4ca8388080c6 | 28 | int cas_minuty_on = 0; |
smejky | 11:4ca8388080c6 | 29 | int cas_hodiny_off = 0; |
smejky | 11:4ca8388080c6 | 30 | int cas_minuty_off = 0; |
smejky | 9:d1385f7171af | 31 | int cas_nastavit = 1037059200; |
smejky | 11:4ca8388080c6 | 32 | int time_on = 1037059200; |
smejky | 11:4ca8388080c6 | 33 | int time_off = 1037059200; |
smejky | 9:d1385f7171af | 34 | int lang = 0; |
smejky | 10:0176705be216 | 35 | char minutka[32]; |
smejky | 10:0176705be216 | 36 | char hodinka[32]; |
smejky | 9:d1385f7171af | 37 | char buffer[32]; |
smejky | 10:0176705be216 | 38 | char jazyk [4][150] = { |
smejky | 9:d1385f7171af | 39 | "Czech", |
smejky | 9:d1385f7171af | 40 | "English", |
smejky | 10:0176705be216 | 41 | " Set Time", |
smejky | 10:0176705be216 | 42 | "Brightness" |
smejky | 9:d1385f7171af | 43 | }; |
smejky | 10:0176705be216 | 44 | char en[4][150] = { |
smejky | 9:d1385f7171af | 45 | "Czech", |
smejky | 9:d1385f7171af | 46 | "English", |
smejky | 10:0176705be216 | 47 | " Set Time", |
smejky | 10:0176705be216 | 48 | "Brightness" |
smejky | 9:d1385f7171af | 49 | }; |
smejky | 10:0176705be216 | 50 | char cz[4][150] = { |
smejky | 9:d1385f7171af | 51 | "Cestina", |
smejky | 9:d1385f7171af | 52 | "Anglictina", |
smejky | 10:0176705be216 | 53 | "Nastavit cas", |
smejky | 10:0176705be216 | 54 | " Jas" |
smejky | 9:d1385f7171af | 55 | }; |
smejky | 9:d1385f7171af | 56 | |
smejky | 9:d1385f7171af | 57 | |
smejky | 9:d1385f7171af | 58 | |
smejky | 9:d1385f7171af | 59 | void hold(){ |
smejky | 9:d1385f7171af | 60 | int i = touch.DataAvailable(); |
smejky | 9:d1385f7171af | 61 | while (i){ |
smejky | 9:d1385f7171af | 62 | i = touch.DataAvailable(); |
smejky | 9:d1385f7171af | 63 | } |
smejky | 9:d1385f7171af | 64 | |
smejky | 9:d1385f7171af | 65 | } |
smejky | 11:4ca8388080c6 | 66 | |
smejky | 11:4ca8388080c6 | 67 | void send_color(float color_r = 255,float color_g = 255, float color_b = 255, float brightness = 0){ |
smejky | 11:4ca8388080c6 | 68 | |
smejky | 11:4ca8388080c6 | 69 | brightness = 100 - brightness; |
smejky | 11:4ca8388080c6 | 70 | |
smejky | 11:4ca8388080c6 | 71 | 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 |
smejky | 11:4ca8388080c6 | 72 | 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 |
smejky | 11:4ca8388080c6 | 73 | color_b = color_b * 0.00387855; |
smejky | 11:4ca8388080c6 | 74 | |
smejky | 11:4ca8388080c6 | 75 | 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 |
smejky | 11:4ca8388080c6 | 76 | 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 |
smejky | 11:4ca8388080c6 | 77 | color_b = color_b - ((color_b*0.01)*brightness); |
smejky | 11:4ca8388080c6 | 78 | write_color(color_r,color_g,color_b); |
smejky | 11:4ca8388080c6 | 79 | } |
smejky | 3:dadb214885c1 | 80 | |
smejky | 11:4ca8388080c6 | 81 | void write_color(float red,float green, float blue){ |
smejky | 11:4ca8388080c6 | 82 | r.write(red); |
smejky | 11:4ca8388080c6 | 83 | g.write(green); |
smejky | 11:4ca8388080c6 | 84 | b.write(blue); |
smejky | 7:91b982ccf255 | 85 | } |
smejky | 0:6abf63b83992 | 86 | |
smejky | 0:6abf63b83992 | 87 | /* |
smejky | 0:6abf63b83992 | 88 | v ILI9341.cpp zmeneny framerate ze 70 na 100, toto pomohlo problemu blikání displeje |
smejky | 3:dadb214885c1 | 89 | velikost fotky pro čudlik 180x70 |
smejky | 3:dadb214885c1 | 90 | 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 |
smejky | 0:6abf63b83992 | 91 | |
smejky | 10:0176705be216 | 92 | 4x doprava jas pro cudliky v menu |
smejky | 10:0176705be216 | 93 | |
smejky | 11:4ca8388080c6 | 94 | predelat na konci jmena cudliku |
smejky | 0:6abf63b83992 | 95 | */ |
smejky | 0:6abf63b83992 | 96 | |
smejky | 7:91b982ccf255 | 97 | |
smejky | 11:4ca8388080c6 | 98 | void grafika(unsigned short int press = 0){ |
smejky | 2:0629f1ddaa92 | 99 | switch(press) |
smejky | 2:0629f1ddaa92 | 100 | { |
smejky | 2:0629f1ddaa92 | 101 | case 1: |
smejky | 9:d1385f7171af | 102 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 9:d1385f7171af | 103 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_cudlik_otoc); // pravy |
smejky | 9:d1385f7171af | 104 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 105 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek); //pravy |
smejky | 7:91b982ccf255 | 106 | |
smejky | 2:0629f1ddaa92 | 107 | break; |
smejky | 4:c7ca936cdd1f | 108 | case 2: |
smejky | 9:d1385f7171af | 109 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 9:d1385f7171af | 110 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_cudlik);// levy |
smejky | 9:d1385f7171af | 111 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 112 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 113 | break; |
smejky | 9:d1385f7171af | 114 | case 7: //zrusit |
smejky | 9:d1385f7171af | 115 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 10:0176705be216 | 116 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit); |
smejky | 9:d1385f7171af | 117 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 118 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 119 | break; |
smejky | 9:d1385f7171af | 120 | case 9: //potvrdit |
smejky | 9:d1385f7171af | 121 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 10:0176705be216 | 122 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit); |
smejky | 9:d1385f7171af | 123 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 10:0176705be216 | 124 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek); |
smejky | 4:c7ca936cdd1f | 125 | break; |
smejky | 4:c7ca936cdd1f | 126 | case 3: |
smejky | 11:4ca8388080c6 | 127 | spi.fillrect(0,200,106,240,Black); |
smejky | 11:4ca8388080c6 | 128 | spi.Bitmap(13,200,80,40,(unsigned char*)gImage_spodni_levy); |
smejky | 2:0629f1ddaa92 | 129 | break; |
smejky | 4:c7ca936cdd1f | 130 | case 4: |
smejky | 11:4ca8388080c6 | 131 | spi.fillrect(107,200,213,240,Black); |
smejky | 11:4ca8388080c6 | 132 | spi.Bitmap(120,200,80,40,(unsigned char*)gImage_stredni_levy);//prostredni |
smejky | 4:c7ca936cdd1f | 133 | break; |
smejky | 4:c7ca936cdd1f | 134 | case 5: |
smejky | 11:4ca8388080c6 | 135 | spi.fillrect(214,200,320,240,Black); |
smejky | 11:4ca8388080c6 | 136 | spi.Bitmap(227,200,80,40,(unsigned char*)gImage_stredni_pravy);//pravy spodni |
smejky | 11:4ca8388080c6 | 137 | break; |
smejky | 4:c7ca936cdd1f | 138 | |
smejky | 4:c7ca936cdd1f | 139 | default: |
smejky | 9:d1385f7171af | 140 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 7:91b982ccf255 | 141 | |
smejky | 9:d1385f7171af | 142 | spi.Bitmap(274,0,46,36,(unsigned char*)gImage_vypln);//pravy |
smejky | 9:d1385f7171af | 143 | spi.Bitmap(274,165,46,36,(unsigned char*)gImage_vypln);//pravy |
smejky | 9:d1385f7171af | 144 | spi.Bitmap(0,0,46,36,(unsigned char*)gImage_vypln);//levy |
smejky | 9:d1385f7171af | 145 | spi.Bitmap(0,165,46,36,(unsigned char*)gImage_vypln);//levy |
smejky | 7:91b982ccf255 | 146 | |
smejky | 9:d1385f7171af | 147 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 9:d1385f7171af | 148 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_cudlik_otoc); // pravy |
smejky | 9:d1385f7171af | 149 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 150 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek); //pravy |
smejky | 7:91b982ccf255 | 151 | |
smejky | 9:d1385f7171af | 152 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 9:d1385f7171af | 153 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_cudlik);// levy |
smejky | 9:d1385f7171af | 154 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 155 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 156 | |
smejky | 11:4ca8388080c6 | 157 | spi.fillrect(0,200,106,240,Black); |
smejky | 11:4ca8388080c6 | 158 | spi.Bitmap(13,200,80,40,(unsigned char*)gImage_spodni_levy); |
smejky | 11:4ca8388080c6 | 159 | |
smejky | 11:4ca8388080c6 | 160 | spi.fillrect(107,200,213,240,Black); |
smejky | 11:4ca8388080c6 | 161 | spi.Bitmap(120,200,80,40,(unsigned char*)gImage_stredni_levy);//prostredni |
smejky | 11:4ca8388080c6 | 162 | |
smejky | 11:4ca8388080c6 | 163 | spi.fillrect(214,200,320,240,Black); |
smejky | 11:4ca8388080c6 | 164 | spi.Bitmap(227,200,80,40,(unsigned char*)gImage_stredni_pravy);//pravy spodni |
smejky | 11:4ca8388080c6 | 165 | |
smejky | 2:0629f1ddaa92 | 166 | } |
smejky | 2:0629f1ddaa92 | 167 | } |
smejky | 2:0629f1ddaa92 | 168 | |
smejky | 2:0629f1ddaa92 | 169 | void malovani(){ |
smejky | 2:0629f1ddaa92 | 170 | |
smejky | 1:4dd546219e30 | 171 | while(1==1) |
smejky | 1:4dd546219e30 | 172 | { |
smejky | 0:6abf63b83992 | 173 | if (touch.DataAvailable()) |
smejky | 0:6abf63b83992 | 174 | { |
smejky | 0:6abf63b83992 | 175 | if(touch.Read()) |
smejky | 0:6abf63b83992 | 176 | { |
smejky | 0:6abf63b83992 | 177 | unsigned short int touch_y = touch.GetX(); |
smejky | 1:4dd546219e30 | 178 | unsigned short int touch_x = touch.GetY(); |
smejky | 0:6abf63b83992 | 179 | touch_x = touch_x - 10; |
smejky | 2:0629f1ddaa92 | 180 | touch_y = touch_y + 10; |
smejky | 2:0629f1ddaa92 | 181 | spi.pixel(touch_x,touch_y,Blue); |
smejky | 2:0629f1ddaa92 | 182 | } |
smejky | 2:0629f1ddaa92 | 183 | } |
smejky | 2:0629f1ddaa92 | 184 | } |
smejky | 2:0629f1ddaa92 | 185 | } |
smejky | 2:0629f1ddaa92 | 186 | |
smejky | 5:7c757a7c97c5 | 187 | /* |
smejky | 5:7c757a7c97c5 | 188 | else if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy [1])){ |
smejky | 5:7c757a7c97c5 | 189 | R_is_pressed = 1; |
smejky | 5:7c757a7c97c5 | 190 | spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]); |
smejky | 5:7c757a7c97c5 | 191 | wait(0.1); |
smejky | 5:7c757a7c97c5 | 192 | } |
smejky | 5:7c757a7c97c5 | 193 | |
smejky | 5:7c757a7c97c5 | 194 | */ |
smejky | 5:7c757a7c97c5 | 195 | |
smejky | 5:7c757a7c97c5 | 196 | |
smejky | 5:7c757a7c97c5 | 197 | |
smejky | 7:91b982ccf255 | 198 | |
smejky | 7:91b982ccf255 | 199 | |
smejky | 7:91b982ccf255 | 200 | void Button(int strana = 0){ |
smejky | 7:91b982ccf255 | 201 | int pravy[] = {34,0,165,46}; //pravý čudlík |
smejky | 9:d1385f7171af | 202 | int levy[] = {34,274,165,320}; //levý čudlík |
smejky | 4:c7ca936cdd1f | 203 | //int cudlik[] = {20,80,42,130,Orange}; //slider nepovedeny projekt |
smejky | 4:c7ca936cdd1f | 204 | //int stred_cudliku[] = {30,105,Blue}; //střed čudliku |
smejky | 11:4ca8388080c6 | 205 | int spodni_levy[] = {200,214,240,320}; // pravy spodni cudlik |
smejky | 11:4ca8388080c6 | 206 | int stredni_levy[] = {200,107,240,213}; //stred spodni cudlik |
smejky | 11:4ca8388080c6 | 207 | int stredni_pravy[] = {200,0,240,106}; //stred levy spodni cudlik |
smejky | 7:91b982ccf255 | 208 | |
smejky | 7:91b982ccf255 | 209 | int cudlik_1[] = {10,213,58,260}; |
smejky | 8:b6e7401fdcfc | 210 | int cudlik_2[] = {10,137,58,184}; |
smejky | 8:b6e7401fdcfc | 211 | |
smejky | 8:b6e7401fdcfc | 212 | |
smejky | 7:91b982ccf255 | 213 | |
smejky | 7:91b982ccf255 | 214 | |
smejky | 9:d1385f7171af | 215 | |
smejky | 3:dadb214885c1 | 216 | while(1) |
smejky | 2:0629f1ddaa92 | 217 | { |
smejky | 2:0629f1ddaa92 | 218 | if (touch.DataAvailable()) |
smejky | 2:0629f1ddaa92 | 219 | { |
smejky | 2:0629f1ddaa92 | 220 | if(touch.Read()) |
smejky | 2:0629f1ddaa92 | 221 | { |
smejky | 5:7c757a7c97c5 | 222 | |
smejky | 5:7c757a7c97c5 | 223 | |
smejky | 3:dadb214885c1 | 224 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 3:dadb214885c1 | 225 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 3:dadb214885c1 | 226 | touch_x = touch_x - 5; |
smejky | 2:0629f1ddaa92 | 227 | touch_y = touch_y + 10; |
smejky | 3:dadb214885c1 | 228 | //spi.pixel(touch_x,touch_y,Blue); |
smejky | 5:7c757a7c97c5 | 229 | //printf("x %d ,y %d\r\n",touch_x,touch_y); |
smejky | 3:dadb214885c1 | 230 | |
smejky | 3:dadb214885c1 | 231 | //pravý čudlik |
smejky | 5:7c757a7c97c5 | 232 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 7:91b982ccf255 | 233 | int m = strana; |
smejky | 7:91b982ccf255 | 234 | switch(strana){ |
smejky | 7:91b982ccf255 | 235 | case 0: |
smejky | 7:91b982ccf255 | 236 | m++; |
smejky | 7:91b982ccf255 | 237 | break; |
smejky | 7:91b982ccf255 | 238 | case 1: |
smejky | 7:91b982ccf255 | 239 | m++; |
smejky | 7:91b982ccf255 | 240 | break; |
smejky | 7:91b982ccf255 | 241 | default: |
smejky | 7:91b982ccf255 | 242 | m = 0; |
smejky | 7:91b982ccf255 | 243 | } |
smejky | 7:91b982ccf255 | 244 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 245 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 246 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_cudlik_otoc_s); |
smejky | 9:d1385f7171af | 247 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 248 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 7:91b982ccf255 | 249 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 250 | hold(); |
smejky | 5:7c757a7c97c5 | 251 | grafika(1); |
smejky | 7:91b982ccf255 | 252 | Menu(m); |
smejky | 5:7c757a7c97c5 | 253 | } |
smejky | 5:7c757a7c97c5 | 254 | |
smejky | 3:dadb214885c1 | 255 | //pravý čudlik |
smejky | 3:dadb214885c1 | 256 | |
smejky | 4:c7ca936cdd1f | 257 | //levý čudlik |
smejky | 5:7c757a7c97c5 | 258 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 7:91b982ccf255 | 259 | int m = strana; |
smejky | 7:91b982ccf255 | 260 | switch(strana){ |
smejky | 7:91b982ccf255 | 261 | case 1: |
smejky | 7:91b982ccf255 | 262 | m--; |
smejky | 7:91b982ccf255 | 263 | break; |
smejky | 7:91b982ccf255 | 264 | default: |
smejky | 8:b6e7401fdcfc | 265 | m = 1; |
smejky | 7:91b982ccf255 | 266 | } |
smejky | 7:91b982ccf255 | 267 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 268 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 269 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_cudlik_s);// levy |
smejky | 9:d1385f7171af | 270 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 271 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 7:91b982ccf255 | 272 | //GRAFIKA************************************************** |
smejky | 7:91b982ccf255 | 273 | |
smejky | 9:d1385f7171af | 274 | hold(); |
smejky | 5:7c757a7c97c5 | 275 | grafika(2); |
smejky | 11:4ca8388080c6 | 276 | |
smejky | 7:91b982ccf255 | 277 | Menu(m); |
smejky | 5:7c757a7c97c5 | 278 | } |
smejky | 3:dadb214885c1 | 279 | //levý čudlik |
smejky | 4:c7ca936cdd1f | 280 | |
smejky | 4:c7ca936cdd1f | 281 | //levý spodni čudlik |
smejky | 5:7c757a7c97c5 | 282 | if ((touch_x > spodni_levy[0]) && (touch_x < spodni_levy[2]) && (touch_y < spodni_levy[3]) && (touch_y > spodni_levy[1])){ |
smejky | 11:4ca8388080c6 | 283 | spi.fillrect(0,200,106,240,Select); |
smejky | 11:4ca8388080c6 | 284 | spi.Bitmap(13,200,80,40,(unsigned char*)gImage_spodni_levy_s); |
smejky | 9:d1385f7171af | 285 | |
smejky | 9:d1385f7171af | 286 | hold(); |
smejky | 9:d1385f7171af | 287 | |
smejky | 9:d1385f7171af | 288 | grafika(9); |
smejky | 11:4ca8388080c6 | 289 | grafika(3); |
smejky | 9:d1385f7171af | 290 | grafika(7); |
smejky | 9:d1385f7171af | 291 | nastaveni(); |
smejky | 11:4ca8388080c6 | 292 | |
smejky | 5:7c757a7c97c5 | 293 | } |
smejky | 4:c7ca936cdd1f | 294 | //levý spodni čudlik |
smejky | 3:dadb214885c1 | 295 | |
smejky | 4:c7ca936cdd1f | 296 | |
smejky | 4:c7ca936cdd1f | 297 | //stred levy spodni cudlik |
smejky | 5:7c757a7c97c5 | 298 | if ((touch_x > stredni_levy[0]) && (touch_x < stredni_levy[2]) && (touch_y < stredni_levy[3]) && (touch_y > stredni_levy[1])){ |
smejky | 9:d1385f7171af | 299 | |
smejky | 11:4ca8388080c6 | 300 | spi.fillrect(107,200,213,240,Select); |
smejky | 11:4ca8388080c6 | 301 | spi.Bitmap(120,200,80,40,(unsigned char*)gImage_stredni_levy_s); |
smejky | 9:d1385f7171af | 302 | |
smejky | 7:91b982ccf255 | 303 | |
smejky | 11:4ca8388080c6 | 304 | on_off(); |
smejky | 7:91b982ccf255 | 305 | |
smejky | 9:d1385f7171af | 306 | hold(); |
smejky | 5:7c757a7c97c5 | 307 | grafika(4); |
smejky | 11:4ca8388080c6 | 308 | |
smejky | 5:7c757a7c97c5 | 309 | } |
smejky | 4:c7ca936cdd1f | 310 | //stred levy spodni cudlik |
smejky | 4:c7ca936cdd1f | 311 | |
smejky | 4:c7ca936cdd1f | 312 | |
smejky | 4:c7ca936cdd1f | 313 | //stred pravy spodni cudlik |
smejky | 5:7c757a7c97c5 | 314 | if ((touch_x > stredni_pravy[0]) && (touch_x < stredni_pravy[2]) && (touch_y < stredni_pravy[3]) && (touch_y > stredni_pravy[1])){ |
smejky | 11:4ca8388080c6 | 315 | spi.fillrect(214,200,320,240,Select); |
smejky | 11:4ca8388080c6 | 316 | spi.Bitmap(227,200,80,40,(unsigned char*)gImage_stredni_pravy_s); |
smejky | 11:4ca8388080c6 | 317 | hold(); |
smejky | 5:7c757a7c97c5 | 318 | grafika(5); |
smejky | 11:4ca8388080c6 | 319 | color_picker(); |
smejky | 11:4ca8388080c6 | 320 | |
smejky | 5:7c757a7c97c5 | 321 | } |
smejky | 4:c7ca936cdd1f | 322 | //stred pravy spodni cudlik |
smejky | 7:91b982ccf255 | 323 | |
smejky | 7:91b982ccf255 | 324 | //MENU CUDLIKY********************************************************************************************************************************************************************************** |
smejky | 7:91b982ccf255 | 325 | //prvni |
smejky | 8:b6e7401fdcfc | 326 | if ((touch_x > cudlik_1[0]) && (touch_x < cudlik_1[2]) && (touch_y < cudlik_1[3]) && (touch_y > cudlik_1[1]) && (strana == 1)){ |
smejky | 9:d1385f7171af | 327 | spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1s_vrch); |
smejky | 9:d1385f7171af | 328 | spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1s_spodek); |
smejky | 9:d1385f7171af | 329 | hold(); |
smejky | 9:d1385f7171af | 330 | spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 331 | spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 10:0176705be216 | 332 | wait(0.2); |
smejky | 10:0176705be216 | 333 | grafika(7); |
smejky | 10:0176705be216 | 334 | grafika(9); |
smejky | 8:b6e7401fdcfc | 335 | Static(); |
smejky | 7:91b982ccf255 | 336 | } |
smejky | 7:91b982ccf255 | 337 | |
smejky | 7:91b982ccf255 | 338 | |
smejky | 7:91b982ccf255 | 339 | //prvni |
smejky | 8:b6e7401fdcfc | 340 | //druhy |
smejky | 8:b6e7401fdcfc | 341 | if ((touch_x > cudlik_2[0]) && (touch_x < cudlik_2[2]) && (touch_y < cudlik_2[3]) && (touch_y > cudlik_2[1]) && (strana == 1)){ |
smejky | 9:d1385f7171af | 342 | spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1s_vrch); |
smejky | 9:d1385f7171af | 343 | spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1s_spodek); |
smejky | 9:d1385f7171af | 344 | hold(); |
smejky | 9:d1385f7171af | 345 | spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 346 | spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 8:b6e7401fdcfc | 347 | wait(0.2); |
smejky | 8:b6e7401fdcfc | 348 | |
smejky | 8:b6e7401fdcfc | 349 | } |
smejky | 8:b6e7401fdcfc | 350 | |
smejky | 8:b6e7401fdcfc | 351 | |
smejky | 8:b6e7401fdcfc | 352 | //druhy |
smejky | 3:dadb214885c1 | 353 | |
smejky | 1:4dd546219e30 | 354 | } |
smejky | 1:4dd546219e30 | 355 | } |
smejky | 1:4dd546219e30 | 356 | } |
smejky | 1:4dd546219e30 | 357 | } |
smejky | 0:6abf63b83992 | 358 | |
smejky | 0:6abf63b83992 | 359 | |
smejky | 0:6abf63b83992 | 360 | |
smejky | 2:0629f1ddaa92 | 361 | |
smejky | 7:91b982ccf255 | 362 | |
smejky | 8:b6e7401fdcfc | 363 | void Menu(int strana = 0){ |
smejky | 7:91b982ccf255 | 364 | switch(strana) |
smejky | 7:91b982ccf255 | 365 | { |
smejky | 7:91b982ccf255 | 366 | case 1: |
smejky | 9:d1385f7171af | 367 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 7:91b982ccf255 | 368 | |
smejky | 7:91b982ccf255 | 369 | |
smejky | 7:91b982ccf255 | 370 | //CUDLIKY******************************************************************************* |
smejky | 7:91b982ccf255 | 371 | //prvni rada |
smejky | 9:d1385f7171af | 372 | spi.Bitmap(213,10,48,24,(unsigned char*)gImage_cudlik3_vrch); |
smejky | 9:d1385f7171af | 373 | spi.Bitmap(213,34,48,24,(unsigned char*)gImage_cudlik3_spodek); |
smejky | 7:91b982ccf255 | 374 | |
smejky | 9:d1385f7171af | 375 | spi.Bitmap(137,10,48,24,(unsigned char*)gImage_cudlik2_vrch); |
smejky | 9:d1385f7171af | 376 | spi.Bitmap(137,34,48,24,(unsigned char*)gImage_cudlik2_spodek); |
smejky | 8:b6e7401fdcfc | 377 | |
smejky | 9:d1385f7171af | 378 | spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 379 | spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 9:d1385f7171af | 380 | |
smejky | 7:91b982ccf255 | 381 | //prvni rada |
smejky | 7:91b982ccf255 | 382 | |
smejky | 7:91b982ccf255 | 383 | //druha rada |
smejky | 9:d1385f7171af | 384 | spi.Bitmap(213,76,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 385 | spi.Bitmap(213,100,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 7:91b982ccf255 | 386 | |
smejky | 9:d1385f7171af | 387 | spi.Bitmap(137,76,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 388 | spi.Bitmap(137,100,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 7:91b982ccf255 | 389 | |
smejky | 9:d1385f7171af | 390 | spi.Bitmap(60,76,48,24,(unsigned char*)gImage_cudlik4_vrch); |
smejky | 9:d1385f7171af | 391 | spi.Bitmap(60,100,48,24,(unsigned char*)gImage_cudlik4_spodek); |
smejky | 7:91b982ccf255 | 392 | // druha rada |
smejky | 7:91b982ccf255 | 393 | |
smejky | 7:91b982ccf255 | 394 | //treti rada |
smejky | 9:d1385f7171af | 395 | spi.Bitmap(213,142,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 396 | spi.Bitmap(213,166,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 7:91b982ccf255 | 397 | |
smejky | 9:d1385f7171af | 398 | spi.Bitmap(137,142,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 399 | spi.Bitmap(137,166,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 7:91b982ccf255 | 400 | |
smejky | 9:d1385f7171af | 401 | spi.Bitmap(60,142,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 402 | spi.Bitmap(60,166,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 7:91b982ccf255 | 403 | // treti rada |
smejky | 7:91b982ccf255 | 404 | |
smejky | 7:91b982ccf255 | 405 | //CUDLIKY******************************************************************************* |
smejky | 8:b6e7401fdcfc | 406 | |
smejky | 8:b6e7401fdcfc | 407 | strana = 1; |
smejky | 8:b6e7401fdcfc | 408 | Button(strana); |
smejky | 8:b6e7401fdcfc | 409 | |
smejky | 8:b6e7401fdcfc | 410 | break; |
smejky | 7:91b982ccf255 | 411 | default: |
smejky | 9:d1385f7171af | 412 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 7:91b982ccf255 | 413 | strana = 0; |
smejky | 7:91b982ccf255 | 414 | Button(strana); |
smejky | 7:91b982ccf255 | 415 | } |
smejky | 7:91b982ccf255 | 416 | } |
smejky | 7:91b982ccf255 | 417 | |
smejky | 8:b6e7401fdcfc | 418 | void Static(){ |
smejky | 11:4ca8388080c6 | 419 | |
smejky | 11:4ca8388080c6 | 420 | int green1[] = {109,40,212,143}; |
smejky | 11:4ca8388080c6 | 421 | int green[] = {40,109,143,212}; |
smejky | 9:d1385f7171af | 422 | |
smejky | 11:4ca8388080c6 | 423 | int stredni_pravy[] = {200,0,240,106}; //stred levy spodni cudlik |
smejky | 8:b6e7401fdcfc | 424 | int pravy[] = {34,0,165,46}; //pravý čudlík |
smejky | 8:b6e7401fdcfc | 425 | int levy[] = {34,274,165,320}; //levý čudlík |
smejky | 8:b6e7401fdcfc | 426 | |
smejky | 9:d1385f7171af | 427 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 11:4ca8388080c6 | 428 | |
smejky | 11:4ca8388080c6 | 429 | spi.fillrect(green1[0],green1[1],green1[2],green1[3],White); |
smejky | 11:4ca8388080c6 | 430 | |
smejky | 11:4ca8388080c6 | 431 | int color_pick = White; |
smejky | 8:b6e7401fdcfc | 432 | |
smejky | 8:b6e7401fdcfc | 433 | while(1) |
smejky | 8:b6e7401fdcfc | 434 | { |
smejky | 8:b6e7401fdcfc | 435 | if (touch.DataAvailable()) |
smejky | 8:b6e7401fdcfc | 436 | { |
smejky | 8:b6e7401fdcfc | 437 | if(touch.Read()) |
smejky | 8:b6e7401fdcfc | 438 | { |
smejky | 8:b6e7401fdcfc | 439 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 8:b6e7401fdcfc | 440 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 8:b6e7401fdcfc | 441 | |
smejky | 8:b6e7401fdcfc | 442 | //pravý čudlik |
smejky | 8:b6e7401fdcfc | 443 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 9:d1385f7171af | 444 | |
smejky | 8:b6e7401fdcfc | 445 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 446 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 10:0176705be216 | 447 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit_s); |
smejky | 9:d1385f7171af | 448 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 449 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 8:b6e7401fdcfc | 450 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 451 | hold(); |
smejky | 11:4ca8388080c6 | 452 | thread.terminate(); |
smejky | 11:4ca8388080c6 | 453 | switch (color_pick){ |
smejky | 11:4ca8388080c6 | 454 | case Red: |
smejky | 11:4ca8388080c6 | 455 | send_color(255,0,0,led_jas); |
smejky | 11:4ca8388080c6 | 456 | break; |
smejky | 11:4ca8388080c6 | 457 | case Orange: |
smejky | 11:4ca8388080c6 | 458 | send_color(255,128,0,led_jas); |
smejky | 11:4ca8388080c6 | 459 | break; |
smejky | 11:4ca8388080c6 | 460 | case Yellow: |
smejky | 11:4ca8388080c6 | 461 | send_color(255,255,0,led_jas); |
smejky | 11:4ca8388080c6 | 462 | break; |
smejky | 11:4ca8388080c6 | 463 | case GreenYellow: |
smejky | 11:4ca8388080c6 | 464 | send_color(127,255,0,led_jas); |
smejky | 11:4ca8388080c6 | 465 | break; |
smejky | 11:4ca8388080c6 | 466 | case Green: |
smejky | 11:4ca8388080c6 | 467 | send_color(0,255,0,led_jas); |
smejky | 11:4ca8388080c6 | 468 | break; |
smejky | 11:4ca8388080c6 | 469 | case White: |
smejky | 11:4ca8388080c6 | 470 | send_color(255,255,255,led_jas); |
smejky | 11:4ca8388080c6 | 471 | break; |
smejky | 11:4ca8388080c6 | 472 | case Cyan: |
smejky | 11:4ca8388080c6 | 473 | send_color(0,255,255,led_jas); |
smejky | 11:4ca8388080c6 | 474 | break; |
smejky | 11:4ca8388080c6 | 475 | case DarkCyan: |
smejky | 11:4ca8388080c6 | 476 | send_color(0,127,255,led_jas); |
smejky | 11:4ca8388080c6 | 477 | break; |
smejky | 11:4ca8388080c6 | 478 | case Blue: |
smejky | 11:4ca8388080c6 | 479 | send_color(0,0,255,led_jas); |
smejky | 11:4ca8388080c6 | 480 | break; |
smejky | 11:4ca8388080c6 | 481 | case Purple: |
smejky | 11:4ca8388080c6 | 482 | send_color(127,0,255,led_jas); |
smejky | 11:4ca8388080c6 | 483 | break; |
smejky | 11:4ca8388080c6 | 484 | case Magenta: |
smejky | 11:4ca8388080c6 | 485 | send_color(255,0,255,led_jas); |
smejky | 11:4ca8388080c6 | 486 | break; |
smejky | 11:4ca8388080c6 | 487 | case Pink: |
smejky | 11:4ca8388080c6 | 488 | send_color(255,0,127,led_jas); |
smejky | 11:4ca8388080c6 | 489 | break; |
smejky | 11:4ca8388080c6 | 490 | default: |
smejky | 11:4ca8388080c6 | 491 | send_color(255,255,255,led_jas); |
smejky | 11:4ca8388080c6 | 492 | } |
smejky | 11:4ca8388080c6 | 493 | |
smejky | 8:b6e7401fdcfc | 494 | grafika(1); |
smejky | 10:0176705be216 | 495 | grafika(2); |
smejky | 8:b6e7401fdcfc | 496 | Menu(); |
smejky | 8:b6e7401fdcfc | 497 | } |
smejky | 8:b6e7401fdcfc | 498 | //pravý čudlik |
smejky | 8:b6e7401fdcfc | 499 | |
smejky | 8:b6e7401fdcfc | 500 | //levý čudlik |
smejky | 8:b6e7401fdcfc | 501 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 8:b6e7401fdcfc | 502 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 503 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 10:0176705be216 | 504 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit_s);// levy |
smejky | 9:d1385f7171af | 505 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 506 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 8:b6e7401fdcfc | 507 | //GRAFIKA************************************************** |
smejky | 8:b6e7401fdcfc | 508 | |
smejky | 9:d1385f7171af | 509 | hold(); |
smejky | 8:b6e7401fdcfc | 510 | grafika(2); |
smejky | 10:0176705be216 | 511 | grafika(1); |
smejky | 8:b6e7401fdcfc | 512 | Menu(); |
smejky | 8:b6e7401fdcfc | 513 | } |
smejky | 8:b6e7401fdcfc | 514 | //levý čudlik |
smejky | 8:b6e7401fdcfc | 515 | |
smejky | 11:4ca8388080c6 | 516 | //stred pravy spodni cudlik |
smejky | 11:4ca8388080c6 | 517 | if ((touch_x > stredni_pravy[0]) && (touch_x < stredni_pravy[2]) && (touch_y < stredni_pravy[3]) && (touch_y > stredni_pravy[1])){ |
smejky | 11:4ca8388080c6 | 518 | spi.fillrect(214,200,320,240,Select); |
smejky | 11:4ca8388080c6 | 519 | spi.Bitmap(227,200,80,40,(unsigned char*)gImage_stredni_pravy_s); |
smejky | 11:4ca8388080c6 | 520 | hold(); |
smejky | 11:4ca8388080c6 | 521 | grafika(5); |
smejky | 11:4ca8388080c6 | 522 | color_picker(); |
smejky | 11:4ca8388080c6 | 523 | |
smejky | 11:4ca8388080c6 | 524 | } |
smejky | 11:4ca8388080c6 | 525 | //stred pravy spodni cudlik |
smejky | 11:4ca8388080c6 | 526 | |
smejky | 9:d1385f7171af | 527 | if((touch_x > green[0]) && (touch_x < green[2]) && (touch_y < green[3]) && (touch_y > green[1])){ |
smejky | 9:d1385f7171af | 528 | hold(); |
smejky | 11:4ca8388080c6 | 529 | color_pick = color_picker(); |
smejky | 11:4ca8388080c6 | 530 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 11:4ca8388080c6 | 531 | spi.fillrect(green1[0],green1[1],green1[2],green1[3],color_pick); |
smejky | 11:4ca8388080c6 | 532 | |
smejky | 8:b6e7401fdcfc | 533 | } |
smejky | 8:b6e7401fdcfc | 534 | } |
smejky | 8:b6e7401fdcfc | 535 | } |
smejky | 8:b6e7401fdcfc | 536 | } |
smejky | 8:b6e7401fdcfc | 537 | |
smejky | 8:b6e7401fdcfc | 538 | } |
smejky | 8:b6e7401fdcfc | 539 | |
smejky | 11:4ca8388080c6 | 540 | int color_picker(){ |
smejky | 11:4ca8388080c6 | 541 | |
smejky | 11:4ca8388080c6 | 542 | int pole1[] = {69,29,116,76}; |
smejky | 11:4ca8388080c6 | 543 | int pole2[] = {117,29,163,76}; |
smejky | 11:4ca8388080c6 | 544 | int pole3[] = {164,29,210,76}; |
smejky | 11:4ca8388080c6 | 545 | int pole4[] = {211,29,257,76}; |
smejky | 11:4ca8388080c6 | 546 | int pole5[] = {69,77,116,123}; |
smejky | 11:4ca8388080c6 | 547 | int pole6[] = {117,77,163,123}; |
smejky | 11:4ca8388080c6 | 548 | int pole7[] = {164,77,210,123}; |
smejky | 11:4ca8388080c6 | 549 | int pole8[] = {211,77,257,123}; |
smejky | 11:4ca8388080c6 | 550 | int pole9[] = {69,124,116,170}; |
smejky | 11:4ca8388080c6 | 551 | int pole10[] = {117,124,163,170}; |
smejky | 11:4ca8388080c6 | 552 | int pole11[] = {164,124,210,170}; |
smejky | 11:4ca8388080c6 | 553 | int pole12[] = {211,124,257,170}; |
smejky | 11:4ca8388080c6 | 554 | |
smejky | 11:4ca8388080c6 | 555 | |
smejky | 11:4ca8388080c6 | 556 | int pole4t[] = {29,69,76,116}; |
smejky | 11:4ca8388080c6 | 557 | int pole3t[] = {29,117,76,163}; |
smejky | 11:4ca8388080c6 | 558 | int pole2t[] = {29,164,76,210}; |
smejky | 11:4ca8388080c6 | 559 | int pole1t[] = {29,211,76,257}; |
smejky | 11:4ca8388080c6 | 560 | int pole8t[] = {77,69,123,116}; |
smejky | 11:4ca8388080c6 | 561 | int pole7t[] = {77,117,123,163}; |
smejky | 11:4ca8388080c6 | 562 | int pole6t[] = {77,164,123,210}; |
smejky | 11:4ca8388080c6 | 563 | int pole5t[] = {77,211,123,257}; |
smejky | 11:4ca8388080c6 | 564 | int pole12t[] = {124,69,170,116}; |
smejky | 11:4ca8388080c6 | 565 | int pole11t[] = {124,117,170,163}; |
smejky | 11:4ca8388080c6 | 566 | int pole10t[] = {124,164,170,210}; |
smejky | 11:4ca8388080c6 | 567 | int pole9t[] = {124,211,170,257}; |
smejky | 11:4ca8388080c6 | 568 | |
smejky | 11:4ca8388080c6 | 569 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 11:4ca8388080c6 | 570 | spi.fillrect(pole1[0],pole1[1],pole1[2],pole1[3],Red); |
smejky | 11:4ca8388080c6 | 571 | spi.fillrect(pole2[0],pole2[1],pole2[2],pole2[3],Orange); |
smejky | 11:4ca8388080c6 | 572 | spi.fillrect(pole3[0],pole3[1],pole3[2],pole3[3],Yellow); |
smejky | 11:4ca8388080c6 | 573 | spi.fillrect(pole4[0],pole4[1],pole4[2],pole4[3],GreenYellow); |
smejky | 11:4ca8388080c6 | 574 | spi.fillrect(pole5[0],pole5[1],pole5[2],pole5[3],Green); |
smejky | 11:4ca8388080c6 | 575 | spi.fillrect(pole6[0],pole6[1],pole6[2],pole6[3],White); |
smejky | 11:4ca8388080c6 | 576 | spi.fillrect(pole7[0],pole7[1],pole7[2],pole7[3],Cyan); |
smejky | 11:4ca8388080c6 | 577 | spi.fillrect(pole8[0],pole8[1],pole8[2],pole8[3],DarkCyan); |
smejky | 11:4ca8388080c6 | 578 | spi.fillrect(pole9[0],pole9[1],pole9[2],pole9[3],Blue); |
smejky | 11:4ca8388080c6 | 579 | spi.fillrect(pole10[0],pole10[1],pole10[2],pole10[3],Purple); |
smejky | 11:4ca8388080c6 | 580 | spi.fillrect(pole11[0],pole11[1],pole11[2],pole11[3],Magenta); |
smejky | 11:4ca8388080c6 | 581 | spi.fillrect(pole12[0],pole12[1],pole12[2],pole12[3],Pink); |
smejky | 11:4ca8388080c6 | 582 | |
smejky | 11:4ca8388080c6 | 583 | |
smejky | 11:4ca8388080c6 | 584 | while(1) |
smejky | 11:4ca8388080c6 | 585 | { |
smejky | 11:4ca8388080c6 | 586 | if (touch.DataAvailable()) |
smejky | 11:4ca8388080c6 | 587 | { |
smejky | 11:4ca8388080c6 | 588 | if(touch.Read()) |
smejky | 11:4ca8388080c6 | 589 | { |
smejky | 11:4ca8388080c6 | 590 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 11:4ca8388080c6 | 591 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 11:4ca8388080c6 | 592 | |
smejky | 11:4ca8388080c6 | 593 | if((touch_x > pole1t[0]) && (touch_x < pole1t[2]) && (touch_y < pole1t[3]) && (touch_y > pole1t[1])){ |
smejky | 11:4ca8388080c6 | 594 | hold(); |
smejky | 11:4ca8388080c6 | 595 | return Red; |
smejky | 11:4ca8388080c6 | 596 | } |
smejky | 11:4ca8388080c6 | 597 | |
smejky | 11:4ca8388080c6 | 598 | if((touch_x > pole2t[0]) && (touch_x < pole2t[2]) && (touch_y < pole2t[3]) && (touch_y > pole2t[1])){ |
smejky | 11:4ca8388080c6 | 599 | hold(); |
smejky | 11:4ca8388080c6 | 600 | return Orange; |
smejky | 11:4ca8388080c6 | 601 | } |
smejky | 11:4ca8388080c6 | 602 | |
smejky | 11:4ca8388080c6 | 603 | if((touch_x > pole3t[0]) && (touch_x < pole3t[2]) && (touch_y < pole3t[3]) && (touch_y > pole3t[1])){ |
smejky | 11:4ca8388080c6 | 604 | hold(); |
smejky | 11:4ca8388080c6 | 605 | return Yellow; |
smejky | 11:4ca8388080c6 | 606 | } |
smejky | 11:4ca8388080c6 | 607 | |
smejky | 11:4ca8388080c6 | 608 | if((touch_x > pole4t[0]) && (touch_x < pole4t[2]) && (touch_y < pole4t[3]) && (touch_y > pole4t[1])){ |
smejky | 11:4ca8388080c6 | 609 | hold(); |
smejky | 11:4ca8388080c6 | 610 | return GreenYellow; |
smejky | 11:4ca8388080c6 | 611 | } |
smejky | 11:4ca8388080c6 | 612 | |
smejky | 11:4ca8388080c6 | 613 | if((touch_x > pole5t[0]) && (touch_x < pole5t[2]) && (touch_y < pole5t[3]) && (touch_y > pole5t[1])){ |
smejky | 11:4ca8388080c6 | 614 | hold(); |
smejky | 11:4ca8388080c6 | 615 | return Green; |
smejky | 11:4ca8388080c6 | 616 | } |
smejky | 11:4ca8388080c6 | 617 | |
smejky | 11:4ca8388080c6 | 618 | if((touch_x > pole6t[0]) && (touch_x < pole6t[2]) && (touch_y < pole6t[3]) && (touch_y > pole6t[1])){ |
smejky | 11:4ca8388080c6 | 619 | hold(); |
smejky | 11:4ca8388080c6 | 620 | return White; |
smejky | 11:4ca8388080c6 | 621 | } |
smejky | 11:4ca8388080c6 | 622 | |
smejky | 11:4ca8388080c6 | 623 | if((touch_x > pole7t[0]) && (touch_x < pole7t[2]) && (touch_y < pole7t[3]) && (touch_y > pole7t[1])){ |
smejky | 11:4ca8388080c6 | 624 | hold(); |
smejky | 11:4ca8388080c6 | 625 | return Cyan; |
smejky | 11:4ca8388080c6 | 626 | } |
smejky | 11:4ca8388080c6 | 627 | |
smejky | 11:4ca8388080c6 | 628 | if((touch_x > pole8t[0]) && (touch_x < pole8t[2]) && (touch_y < pole8t[3]) && (touch_y > pole8t[1])){ |
smejky | 11:4ca8388080c6 | 629 | hold(); |
smejky | 11:4ca8388080c6 | 630 | return DarkCyan; |
smejky | 11:4ca8388080c6 | 631 | } |
smejky | 11:4ca8388080c6 | 632 | |
smejky | 11:4ca8388080c6 | 633 | if((touch_x > pole9t[0]) && (touch_x < pole9t[2]) && (touch_y < pole9t[3]) && (touch_y > pole9t[1])){ |
smejky | 11:4ca8388080c6 | 634 | hold(); |
smejky | 11:4ca8388080c6 | 635 | return Blue; |
smejky | 11:4ca8388080c6 | 636 | } |
smejky | 11:4ca8388080c6 | 637 | |
smejky | 11:4ca8388080c6 | 638 | if((touch_x > pole10t[0]) && (touch_x < pole10t[2]) && (touch_y < pole10t[3]) && (touch_y > pole10t[1])){ |
smejky | 11:4ca8388080c6 | 639 | hold(); |
smejky | 11:4ca8388080c6 | 640 | return Purple; |
smejky | 11:4ca8388080c6 | 641 | } |
smejky | 11:4ca8388080c6 | 642 | |
smejky | 11:4ca8388080c6 | 643 | if((touch_x > pole11t[0]) && (touch_x < pole11t[2]) && (touch_y < pole11t[3]) && (touch_y > pole11t[1])){ |
smejky | 11:4ca8388080c6 | 644 | hold(); |
smejky | 11:4ca8388080c6 | 645 | return Magenta; |
smejky | 11:4ca8388080c6 | 646 | } |
smejky | 11:4ca8388080c6 | 647 | |
smejky | 11:4ca8388080c6 | 648 | if((touch_x > pole12t[0]) && (touch_x < pole12t[2]) && (touch_y < pole12t[3]) && (touch_y > pole12t[1])){ |
smejky | 11:4ca8388080c6 | 649 | hold(); |
smejky | 11:4ca8388080c6 | 650 | return Pink; |
smejky | 11:4ca8388080c6 | 651 | } |
smejky | 11:4ca8388080c6 | 652 | } |
smejky | 11:4ca8388080c6 | 653 | } |
smejky | 11:4ca8388080c6 | 654 | } |
smejky | 11:4ca8388080c6 | 655 | |
smejky | 11:4ca8388080c6 | 656 | } |
smejky | 11:4ca8388080c6 | 657 | |
smejky | 11:4ca8388080c6 | 658 | |
smejky | 9:d1385f7171af | 659 | void nastaveni(){ |
smejky | 9:d1385f7171af | 660 | int pravy[] = {34,0,165,46}; //pravý čudlík |
smejky | 9:d1385f7171af | 661 | int levy[] = {34,274,165,320}; //levý čudlík |
smejky | 9:d1385f7171af | 662 | int i = 0; |
smejky | 10:0176705be216 | 663 | |
smejky | 9:d1385f7171af | 664 | |
smejky | 9:d1385f7171af | 665 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 9:d1385f7171af | 666 | int check1[] = {66,10,96,40}; |
smejky | 9:d1385f7171af | 667 | int check2[] = {66,56,96,86}; |
smejky | 9:d1385f7171af | 668 | |
smejky | 10:0176705be216 | 669 | int prvni[] = {46,0,273,46}; //prvni čudlík |
smejky | 10:0176705be216 | 670 | int druhy[] = {46,46,273,92}; //druhy čudlík |
smejky | 10:0176705be216 | 671 | int treti[] = {46,92,273,138}; //treti čudlík |
smejky | 10:0176705be216 | 672 | int ctvrty[] = {46,138,273,184}; //treti čudlík |
smejky | 10:0176705be216 | 673 | |
smejky | 9:d1385f7171af | 674 | |
smejky | 9:d1385f7171af | 675 | spi.background(MojeSeda); |
smejky | 9:d1385f7171af | 676 | spi.fillrect(prvni[0],prvni[1],prvni[2],prvni[3],MojeSeda); //prvni |
smejky | 9:d1385f7171af | 677 | spi.rect(prvni[0],prvni[1],prvni[2],prvni[3],White); //prvni |
smejky | 9:d1385f7171af | 678 | spi.set_font((unsigned char*) Arial28x28); |
smejky | 9:d1385f7171af | 679 | spi.locate(140,14); |
smejky | 9:d1385f7171af | 680 | spi.printf(jazyk[0]); |
smejky | 9:d1385f7171af | 681 | |
smejky | 9:d1385f7171af | 682 | spi.fillrect(druhy[0],druhy[1],druhy[2],druhy[3],MojeSeda); //druhy |
smejky | 9:d1385f7171af | 683 | spi.rect(druhy[0],druhy[1],druhy[2],druhy[3],White); //druhy |
smejky | 9:d1385f7171af | 684 | spi.locate(140,60); |
smejky | 9:d1385f7171af | 685 | spi.printf(jazyk[1]); |
smejky | 9:d1385f7171af | 686 | |
smejky | 9:d1385f7171af | 687 | switch(lang) |
smejky | 9:d1385f7171af | 688 | { |
smejky | 9:d1385f7171af | 689 | case 1: |
smejky | 9:d1385f7171af | 690 | spi.fillrect(check1[0],check1[1],check1[2],check1[3],Green); |
smejky | 9:d1385f7171af | 691 | spi.fillrect(check2[0],check2[1],check2[2],check2[3],Red); |
smejky | 9:d1385f7171af | 692 | break; |
smejky | 9:d1385f7171af | 693 | default: |
smejky | 9:d1385f7171af | 694 | spi.fillrect(check1[0],check1[1],check1[2],check1[3],Red); |
smejky | 9:d1385f7171af | 695 | spi.fillrect(check2[0],check2[1],check2[2],check2[3],Green); |
smejky | 9:d1385f7171af | 696 | } |
smejky | 9:d1385f7171af | 697 | |
smejky | 9:d1385f7171af | 698 | |
smejky | 9:d1385f7171af | 699 | spi.fillrect(treti[0],treti[1],treti[2],treti[3],MojeSeda); //treti |
smejky | 9:d1385f7171af | 700 | spi.rect(treti[0],treti[1],treti[2],treti[3],White); //treti |
smejky | 9:d1385f7171af | 701 | spi.locate(90,106); |
smejky | 9:d1385f7171af | 702 | spi.printf(jazyk[2]); |
smejky | 10:0176705be216 | 703 | |
smejky | 10:0176705be216 | 704 | spi.fillrect(ctvrty[0],ctvrty[1],ctvrty[2],ctvrty[3],MojeSeda); //ctvrty |
smejky | 10:0176705be216 | 705 | spi.rect(ctvrty[0],ctvrty[1],ctvrty[2],ctvrty[3],White); //ctvrty |
smejky | 10:0176705be216 | 706 | spi.locate(95,152); |
smejky | 10:0176705be216 | 707 | spi.printf(jazyk[3]); |
smejky | 10:0176705be216 | 708 | |
smejky | 10:0176705be216 | 709 | |
smejky | 9:d1385f7171af | 710 | while(1){ |
smejky | 9:d1385f7171af | 711 | if (touch.DataAvailable()) |
smejky | 9:d1385f7171af | 712 | { |
smejky | 9:d1385f7171af | 713 | if(touch.Read()) |
smejky | 9:d1385f7171af | 714 | { |
smejky | 9:d1385f7171af | 715 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 9:d1385f7171af | 716 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 9:d1385f7171af | 717 | |
smejky | 9:d1385f7171af | 718 | //pravý čudlik |
smejky | 9:d1385f7171af | 719 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 9:d1385f7171af | 720 | |
smejky | 9:d1385f7171af | 721 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 722 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 723 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit_s); |
smejky | 9:d1385f7171af | 724 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 725 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 726 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 727 | hold(); |
smejky | 9:d1385f7171af | 728 | switch(jazyk_s) |
smejky | 9:d1385f7171af | 729 | { |
smejky | 9:d1385f7171af | 730 | case 1: |
smejky | 10:0176705be216 | 731 | while(i < 4){ |
smejky | 9:d1385f7171af | 732 | strcpy(jazyk[i], cz[i]); |
smejky | 9:d1385f7171af | 733 | i++; |
smejky | 9:d1385f7171af | 734 | } |
smejky | 9:d1385f7171af | 735 | break; |
smejky | 9:d1385f7171af | 736 | default: |
smejky | 10:0176705be216 | 737 | while(i < 4){ |
smejky | 9:d1385f7171af | 738 | strcpy(jazyk[i], en[i]); |
smejky | 9:d1385f7171af | 739 | i++; |
smejky | 9:d1385f7171af | 740 | } |
smejky | 9:d1385f7171af | 741 | } |
smejky | 9:d1385f7171af | 742 | i = 0; |
smejky | 9:d1385f7171af | 743 | grafika(1); |
smejky | 9:d1385f7171af | 744 | grafika(2); |
smejky | 9:d1385f7171af | 745 | Menu(); |
smejky | 9:d1385f7171af | 746 | wait(0.2); |
smejky | 9:d1385f7171af | 747 | } |
smejky | 9:d1385f7171af | 748 | //pravý čudlik |
smejky | 9:d1385f7171af | 749 | |
smejky | 9:d1385f7171af | 750 | //levý čudlik |
smejky | 9:d1385f7171af | 751 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 9:d1385f7171af | 752 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 753 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 754 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit_s);// levy |
smejky | 9:d1385f7171af | 755 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 756 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 757 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 758 | |
smejky | 9:d1385f7171af | 759 | hold(); |
smejky | 9:d1385f7171af | 760 | |
smejky | 9:d1385f7171af | 761 | grafika(2); |
smejky | 9:d1385f7171af | 762 | grafika(1); |
smejky | 9:d1385f7171af | 763 | Menu(); |
smejky | 9:d1385f7171af | 764 | wait(0.2); |
smejky | 9:d1385f7171af | 765 | } |
smejky | 9:d1385f7171af | 766 | //levý čudlik |
smejky | 9:d1385f7171af | 767 | |
smejky | 9:d1385f7171af | 768 | if((touch_x > prvni[1]) && (touch_x < prvni[3]) && (touch_y < prvni[2]) && (touch_y > prvni[0])){ |
smejky | 9:d1385f7171af | 769 | hold(); |
smejky | 9:d1385f7171af | 770 | jazyk_s = 1; |
smejky | 9:d1385f7171af | 771 | lang = jazyk_s; |
smejky | 9:d1385f7171af | 772 | spi.fillrect(check1[0],check1[1],check1[2],check1[3],Green); |
smejky | 9:d1385f7171af | 773 | spi.fillrect(check2[0],check2[1],check2[2],check2[3],Red); |
smejky | 9:d1385f7171af | 774 | wait(0.2); |
smejky | 9:d1385f7171af | 775 | } |
smejky | 9:d1385f7171af | 776 | if((touch_x > druhy[1]) && (touch_x < druhy[3]) && (touch_y < druhy[2]) && (touch_y > druhy[0])){ |
smejky | 9:d1385f7171af | 777 | hold(); |
smejky | 9:d1385f7171af | 778 | jazyk_s = 0; |
smejky | 9:d1385f7171af | 779 | lang = jazyk_s; |
smejky | 9:d1385f7171af | 780 | spi.fillrect(check1[0],check1[1],check1[2],check1[3],Red); |
smejky | 9:d1385f7171af | 781 | spi.fillrect(check2[0],check2[1],check2[2],check2[3],Green); |
smejky | 9:d1385f7171af | 782 | wait(0.2); |
smejky | 9:d1385f7171af | 783 | } |
smejky | 9:d1385f7171af | 784 | if((touch_x > treti[1]) && (touch_x < treti[3]) && (touch_y < treti[2]) && (touch_y > treti[0])){ |
smejky | 9:d1385f7171af | 785 | hold(); |
smejky | 9:d1385f7171af | 786 | nastavit_hodiny(); |
smejky | 9:d1385f7171af | 787 | } |
smejky | 10:0176705be216 | 788 | if((touch_x > ctvrty[1]) && (touch_x < ctvrty[3]) && (touch_y < ctvrty[2]) && (touch_y > ctvrty[0])){ |
smejky | 10:0176705be216 | 789 | hold(); |
smejky | 10:0176705be216 | 790 | brightness(); |
smejky | 10:0176705be216 | 791 | } |
smejky | 9:d1385f7171af | 792 | |
smejky | 9:d1385f7171af | 793 | |
smejky | 9:d1385f7171af | 794 | } |
smejky | 9:d1385f7171af | 795 | } |
smejky | 9:d1385f7171af | 796 | } |
smejky | 9:d1385f7171af | 797 | |
smejky | 9:d1385f7171af | 798 | } |
smejky | 9:d1385f7171af | 799 | |
smejky | 10:0176705be216 | 800 | |
smejky | 10:0176705be216 | 801 | void brightness(){ |
smejky | 10:0176705be216 | 802 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 9:d1385f7171af | 803 | int pravy[] = {34,0,165,46}; //pravý čudlík |
smejky | 9:d1385f7171af | 804 | int levy[] = {34,274,165,320}; //levý čudlík |
smejky | 9:d1385f7171af | 805 | |
smejky | 10:0176705be216 | 806 | int p10t[] = {229,52,264,147}; |
smejky | 10:0176705be216 | 807 | int p30t[] = {186,52,221,147}; |
smejky | 10:0176705be216 | 808 | int p50t[] = {143,52,178,147}; |
smejky | 10:0176705be216 | 809 | int p70t[] = {100,52,135,147}; |
smejky | 10:0176705be216 | 810 | int p90t[] = {57,52,92,147}; |
smejky | 10:0176705be216 | 811 | |
smejky | 10:0176705be216 | 812 | int p10[] = {57,52,92,147}; |
smejky | 10:0176705be216 | 813 | int p30[] = {100,52,135,147}; |
smejky | 10:0176705be216 | 814 | int p50[] = {143,52,178,147}; |
smejky | 10:0176705be216 | 815 | int p70[] = {186,52,221,147}; |
smejky | 10:0176705be216 | 816 | int p90[] = {229,52,264,147}; |
smejky | 10:0176705be216 | 817 | |
smejky | 10:0176705be216 | 818 | switch(jas_s){ |
smejky | 10:0176705be216 | 819 | case 0: |
smejky | 10:0176705be216 | 820 | spi.fillrect(p10[0],p10[1],p10[2],p10[3],jas[0]); |
smejky | 10:0176705be216 | 821 | spi.fillrect(p30[0],p30[1],p30[2],p30[3],jas[1]); |
smejky | 10:0176705be216 | 822 | spi.fillrect(p50[0],p50[1],p50[2],p50[3],jas[1]); |
smejky | 10:0176705be216 | 823 | spi.fillrect(p70[0],p70[1],p70[2],p70[3],jas[1]); |
smejky | 10:0176705be216 | 824 | spi.fillrect(p90[0],p90[1],p90[2],p90[3],jas[1]); |
smejky | 10:0176705be216 | 825 | break; |
smejky | 10:0176705be216 | 826 | case 1: |
smejky | 10:0176705be216 | 827 | spi.fillrect(p10[0],p10[1],p10[2],p10[3],jas[0]); |
smejky | 10:0176705be216 | 828 | spi.fillrect(p30[0],p30[1],p30[2],p30[3],jas[0]); |
smejky | 10:0176705be216 | 829 | spi.fillrect(p50[0],p50[1],p50[2],p50[3],jas[1]); |
smejky | 10:0176705be216 | 830 | spi.fillrect(p70[0],p70[1],p70[2],p70[3],jas[1]); |
smejky | 10:0176705be216 | 831 | spi.fillrect(p90[0],p90[1],p90[2],p90[3],jas[1]); |
smejky | 10:0176705be216 | 832 | break; |
smejky | 10:0176705be216 | 833 | case 2: |
smejky | 10:0176705be216 | 834 | spi.fillrect(p10[0],p10[1],p10[2],p10[3],jas[0]); |
smejky | 10:0176705be216 | 835 | spi.fillrect(p30[0],p30[1],p30[2],p30[3],jas[0]); |
smejky | 10:0176705be216 | 836 | spi.fillrect(p50[0],p50[1],p50[2],p50[3],jas[0]); |
smejky | 10:0176705be216 | 837 | spi.fillrect(p70[0],p70[1],p70[2],p70[3],jas[1]); |
smejky | 10:0176705be216 | 838 | spi.fillrect(p90[0],p90[1],p90[2],p90[3],jas[1]); |
smejky | 10:0176705be216 | 839 | break; |
smejky | 10:0176705be216 | 840 | case 3: |
smejky | 10:0176705be216 | 841 | spi.fillrect(p10[0],p10[1],p10[2],p10[3],jas[0]); |
smejky | 10:0176705be216 | 842 | spi.fillrect(p30[0],p30[1],p30[2],p30[3],jas[0]); |
smejky | 10:0176705be216 | 843 | spi.fillrect(p50[0],p50[1],p50[2],p50[3],jas[0]); |
smejky | 10:0176705be216 | 844 | spi.fillrect(p70[0],p70[1],p70[2],p70[3],jas[0]); |
smejky | 10:0176705be216 | 845 | spi.fillrect(p90[0],p90[1],p90[2],p90[3],jas[1]); |
smejky | 10:0176705be216 | 846 | break; |
smejky | 10:0176705be216 | 847 | case 4: |
smejky | 10:0176705be216 | 848 | spi.fillrect(p10[0],p10[1],p10[2],p10[3],jas[0]); |
smejky | 10:0176705be216 | 849 | spi.fillrect(p30[0],p30[1],p30[2],p30[3],jas[0]); |
smejky | 10:0176705be216 | 850 | spi.fillrect(p50[0],p50[1],p50[2],p50[3],jas[0]); |
smejky | 10:0176705be216 | 851 | spi.fillrect(p70[0],p70[1],p70[2],p70[3],jas[0]); |
smejky | 10:0176705be216 | 852 | spi.fillrect(p90[0],p90[1],p90[2],p90[3],jas[0]); |
smejky | 10:0176705be216 | 853 | break; |
smejky | 10:0176705be216 | 854 | default: |
smejky | 10:0176705be216 | 855 | printf("err"); |
smejky | 9:d1385f7171af | 856 | |
smejky | 10:0176705be216 | 857 | } |
smejky | 9:d1385f7171af | 858 | |
smejky | 9:d1385f7171af | 859 | while(1){ |
smejky | 9:d1385f7171af | 860 | if (touch.DataAvailable()) |
smejky | 9:d1385f7171af | 861 | { |
smejky | 9:d1385f7171af | 862 | if(touch.Read()) |
smejky | 9:d1385f7171af | 863 | { |
smejky | 9:d1385f7171af | 864 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 9:d1385f7171af | 865 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 9:d1385f7171af | 866 | |
smejky | 9:d1385f7171af | 867 | //pravý čudlik |
smejky | 9:d1385f7171af | 868 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 9:d1385f7171af | 869 | |
smejky | 9:d1385f7171af | 870 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 871 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 872 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit_s); |
smejky | 9:d1385f7171af | 873 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 874 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 875 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 876 | hold(); |
smejky | 9:d1385f7171af | 877 | |
smejky | 9:d1385f7171af | 878 | grafika(9); |
smejky | 10:0176705be216 | 879 | br.write(lcd_jas); |
smejky | 9:d1385f7171af | 880 | nastaveni(); |
smejky | 9:d1385f7171af | 881 | wait(0.2); |
smejky | 9:d1385f7171af | 882 | } |
smejky | 9:d1385f7171af | 883 | //pravý čudlik |
smejky | 9:d1385f7171af | 884 | |
smejky | 9:d1385f7171af | 885 | //levý čudlik |
smejky | 9:d1385f7171af | 886 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 9:d1385f7171af | 887 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 888 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 889 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit_s);// levy |
smejky | 9:d1385f7171af | 890 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 891 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 892 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 893 | |
smejky | 9:d1385f7171af | 894 | hold(); |
smejky | 10:0176705be216 | 895 | lcd_jas = 0.00f; |
smejky | 9:d1385f7171af | 896 | grafika(7); |
smejky | 9:d1385f7171af | 897 | nastaveni(); |
smejky | 9:d1385f7171af | 898 | wait(0.2); |
smejky | 9:d1385f7171af | 899 | } |
smejky | 9:d1385f7171af | 900 | //levý čudlik |
smejky | 9:d1385f7171af | 901 | |
smejky | 10:0176705be216 | 902 | if((touch_x > p10t[1]) && (touch_x < p10t[3]) && (touch_y < p10t[2]) && (touch_y > p10t[0])){ |
smejky | 10:0176705be216 | 903 | hold(); |
smejky | 10:0176705be216 | 904 | jas_s = 0; |
smejky | 10:0176705be216 | 905 | lcd_jas = 0.10f; |
smejky | 10:0176705be216 | 906 | brightness(); |
smejky | 10:0176705be216 | 907 | |
smejky | 10:0176705be216 | 908 | } |
smejky | 10:0176705be216 | 909 | |
smejky | 10:0176705be216 | 910 | if((touch_x > p30t[1]) && (touch_x < p30t[3]) && (touch_y < p30t[2]) && (touch_y > p30t[0])){ |
smejky | 10:0176705be216 | 911 | hold(); |
smejky | 10:0176705be216 | 912 | jas_s = 1; |
smejky | 10:0176705be216 | 913 | lcd_jas = 0.30f; |
smejky | 10:0176705be216 | 914 | brightness(); |
smejky | 10:0176705be216 | 915 | } |
smejky | 10:0176705be216 | 916 | if((touch_x > p50t[1]) && (touch_x < p50t[3]) && (touch_y < p50t[2]) && (touch_y > p50t[0])){ |
smejky | 10:0176705be216 | 917 | hold(); |
smejky | 10:0176705be216 | 918 | jas_s = 2; |
smejky | 10:0176705be216 | 919 | lcd_jas = 0.50f; |
smejky | 10:0176705be216 | 920 | brightness(); |
smejky | 10:0176705be216 | 921 | |
smejky | 10:0176705be216 | 922 | } |
smejky | 10:0176705be216 | 923 | if((touch_x > p70t[1]) && (touch_x < p70t[3]) && (touch_y < p70t[2]) && (touch_y > p70t[0])){ |
smejky | 10:0176705be216 | 924 | hold(); |
smejky | 10:0176705be216 | 925 | jas_s = 3; |
smejky | 10:0176705be216 | 926 | lcd_jas = 0.70f; |
smejky | 10:0176705be216 | 927 | brightness(); |
smejky | 10:0176705be216 | 928 | } |
smejky | 10:0176705be216 | 929 | if((touch_x > p90t[1]) && (touch_x < p90t[3]) && (touch_y < p90t[2]) && (touch_y > p90t[0])){ |
smejky | 10:0176705be216 | 930 | hold(); |
smejky | 10:0176705be216 | 931 | jas_s = 4; |
smejky | 10:0176705be216 | 932 | lcd_jas = 0.90f; |
smejky | 10:0176705be216 | 933 | brightness(); |
smejky | 10:0176705be216 | 934 | } |
smejky | 10:0176705be216 | 935 | |
smejky | 10:0176705be216 | 936 | |
smejky | 10:0176705be216 | 937 | } |
smejky | 10:0176705be216 | 938 | } |
smejky | 10:0176705be216 | 939 | } |
smejky | 10:0176705be216 | 940 | } |
smejky | 10:0176705be216 | 941 | |
smejky | 11:4ca8388080c6 | 942 | void on_off(){ |
smejky | 11:4ca8388080c6 | 943 | int pravy[] = {34,0,165,46}; //pravý čudlík |
smejky | 11:4ca8388080c6 | 944 | int levy[] = {34,274,165,320}; //levý čudlík |
smejky | 11:4ca8388080c6 | 945 | |
smejky | 11:4ca8388080c6 | 946 | int up1[] = {172,28,258,57}; |
smejky | 11:4ca8388080c6 | 947 | int down1[] = {172,142,258,171}; |
smejky | 11:4ca8388080c6 | 948 | |
smejky | 11:4ca8388080c6 | 949 | int up2[] = {62,28,148,57}; |
smejky | 11:4ca8388080c6 | 950 | int down2[] = {62,142,148,171}; |
smejky | 11:4ca8388080c6 | 951 | |
smejky | 11:4ca8388080c6 | 952 | bool a = true; |
smejky | 11:4ca8388080c6 | 953 | |
smejky | 11:4ca8388080c6 | 954 | cas_hodiny_on = 0; |
smejky | 11:4ca8388080c6 | 955 | cas_minuty_on = 0; |
smejky | 11:4ca8388080c6 | 956 | cas_hodiny_off = 0; |
smejky | 11:4ca8388080c6 | 957 | cas_minuty_off = 0; |
smejky | 11:4ca8388080c6 | 958 | |
smejky | 11:4ca8388080c6 | 959 | int h1_on = cas_hodiny_on / 10; |
smejky | 11:4ca8388080c6 | 960 | int h2_on = cas_hodiny_on % 10; |
smejky | 10:0176705be216 | 961 | |
smejky | 11:4ca8388080c6 | 962 | int h1_off = cas_hodiny_off / 10; |
smejky | 11:4ca8388080c6 | 963 | int h2_off = cas_hodiny_off % 10; |
smejky | 11:4ca8388080c6 | 964 | |
smejky | 11:4ca8388080c6 | 965 | char cisla[10][3] = { |
smejky | 11:4ca8388080c6 | 966 | "0", |
smejky | 11:4ca8388080c6 | 967 | "1", |
smejky | 11:4ca8388080c6 | 968 | "2", |
smejky | 11:4ca8388080c6 | 969 | "3", |
smejky | 11:4ca8388080c6 | 970 | "4", |
smejky | 11:4ca8388080c6 | 971 | "5", |
smejky | 11:4ca8388080c6 | 972 | "6", |
smejky | 11:4ca8388080c6 | 973 | "7", |
smejky | 11:4ca8388080c6 | 974 | "8", |
smejky | 11:4ca8388080c6 | 975 | "9" |
smejky | 11:4ca8388080c6 | 976 | }; |
smejky | 11:4ca8388080c6 | 977 | |
smejky | 11:4ca8388080c6 | 978 | int m1_on = cas_minuty_on / 10; |
smejky | 11:4ca8388080c6 | 979 | int m2_on = cas_minuty_on % 10; |
smejky | 11:4ca8388080c6 | 980 | |
smejky | 11:4ca8388080c6 | 981 | int m1_off = cas_minuty_off / 10; |
smejky | 11:4ca8388080c6 | 982 | int m2_off = cas_minuty_off % 10; |
smejky | 11:4ca8388080c6 | 983 | |
smejky | 11:4ca8388080c6 | 984 | int blue1[] = {71,65,249,134}; |
smejky | 11:4ca8388080c6 | 985 | int bar2[] = {159,200,320,240}; |
smejky | 11:4ca8388080c6 | 986 | int bar1[] = {0,200,160,240}; |
smejky | 11:4ca8388080c6 | 987 | |
smejky | 11:4ca8388080c6 | 988 | int b1[] = {200,159,240,320}; |
smejky | 11:4ca8388080c6 | 989 | int b2[] = {200,0,240,160}; |
smejky | 11:4ca8388080c6 | 990 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 11:4ca8388080c6 | 991 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 11:4ca8388080c6 | 992 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 11:4ca8388080c6 | 993 | |
smejky | 11:4ca8388080c6 | 994 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 11:4ca8388080c6 | 995 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 11:4ca8388080c6 | 996 | |
smejky | 11:4ca8388080c6 | 997 | |
smejky | 11:4ca8388080c6 | 998 | spi.fillrect(bar1[0],bar1[1],bar1[2],bar1[3],Select); |
smejky | 11:4ca8388080c6 | 999 | spi.fillrect(bar2[0],bar2[1],bar2[2],bar2[3],Black); |
smejky | 11:4ca8388080c6 | 1000 | spi.fillrect(blue1[0],blue1[1],blue1[2],blue1[3],MojeSeda); |
smejky | 11:4ca8388080c6 | 1001 | |
smejky | 11:4ca8388080c6 | 1002 | spi.set_font((unsigned char*) Arial21x21); |
smejky | 11:4ca8388080c6 | 1003 | spi.background(Select); |
smejky | 11:4ca8388080c6 | 1004 | spi.locate(55,210); |
smejky | 11:4ca8388080c6 | 1005 | spi.printf(" ON"); |
smejky | 11:4ca8388080c6 | 1006 | spi.background(Black); |
smejky | 11:4ca8388080c6 | 1007 | spi.locate(215,210); |
smejky | 11:4ca8388080c6 | 1008 | spi.printf(" OFF"); |
smejky | 11:4ca8388080c6 | 1009 | |
smejky | 11:4ca8388080c6 | 1010 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1011 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1012 | spi.locate(80,80); |
smejky | 11:4ca8388080c6 | 1013 | spi.printf(cisla[h1_on]); |
smejky | 11:4ca8388080c6 | 1014 | spi.locate(110,80); |
smejky | 11:4ca8388080c6 | 1015 | spi.printf(cisla[h2_on]); |
smejky | 11:4ca8388080c6 | 1016 | spi.locate(155,80); |
smejky | 11:4ca8388080c6 | 1017 | spi.printf(":"); |
smejky | 11:4ca8388080c6 | 1018 | spi.locate(189,80); |
smejky | 11:4ca8388080c6 | 1019 | spi.printf(cisla[m1_on]); |
smejky | 11:4ca8388080c6 | 1020 | spi.locate(219,80); |
smejky | 11:4ca8388080c6 | 1021 | spi.printf(cisla[m2_on]); |
smejky | 11:4ca8388080c6 | 1022 | |
smejky | 11:4ca8388080c6 | 1023 | grafika(9); |
smejky | 11:4ca8388080c6 | 1024 | grafika(7); |
smejky | 11:4ca8388080c6 | 1025 | while(1){ |
smejky | 11:4ca8388080c6 | 1026 | if (touch.DataAvailable()) |
smejky | 11:4ca8388080c6 | 1027 | { |
smejky | 11:4ca8388080c6 | 1028 | if(touch.Read()) |
smejky | 11:4ca8388080c6 | 1029 | { |
smejky | 11:4ca8388080c6 | 1030 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 11:4ca8388080c6 | 1031 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 11:4ca8388080c6 | 1032 | |
smejky | 11:4ca8388080c6 | 1033 | //pravý čudlik |
smejky | 11:4ca8388080c6 | 1034 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 11:4ca8388080c6 | 1035 | |
smejky | 11:4ca8388080c6 | 1036 | //GRAFIKA************************************************** |
smejky | 11:4ca8388080c6 | 1037 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 11:4ca8388080c6 | 1038 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit_s); |
smejky | 11:4ca8388080c6 | 1039 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 11:4ca8388080c6 | 1040 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 11:4ca8388080c6 | 1041 | //GRAFIKA************************************************** |
smejky | 11:4ca8388080c6 | 1042 | hold(); |
smejky | 11:4ca8388080c6 | 1043 | |
smejky | 11:4ca8388080c6 | 1044 | time_on = 1037059200 + (cas_hodiny_on * 3600) + (cas_minuty_on * 60); |
smejky | 11:4ca8388080c6 | 1045 | time_off = 1037059200 + (cas_hodiny_off * 3600) + (cas_minuty_off * 60); |
smejky | 11:4ca8388080c6 | 1046 | |
smejky | 11:4ca8388080c6 | 1047 | grafika(); |
smejky | 11:4ca8388080c6 | 1048 | Button(); |
smejky | 11:4ca8388080c6 | 1049 | wait(0.2); |
smejky | 11:4ca8388080c6 | 1050 | } |
smejky | 11:4ca8388080c6 | 1051 | //pravý čudlik |
smejky | 11:4ca8388080c6 | 1052 | |
smejky | 11:4ca8388080c6 | 1053 | //levý čudlik |
smejky | 11:4ca8388080c6 | 1054 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 11:4ca8388080c6 | 1055 | //GRAFIKA************************************************** |
smejky | 11:4ca8388080c6 | 1056 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 11:4ca8388080c6 | 1057 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit_s);// levy |
smejky | 11:4ca8388080c6 | 1058 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 11:4ca8388080c6 | 1059 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 11:4ca8388080c6 | 1060 | //GRAFIKA************************************************** |
smejky | 11:4ca8388080c6 | 1061 | |
smejky | 11:4ca8388080c6 | 1062 | hold(); |
smejky | 11:4ca8388080c6 | 1063 | grafika(); |
smejky | 11:4ca8388080c6 | 1064 | Button(); |
smejky | 11:4ca8388080c6 | 1065 | wait(0.2); |
smejky | 11:4ca8388080c6 | 1066 | } |
smejky | 11:4ca8388080c6 | 1067 | //levý čudlik |
smejky | 11:4ca8388080c6 | 1068 | |
smejky | 11:4ca8388080c6 | 1069 | //ON |
smejky | 11:4ca8388080c6 | 1070 | if ((touch_x > b1[0]) && (touch_x < b1[2]) && (touch_y < b1[3]) && (touch_y > b1[1])){ |
smejky | 11:4ca8388080c6 | 1071 | |
smejky | 11:4ca8388080c6 | 1072 | spi.fillrect(bar1[0],bar1[1],bar1[2],bar1[3],Select); |
smejky | 11:4ca8388080c6 | 1073 | spi.set_font((unsigned char*) Arial21x21); |
smejky | 11:4ca8388080c6 | 1074 | spi.background(Select); |
smejky | 11:4ca8388080c6 | 1075 | spi.locate(55,210); |
smejky | 11:4ca8388080c6 | 1076 | spi.printf(" ON"); |
smejky | 11:4ca8388080c6 | 1077 | |
smejky | 11:4ca8388080c6 | 1078 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1079 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1080 | spi.locate(80,80); |
smejky | 11:4ca8388080c6 | 1081 | spi.printf(cisla[h1_on]); |
smejky | 11:4ca8388080c6 | 1082 | spi.locate(110,80); |
smejky | 11:4ca8388080c6 | 1083 | spi.printf(cisla[h2_on]); |
smejky | 11:4ca8388080c6 | 1084 | spi.locate(189,80); |
smejky | 11:4ca8388080c6 | 1085 | spi.printf(cisla[m1_on]); |
smejky | 11:4ca8388080c6 | 1086 | spi.locate(219,80); |
smejky | 11:4ca8388080c6 | 1087 | spi.printf(cisla[m2_on]); |
smejky | 11:4ca8388080c6 | 1088 | |
smejky | 11:4ca8388080c6 | 1089 | spi.fillrect(bar2[0],bar2[1],bar2[2],bar2[3],Black); |
smejky | 11:4ca8388080c6 | 1090 | spi.set_font((unsigned char*) Arial21x21); |
smejky | 11:4ca8388080c6 | 1091 | spi.background(Black); |
smejky | 11:4ca8388080c6 | 1092 | spi.locate(215,210); |
smejky | 11:4ca8388080c6 | 1093 | spi.printf(" OFF"); |
smejky | 11:4ca8388080c6 | 1094 | |
smejky | 11:4ca8388080c6 | 1095 | a = true; |
smejky | 11:4ca8388080c6 | 1096 | hold(); |
smejky | 11:4ca8388080c6 | 1097 | wait(0.2); |
smejky | 11:4ca8388080c6 | 1098 | } |
smejky | 11:4ca8388080c6 | 1099 | //ON |
smejky | 11:4ca8388080c6 | 1100 | |
smejky | 11:4ca8388080c6 | 1101 | //OFF |
smejky | 11:4ca8388080c6 | 1102 | if ((touch_x > b2[0]) && (touch_x < b2[2]) && (touch_y < b2[3]) && (touch_y > b2[1])){ |
smejky | 11:4ca8388080c6 | 1103 | spi.fillrect(bar1[0],bar1[1],bar1[2],bar1[3],Black); |
smejky | 11:4ca8388080c6 | 1104 | spi.set_font((unsigned char*) Arial21x21); |
smejky | 11:4ca8388080c6 | 1105 | spi.background(Black); |
smejky | 11:4ca8388080c6 | 1106 | spi.locate(55,210); |
smejky | 11:4ca8388080c6 | 1107 | spi.printf(" ON"); |
smejky | 11:4ca8388080c6 | 1108 | |
smejky | 11:4ca8388080c6 | 1109 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1110 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1111 | spi.locate(80,80); |
smejky | 11:4ca8388080c6 | 1112 | spi.printf(cisla[h1_off]); |
smejky | 11:4ca8388080c6 | 1113 | spi.locate(110,80); |
smejky | 11:4ca8388080c6 | 1114 | spi.printf(cisla[h2_off]); |
smejky | 11:4ca8388080c6 | 1115 | spi.locate(189,80); |
smejky | 11:4ca8388080c6 | 1116 | spi.printf(cisla[m1_off]); |
smejky | 11:4ca8388080c6 | 1117 | spi.locate(219,80); |
smejky | 11:4ca8388080c6 | 1118 | spi.printf(cisla[m2_off]); |
smejky | 11:4ca8388080c6 | 1119 | |
smejky | 11:4ca8388080c6 | 1120 | |
smejky | 11:4ca8388080c6 | 1121 | spi.fillrect(bar2[0],bar2[1],bar2[2],bar2[3],Select); |
smejky | 11:4ca8388080c6 | 1122 | spi.set_font((unsigned char*) Arial21x21); |
smejky | 11:4ca8388080c6 | 1123 | spi.background(Select); |
smejky | 11:4ca8388080c6 | 1124 | spi.locate(215,210); |
smejky | 11:4ca8388080c6 | 1125 | spi.printf(" OFF"); |
smejky | 11:4ca8388080c6 | 1126 | a = false; |
smejky | 11:4ca8388080c6 | 1127 | hold(); |
smejky | 11:4ca8388080c6 | 1128 | wait(0.2); |
smejky | 11:4ca8388080c6 | 1129 | } |
smejky | 11:4ca8388080c6 | 1130 | //OFF |
smejky | 11:4ca8388080c6 | 1131 | |
smejky | 11:4ca8388080c6 | 1132 | if(a == true){////////////////////////////////////ON |
smejky | 11:4ca8388080c6 | 1133 | if((touch_x > up1[1]) && (touch_x < up1[3]) && (touch_y < up1[2]) && (touch_y > up1[0])){ |
smejky | 11:4ca8388080c6 | 1134 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru_s); |
smejky | 11:4ca8388080c6 | 1135 | while ((touch.DataAvailable()) && (h2_on < 10)){ |
smejky | 11:4ca8388080c6 | 1136 | h2_on++; |
smejky | 11:4ca8388080c6 | 1137 | cas_hodiny_on++; |
smejky | 11:4ca8388080c6 | 1138 | if(cas_hodiny_on == 24){ |
smejky | 11:4ca8388080c6 | 1139 | cas_hodiny_on = 0; |
smejky | 11:4ca8388080c6 | 1140 | } |
smejky | 11:4ca8388080c6 | 1141 | if(h2_on == 10){ |
smejky | 11:4ca8388080c6 | 1142 | h2_on = 0; |
smejky | 11:4ca8388080c6 | 1143 | h1_on++; |
smejky | 11:4ca8388080c6 | 1144 | } |
smejky | 11:4ca8388080c6 | 1145 | if((h1_on == 2)&&(h2_on == 4)){ |
smejky | 11:4ca8388080c6 | 1146 | h2_on = 0; |
smejky | 11:4ca8388080c6 | 1147 | h1_on = 0; |
smejky | 11:4ca8388080c6 | 1148 | } |
smejky | 11:4ca8388080c6 | 1149 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1150 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1151 | spi.locate(80,80); |
smejky | 11:4ca8388080c6 | 1152 | spi.printf(cisla[h1_on]); |
smejky | 11:4ca8388080c6 | 1153 | spi.locate(110,80); |
smejky | 11:4ca8388080c6 | 1154 | spi.printf(cisla[h2_on]); |
smejky | 11:4ca8388080c6 | 1155 | |
smejky | 11:4ca8388080c6 | 1156 | |
smejky | 11:4ca8388080c6 | 1157 | wait(0.1); |
smejky | 11:4ca8388080c6 | 1158 | } |
smejky | 11:4ca8388080c6 | 1159 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 11:4ca8388080c6 | 1160 | } |
smejky | 11:4ca8388080c6 | 1161 | if((touch_x > down1[1]) && (touch_x < down1[3]) && (touch_y < down1[2]) && (touch_y > down1[0])){ |
smejky | 11:4ca8388080c6 | 1162 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu_s); |
smejky | 11:4ca8388080c6 | 1163 | while ((touch.DataAvailable()) && (h2_on < 10)){ |
smejky | 11:4ca8388080c6 | 1164 | h2_on--; |
smejky | 11:4ca8388080c6 | 1165 | if((h2_on < 0)&&(h1_on == 0)){ |
smejky | 11:4ca8388080c6 | 1166 | h2_on = 3; |
smejky | 11:4ca8388080c6 | 1167 | h1_on = 2; |
smejky | 11:4ca8388080c6 | 1168 | } |
smejky | 11:4ca8388080c6 | 1169 | if(h2_on < 0){ |
smejky | 11:4ca8388080c6 | 1170 | h2_on = 9; |
smejky | 11:4ca8388080c6 | 1171 | h1_on--; |
smejky | 11:4ca8388080c6 | 1172 | } |
smejky | 11:4ca8388080c6 | 1173 | cas_hodiny_on--; |
smejky | 11:4ca8388080c6 | 1174 | if(cas_hodiny_on < 0){ |
smejky | 11:4ca8388080c6 | 1175 | cas_hodiny_on = 23; |
smejky | 11:4ca8388080c6 | 1176 | } |
smejky | 11:4ca8388080c6 | 1177 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1178 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1179 | spi.locate(80,80); |
smejky | 11:4ca8388080c6 | 1180 | spi.printf(cisla[h1_on]); |
smejky | 11:4ca8388080c6 | 1181 | spi.locate(110,80); |
smejky | 11:4ca8388080c6 | 1182 | spi.printf(cisla[h2_on]); |
smejky | 11:4ca8388080c6 | 1183 | wait(0.1); |
smejky | 11:4ca8388080c6 | 1184 | } |
smejky | 11:4ca8388080c6 | 1185 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 11:4ca8388080c6 | 1186 | } |
smejky | 11:4ca8388080c6 | 1187 | if((touch_x > up2[1]) && (touch_x < up2[3]) && (touch_y < up2[2]) && (touch_y > up2[0])){ |
smejky | 11:4ca8388080c6 | 1188 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru_s); |
smejky | 11:4ca8388080c6 | 1189 | while ((touch.DataAvailable()) && (m2_on < 10)){ |
smejky | 11:4ca8388080c6 | 1190 | m2_on++; |
smejky | 11:4ca8388080c6 | 1191 | cas_minuty_on++; |
smejky | 11:4ca8388080c6 | 1192 | if(cas_minuty_on == 60){ |
smejky | 11:4ca8388080c6 | 1193 | cas_minuty_on = 0; |
smejky | 11:4ca8388080c6 | 1194 | } |
smejky | 11:4ca8388080c6 | 1195 | if((m1_on == 5)&&(m2_on == 10)){ |
smejky | 11:4ca8388080c6 | 1196 | m2_on = 0; |
smejky | 11:4ca8388080c6 | 1197 | m1_on = 0; |
smejky | 11:4ca8388080c6 | 1198 | } |
smejky | 11:4ca8388080c6 | 1199 | if(m2_on == 10){ |
smejky | 11:4ca8388080c6 | 1200 | m2_on = 0; |
smejky | 11:4ca8388080c6 | 1201 | m1_on++; |
smejky | 11:4ca8388080c6 | 1202 | } |
smejky | 11:4ca8388080c6 | 1203 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1204 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1205 | spi.locate(189,80); |
smejky | 11:4ca8388080c6 | 1206 | spi.printf(cisla[m1_on]); |
smejky | 11:4ca8388080c6 | 1207 | spi.locate(219,80); |
smejky | 11:4ca8388080c6 | 1208 | spi.printf(cisla[m2_on]); |
smejky | 11:4ca8388080c6 | 1209 | wait(0.1); |
smejky | 11:4ca8388080c6 | 1210 | } |
smejky | 11:4ca8388080c6 | 1211 | |
smejky | 11:4ca8388080c6 | 1212 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 11:4ca8388080c6 | 1213 | } |
smejky | 11:4ca8388080c6 | 1214 | if((touch_x > down2[1]) && (touch_x < down2[3]) && (touch_y < down2[2]) && (touch_y > down2[0])){ |
smejky | 11:4ca8388080c6 | 1215 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu_s); |
smejky | 11:4ca8388080c6 | 1216 | while ((touch.DataAvailable()) && (m2_on < 10)){ |
smejky | 11:4ca8388080c6 | 1217 | m2_on--; |
smejky | 11:4ca8388080c6 | 1218 | if((m2_on < 0)&&(m1_on == 0)){ |
smejky | 11:4ca8388080c6 | 1219 | m2_on = 9; |
smejky | 11:4ca8388080c6 | 1220 | m1_on = 5; |
smejky | 11:4ca8388080c6 | 1221 | } |
smejky | 11:4ca8388080c6 | 1222 | if(m2_on < 0){ |
smejky | 11:4ca8388080c6 | 1223 | m2_on = 9; |
smejky | 11:4ca8388080c6 | 1224 | m1_on--; |
smejky | 11:4ca8388080c6 | 1225 | } |
smejky | 11:4ca8388080c6 | 1226 | cas_minuty_on--; |
smejky | 11:4ca8388080c6 | 1227 | if(cas_minuty_on < 0){ |
smejky | 11:4ca8388080c6 | 1228 | cas_minuty_on = 59; |
smejky | 11:4ca8388080c6 | 1229 | } |
smejky | 11:4ca8388080c6 | 1230 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1231 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1232 | spi.locate(189,80); |
smejky | 11:4ca8388080c6 | 1233 | spi.printf(cisla[m1_on]); |
smejky | 11:4ca8388080c6 | 1234 | spi.locate(219,80); |
smejky | 11:4ca8388080c6 | 1235 | spi.printf(cisla[m2_on]); |
smejky | 11:4ca8388080c6 | 1236 | wait(0.1); |
smejky | 11:4ca8388080c6 | 1237 | } |
smejky | 11:4ca8388080c6 | 1238 | |
smejky | 11:4ca8388080c6 | 1239 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 11:4ca8388080c6 | 1240 | } |
smejky | 11:4ca8388080c6 | 1241 | |
smejky | 11:4ca8388080c6 | 1242 | } |
smejky | 11:4ca8388080c6 | 1243 | else{////////////////////////////////////OFF |
smejky | 11:4ca8388080c6 | 1244 | if((touch_x > up1[1]) && (touch_x < up1[3]) && (touch_y < up1[2]) && (touch_y > up1[0])){ |
smejky | 11:4ca8388080c6 | 1245 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru_s); |
smejky | 11:4ca8388080c6 | 1246 | while ((touch.DataAvailable()) && (h2_off < 10)){ |
smejky | 11:4ca8388080c6 | 1247 | h2_off++; |
smejky | 11:4ca8388080c6 | 1248 | cas_hodiny_off++; |
smejky | 11:4ca8388080c6 | 1249 | if(cas_hodiny_off == 24){ |
smejky | 11:4ca8388080c6 | 1250 | cas_hodiny_off = 0; |
smejky | 11:4ca8388080c6 | 1251 | } |
smejky | 11:4ca8388080c6 | 1252 | if(h2_off == 10){ |
smejky | 11:4ca8388080c6 | 1253 | h2_off = 0; |
smejky | 11:4ca8388080c6 | 1254 | h1_off++; |
smejky | 11:4ca8388080c6 | 1255 | } |
smejky | 11:4ca8388080c6 | 1256 | if((h1_off == 2)&&(h2_off == 4)){ |
smejky | 11:4ca8388080c6 | 1257 | h2_off = 0; |
smejky | 11:4ca8388080c6 | 1258 | h1_off = 0; |
smejky | 11:4ca8388080c6 | 1259 | } |
smejky | 11:4ca8388080c6 | 1260 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1261 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1262 | spi.locate(80,80); |
smejky | 11:4ca8388080c6 | 1263 | spi.printf(cisla[h1_off]); |
smejky | 11:4ca8388080c6 | 1264 | spi.locate(110,80); |
smejky | 11:4ca8388080c6 | 1265 | spi.printf(cisla[h2_off]); |
smejky | 11:4ca8388080c6 | 1266 | |
smejky | 11:4ca8388080c6 | 1267 | |
smejky | 11:4ca8388080c6 | 1268 | wait(0.1); |
smejky | 11:4ca8388080c6 | 1269 | } |
smejky | 11:4ca8388080c6 | 1270 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 11:4ca8388080c6 | 1271 | } |
smejky | 11:4ca8388080c6 | 1272 | if((touch_x > down1[1]) && (touch_x < down1[3]) && (touch_y < down1[2]) && (touch_y > down1[0])){ |
smejky | 11:4ca8388080c6 | 1273 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu_s); |
smejky | 11:4ca8388080c6 | 1274 | while ((touch.DataAvailable()) && (h2_off < 10)){ |
smejky | 11:4ca8388080c6 | 1275 | h2_off--; |
smejky | 11:4ca8388080c6 | 1276 | if((h2_off < 0)&&(h1_off == 0)){ |
smejky | 11:4ca8388080c6 | 1277 | h2_off = 3; |
smejky | 11:4ca8388080c6 | 1278 | h1_off = 2; |
smejky | 11:4ca8388080c6 | 1279 | } |
smejky | 11:4ca8388080c6 | 1280 | if(h2_off < 0){ |
smejky | 11:4ca8388080c6 | 1281 | h2_off = 9; |
smejky | 11:4ca8388080c6 | 1282 | h1_off--; |
smejky | 11:4ca8388080c6 | 1283 | } |
smejky | 11:4ca8388080c6 | 1284 | cas_hodiny_off--; |
smejky | 11:4ca8388080c6 | 1285 | if(cas_hodiny_off < 0){ |
smejky | 11:4ca8388080c6 | 1286 | cas_hodiny_off = 23; |
smejky | 11:4ca8388080c6 | 1287 | } |
smejky | 11:4ca8388080c6 | 1288 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1289 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1290 | spi.locate(80,80); |
smejky | 11:4ca8388080c6 | 1291 | spi.printf(cisla[h1_off]); |
smejky | 11:4ca8388080c6 | 1292 | spi.locate(110,80); |
smejky | 11:4ca8388080c6 | 1293 | spi.printf(cisla[h2_off]); |
smejky | 11:4ca8388080c6 | 1294 | wait(0.1); |
smejky | 11:4ca8388080c6 | 1295 | } |
smejky | 11:4ca8388080c6 | 1296 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 11:4ca8388080c6 | 1297 | } |
smejky | 11:4ca8388080c6 | 1298 | if((touch_x > up2[1]) && (touch_x < up2[3]) && (touch_y < up2[2]) && (touch_y > up2[0])){ |
smejky | 11:4ca8388080c6 | 1299 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru_s); |
smejky | 11:4ca8388080c6 | 1300 | while ((touch.DataAvailable()) && (m2_off < 10)){ |
smejky | 11:4ca8388080c6 | 1301 | m2_off++; |
smejky | 11:4ca8388080c6 | 1302 | cas_minuty_off++; |
smejky | 11:4ca8388080c6 | 1303 | if(cas_minuty_off == 60){ |
smejky | 11:4ca8388080c6 | 1304 | cas_minuty_off = 0; |
smejky | 11:4ca8388080c6 | 1305 | } |
smejky | 11:4ca8388080c6 | 1306 | if((m1_off == 5)&&(m2_off == 10)){ |
smejky | 11:4ca8388080c6 | 1307 | m2_off = 0; |
smejky | 11:4ca8388080c6 | 1308 | m1_off = 0; |
smejky | 11:4ca8388080c6 | 1309 | } |
smejky | 11:4ca8388080c6 | 1310 | if(m2_off == 10){ |
smejky | 11:4ca8388080c6 | 1311 | m2_off = 0; |
smejky | 11:4ca8388080c6 | 1312 | m1_off++; |
smejky | 11:4ca8388080c6 | 1313 | } |
smejky | 11:4ca8388080c6 | 1314 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1315 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1316 | spi.locate(189,80); |
smejky | 11:4ca8388080c6 | 1317 | spi.printf(cisla[m1_off]); |
smejky | 11:4ca8388080c6 | 1318 | spi.locate(219,80); |
smejky | 11:4ca8388080c6 | 1319 | spi.printf(cisla[m2_off]); |
smejky | 11:4ca8388080c6 | 1320 | wait(0.1); |
smejky | 11:4ca8388080c6 | 1321 | } |
smejky | 11:4ca8388080c6 | 1322 | |
smejky | 11:4ca8388080c6 | 1323 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 11:4ca8388080c6 | 1324 | } |
smejky | 11:4ca8388080c6 | 1325 | if((touch_x > down2[1]) && (touch_x < down2[3]) && (touch_y < down2[2]) && (touch_y > down2[0])){ |
smejky | 11:4ca8388080c6 | 1326 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu_s); |
smejky | 11:4ca8388080c6 | 1327 | while ((touch.DataAvailable()) && (m2_off < 10)){ |
smejky | 11:4ca8388080c6 | 1328 | m2_off--; |
smejky | 11:4ca8388080c6 | 1329 | if((m2_off < 0)&&(m1_off == 0)){ |
smejky | 11:4ca8388080c6 | 1330 | m2_off = 9; |
smejky | 11:4ca8388080c6 | 1331 | m1_off = 5; |
smejky | 11:4ca8388080c6 | 1332 | } |
smejky | 11:4ca8388080c6 | 1333 | if(m2_off < 0){ |
smejky | 11:4ca8388080c6 | 1334 | m2_off = 9; |
smejky | 11:4ca8388080c6 | 1335 | m1_off--; |
smejky | 11:4ca8388080c6 | 1336 | } |
smejky | 11:4ca8388080c6 | 1337 | cas_minuty_off--; |
smejky | 11:4ca8388080c6 | 1338 | if(cas_minuty_off < 0){ |
smejky | 11:4ca8388080c6 | 1339 | cas_minuty_off = 59; |
smejky | 11:4ca8388080c6 | 1340 | } |
smejky | 11:4ca8388080c6 | 1341 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 11:4ca8388080c6 | 1342 | spi.background(MojeSeda); |
smejky | 11:4ca8388080c6 | 1343 | spi.locate(189,80); |
smejky | 11:4ca8388080c6 | 1344 | spi.printf(cisla[m1_off]); |
smejky | 11:4ca8388080c6 | 1345 | spi.locate(219,80); |
smejky | 11:4ca8388080c6 | 1346 | spi.printf(cisla[m2_off]); |
smejky | 11:4ca8388080c6 | 1347 | wait(0.1); |
smejky | 11:4ca8388080c6 | 1348 | } |
smejky | 11:4ca8388080c6 | 1349 | |
smejky | 11:4ca8388080c6 | 1350 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 11:4ca8388080c6 | 1351 | } |
smejky | 11:4ca8388080c6 | 1352 | |
smejky | 11:4ca8388080c6 | 1353 | } |
smejky | 11:4ca8388080c6 | 1354 | |
smejky | 11:4ca8388080c6 | 1355 | |
smejky | 11:4ca8388080c6 | 1356 | } |
smejky | 11:4ca8388080c6 | 1357 | } |
smejky | 11:4ca8388080c6 | 1358 | } |
smejky | 11:4ca8388080c6 | 1359 | } |
smejky | 10:0176705be216 | 1360 | |
smejky | 10:0176705be216 | 1361 | void nastavit_hodiny(){ |
smejky | 10:0176705be216 | 1362 | int pravy[] = {34,0,165,46}; //pravý čudlík |
smejky | 10:0176705be216 | 1363 | int levy[] = {34,274,165,320}; //levý čudlík |
smejky | 10:0176705be216 | 1364 | |
smejky | 10:0176705be216 | 1365 | int up1[] = {172,28,258,57}; |
smejky | 10:0176705be216 | 1366 | int down1[] = {172,142,258,171}; |
smejky | 10:0176705be216 | 1367 | |
smejky | 10:0176705be216 | 1368 | int up2[] = {62,28,148,57}; |
smejky | 10:0176705be216 | 1369 | int down2[] = {62,142,148,171}; |
smejky | 10:0176705be216 | 1370 | |
smejky | 10:0176705be216 | 1371 | cas_hodiny = atoi(hodinka); |
smejky | 10:0176705be216 | 1372 | cas_minuty = atoi(minutka); |
smejky | 10:0176705be216 | 1373 | |
smejky | 10:0176705be216 | 1374 | |
smejky | 10:0176705be216 | 1375 | int h1 = cas_hodiny / 10; |
smejky | 10:0176705be216 | 1376 | int h2 = cas_hodiny % 10; |
smejky | 10:0176705be216 | 1377 | |
smejky | 10:0176705be216 | 1378 | char cisla[10][3] = { |
smejky | 10:0176705be216 | 1379 | "0", |
smejky | 10:0176705be216 | 1380 | "1", |
smejky | 10:0176705be216 | 1381 | "2", |
smejky | 10:0176705be216 | 1382 | "3", |
smejky | 10:0176705be216 | 1383 | "4", |
smejky | 10:0176705be216 | 1384 | "5", |
smejky | 10:0176705be216 | 1385 | "6", |
smejky | 10:0176705be216 | 1386 | "7", |
smejky | 10:0176705be216 | 1387 | "8", |
smejky | 10:0176705be216 | 1388 | "9" |
smejky | 10:0176705be216 | 1389 | }; |
smejky | 10:0176705be216 | 1390 | |
smejky | 10:0176705be216 | 1391 | int m1 = cas_minuty / 10; |
smejky | 10:0176705be216 | 1392 | int m2 = cas_minuty % 10; |
smejky | 10:0176705be216 | 1393 | |
smejky | 10:0176705be216 | 1394 | int blue1[] = {71,65,249,134}; |
smejky | 10:0176705be216 | 1395 | |
smejky | 10:0176705be216 | 1396 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 10:0176705be216 | 1397 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 10:0176705be216 | 1398 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 10:0176705be216 | 1399 | |
smejky | 10:0176705be216 | 1400 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 10:0176705be216 | 1401 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 10:0176705be216 | 1402 | |
smejky | 10:0176705be216 | 1403 | |
smejky | 10:0176705be216 | 1404 | |
smejky | 10:0176705be216 | 1405 | spi.fillrect(blue1[0],blue1[1],blue1[2],blue1[3],MojeSeda); |
smejky | 10:0176705be216 | 1406 | |
smejky | 10:0176705be216 | 1407 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 10:0176705be216 | 1408 | spi.background(MojeSeda); |
smejky | 10:0176705be216 | 1409 | spi.locate(80,80); |
smejky | 10:0176705be216 | 1410 | spi.printf(cisla[h1]); |
smejky | 10:0176705be216 | 1411 | spi.locate(110,80); |
smejky | 10:0176705be216 | 1412 | spi.printf(cisla[h2]); |
smejky | 10:0176705be216 | 1413 | spi.locate(155,80); |
smejky | 10:0176705be216 | 1414 | spi.printf(":"); |
smejky | 10:0176705be216 | 1415 | spi.locate(189,80); |
smejky | 10:0176705be216 | 1416 | spi.printf(cisla[m1]); |
smejky | 10:0176705be216 | 1417 | spi.locate(219,80); |
smejky | 10:0176705be216 | 1418 | spi.printf(cisla[m2]); |
smejky | 10:0176705be216 | 1419 | |
smejky | 10:0176705be216 | 1420 | |
smejky | 10:0176705be216 | 1421 | while(1){ |
smejky | 10:0176705be216 | 1422 | if (touch.DataAvailable()) |
smejky | 10:0176705be216 | 1423 | { |
smejky | 10:0176705be216 | 1424 | if(touch.Read()) |
smejky | 10:0176705be216 | 1425 | { |
smejky | 10:0176705be216 | 1426 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 10:0176705be216 | 1427 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 10:0176705be216 | 1428 | |
smejky | 10:0176705be216 | 1429 | //pravý čudlik |
smejky | 10:0176705be216 | 1430 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 10:0176705be216 | 1431 | |
smejky | 10:0176705be216 | 1432 | //GRAFIKA************************************************** |
smejky | 10:0176705be216 | 1433 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 10:0176705be216 | 1434 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit_s); |
smejky | 10:0176705be216 | 1435 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 10:0176705be216 | 1436 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 10:0176705be216 | 1437 | //GRAFIKA************************************************** |
smejky | 10:0176705be216 | 1438 | hold(); |
smejky | 11:4ca8388080c6 | 1439 | thread_h.terminate(); |
smejky | 10:0176705be216 | 1440 | cas_nastavit = 1037059200 + (cas_hodiny * 3600) + (cas_minuty * 60); |
smejky | 11:4ca8388080c6 | 1441 | thread_h.start(hodiny); |
smejky | 10:0176705be216 | 1442 | grafika(9); |
smejky | 10:0176705be216 | 1443 | nastaveni(); |
smejky | 10:0176705be216 | 1444 | wait(0.2); |
smejky | 10:0176705be216 | 1445 | } |
smejky | 10:0176705be216 | 1446 | //pravý čudlik |
smejky | 10:0176705be216 | 1447 | |
smejky | 10:0176705be216 | 1448 | //levý čudlik |
smejky | 10:0176705be216 | 1449 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 10:0176705be216 | 1450 | //GRAFIKA************************************************** |
smejky | 10:0176705be216 | 1451 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 10:0176705be216 | 1452 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit_s);// levy |
smejky | 10:0176705be216 | 1453 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 10:0176705be216 | 1454 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 10:0176705be216 | 1455 | //GRAFIKA************************************************** |
smejky | 10:0176705be216 | 1456 | |
smejky | 10:0176705be216 | 1457 | hold(); |
smejky | 10:0176705be216 | 1458 | |
smejky | 10:0176705be216 | 1459 | |
smejky | 10:0176705be216 | 1460 | |
smejky | 10:0176705be216 | 1461 | grafika(7); |
smejky | 10:0176705be216 | 1462 | nastaveni(); |
smejky | 10:0176705be216 | 1463 | wait(0.2); |
smejky | 10:0176705be216 | 1464 | } |
smejky | 10:0176705be216 | 1465 | //levý čudlik |
smejky | 10:0176705be216 | 1466 | if((touch_x > up1[1]) && (touch_x < up1[3]) && (touch_y < up1[2]) && (touch_y > up1[0])){ |
smejky | 10:0176705be216 | 1467 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru_s); |
smejky | 10:0176705be216 | 1468 | while ((touch.DataAvailable()) && (h2 < 10)){ |
smejky | 10:0176705be216 | 1469 | h2++; |
smejky | 10:0176705be216 | 1470 | cas_hodiny++; |
smejky | 10:0176705be216 | 1471 | if(cas_hodiny == 24){ |
smejky | 10:0176705be216 | 1472 | cas_hodiny = 0; |
smejky | 10:0176705be216 | 1473 | } |
smejky | 10:0176705be216 | 1474 | if(h2 == 10){ |
smejky | 10:0176705be216 | 1475 | h2 = 0; |
smejky | 10:0176705be216 | 1476 | h1++; |
smejky | 10:0176705be216 | 1477 | } |
smejky | 10:0176705be216 | 1478 | if((h1 == 2)&&(h2 == 4)){ |
smejky | 10:0176705be216 | 1479 | h2 = 0; |
smejky | 10:0176705be216 | 1480 | h1 = 0; |
smejky | 10:0176705be216 | 1481 | } |
smejky | 10:0176705be216 | 1482 | |
smejky | 10:0176705be216 | 1483 | spi.locate(80,80); |
smejky | 10:0176705be216 | 1484 | spi.printf(cisla[h1]); |
smejky | 10:0176705be216 | 1485 | spi.locate(110,80); |
smejky | 10:0176705be216 | 1486 | spi.printf(cisla[h2]); |
smejky | 10:0176705be216 | 1487 | |
smejky | 10:0176705be216 | 1488 | |
smejky | 10:0176705be216 | 1489 | wait(0.1); |
smejky | 10:0176705be216 | 1490 | } |
smejky | 10:0176705be216 | 1491 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 10:0176705be216 | 1492 | } |
smejky | 10:0176705be216 | 1493 | if((touch_x > down1[1]) && (touch_x < down1[3]) && (touch_y < down1[2]) && (touch_y > down1[0])){ |
smejky | 10:0176705be216 | 1494 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu_s); |
smejky | 10:0176705be216 | 1495 | while ((touch.DataAvailable()) && (h2 < 10)){ |
smejky | 10:0176705be216 | 1496 | h2--; |
smejky | 10:0176705be216 | 1497 | if((h2 < 0)&&(h1 == 0)){ |
smejky | 10:0176705be216 | 1498 | h2 = 3; |
smejky | 10:0176705be216 | 1499 | h1 = 2; |
smejky | 10:0176705be216 | 1500 | } |
smejky | 10:0176705be216 | 1501 | if(h2 < 0){ |
smejky | 10:0176705be216 | 1502 | h2 = 9; |
smejky | 10:0176705be216 | 1503 | h1--; |
smejky | 10:0176705be216 | 1504 | } |
smejky | 10:0176705be216 | 1505 | cas_hodiny--; |
smejky | 10:0176705be216 | 1506 | if(cas_hodiny < 0){ |
smejky | 10:0176705be216 | 1507 | cas_hodiny = 23; |
smejky | 10:0176705be216 | 1508 | } |
smejky | 10:0176705be216 | 1509 | spi.locate(80,80); |
smejky | 10:0176705be216 | 1510 | spi.printf(cisla[h1]); |
smejky | 10:0176705be216 | 1511 | spi.locate(110,80); |
smejky | 10:0176705be216 | 1512 | spi.printf(cisla[h2]); |
smejky | 10:0176705be216 | 1513 | wait(0.1); |
smejky | 10:0176705be216 | 1514 | } |
smejky | 10:0176705be216 | 1515 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 10:0176705be216 | 1516 | } |
smejky | 10:0176705be216 | 1517 | if((touch_x > up2[1]) && (touch_x < up2[3]) && (touch_y < up2[2]) && (touch_y > up2[0])){ |
smejky | 10:0176705be216 | 1518 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru_s); |
smejky | 10:0176705be216 | 1519 | while ((touch.DataAvailable()) && (m2 < 10)){ |
smejky | 10:0176705be216 | 1520 | m2++; |
smejky | 10:0176705be216 | 1521 | cas_minuty++; |
smejky | 10:0176705be216 | 1522 | if(cas_minuty == 60){ |
smejky | 10:0176705be216 | 1523 | cas_minuty = 0; |
smejky | 10:0176705be216 | 1524 | } |
smejky | 10:0176705be216 | 1525 | if((m1 == 5)&&(m2 == 10)){ |
smejky | 10:0176705be216 | 1526 | m2 = 0; |
smejky | 10:0176705be216 | 1527 | m1 = 0; |
smejky | 10:0176705be216 | 1528 | } |
smejky | 10:0176705be216 | 1529 | if(m2 == 10){ |
smejky | 10:0176705be216 | 1530 | m2 = 0; |
smejky | 10:0176705be216 | 1531 | m1++; |
smejky | 10:0176705be216 | 1532 | } |
smejky | 10:0176705be216 | 1533 | |
smejky | 10:0176705be216 | 1534 | spi.locate(189,80); |
smejky | 10:0176705be216 | 1535 | spi.printf(cisla[m1]); |
smejky | 10:0176705be216 | 1536 | spi.locate(219,80); |
smejky | 10:0176705be216 | 1537 | spi.printf(cisla[m2]); |
smejky | 10:0176705be216 | 1538 | wait(0.1); |
smejky | 10:0176705be216 | 1539 | } |
smejky | 10:0176705be216 | 1540 | |
smejky | 10:0176705be216 | 1541 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 10:0176705be216 | 1542 | } |
smejky | 10:0176705be216 | 1543 | if((touch_x > down2[1]) && (touch_x < down2[3]) && (touch_y < down2[2]) && (touch_y > down2[0])){ |
smejky | 10:0176705be216 | 1544 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu_s); |
smejky | 10:0176705be216 | 1545 | while ((touch.DataAvailable()) && (m2 < 10)){ |
smejky | 10:0176705be216 | 1546 | m2--; |
smejky | 10:0176705be216 | 1547 | if((m2 < 0)&&(m1 == 0)){ |
smejky | 10:0176705be216 | 1548 | m2 = 9; |
smejky | 10:0176705be216 | 1549 | m1 = 5; |
smejky | 10:0176705be216 | 1550 | } |
smejky | 10:0176705be216 | 1551 | if(m2 < 0){ |
smejky | 10:0176705be216 | 1552 | m2 = 9; |
smejky | 10:0176705be216 | 1553 | m1--; |
smejky | 10:0176705be216 | 1554 | } |
smejky | 10:0176705be216 | 1555 | cas_minuty--; |
smejky | 10:0176705be216 | 1556 | if(cas_minuty < 0){ |
smejky | 10:0176705be216 | 1557 | cas_minuty = 59; |
smejky | 10:0176705be216 | 1558 | } |
smejky | 10:0176705be216 | 1559 | spi.locate(189,80); |
smejky | 10:0176705be216 | 1560 | spi.printf(cisla[m1]); |
smejky | 10:0176705be216 | 1561 | spi.locate(219,80); |
smejky | 10:0176705be216 | 1562 | spi.printf(cisla[m2]); |
smejky | 10:0176705be216 | 1563 | wait(0.1); |
smejky | 10:0176705be216 | 1564 | } |
smejky | 10:0176705be216 | 1565 | |
smejky | 10:0176705be216 | 1566 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 10:0176705be216 | 1567 | } |
smejky | 10:0176705be216 | 1568 | |
smejky | 9:d1385f7171af | 1569 | |
smejky | 9:d1385f7171af | 1570 | } |
smejky | 9:d1385f7171af | 1571 | } |
smejky | 9:d1385f7171af | 1572 | } |
smejky | 9:d1385f7171af | 1573 | } |
smejky | 9:d1385f7171af | 1574 | |
smejky | 9:d1385f7171af | 1575 | |
smejky | 10:0176705be216 | 1576 | |
smejky | 10:0176705be216 | 1577 | |
smejky | 8:b6e7401fdcfc | 1578 | void hodiny(){ |
smejky | 9:d1385f7171af | 1579 | set_time(cas_nastavit); |
smejky | 8:b6e7401fdcfc | 1580 | while(1){ |
smejky | 8:b6e7401fdcfc | 1581 | time_t seconds = time(NULL); |
smejky | 9:d1385f7171af | 1582 | //seconds = seconds + 7200; |
smejky | 10:0176705be216 | 1583 | if(seconds == time_on){ |
smejky | 10:0176705be216 | 1584 | printf("ON\r\n"); |
smejky | 10:0176705be216 | 1585 | } |
smejky | 10:0176705be216 | 1586 | if(seconds == time_off){ |
smejky | 10:0176705be216 | 1587 | printf("OFF\r\n"); |
smejky | 10:0176705be216 | 1588 | } |
smejky | 8:b6e7401fdcfc | 1589 | strftime(buffer, 32, "%R", localtime(&seconds)); |
smejky | 10:0176705be216 | 1590 | strftime(hodinka, 32, "%H", localtime(&seconds)); |
smejky | 10:0176705be216 | 1591 | strftime(minutka, 32, "%M", localtime(&seconds)); |
smejky | 10:0176705be216 | 1592 | printf("%s\r\n",buffer); |
smejky | 9:d1385f7171af | 1593 | Thread::wait(1000); |
smejky | 8:b6e7401fdcfc | 1594 | } |
smejky | 8:b6e7401fdcfc | 1595 | } |
smejky | 7:91b982ccf255 | 1596 | |
smejky | 0:6abf63b83992 | 1597 | main(){ |
smejky | 11:4ca8388080c6 | 1598 | r.period_us(1000); |
smejky | 11:4ca8388080c6 | 1599 | g.period_us(1000); |
smejky | 11:4ca8388080c6 | 1600 | b.period_us(1000); |
smejky | 9:d1385f7171af | 1601 | |
smejky | 8:b6e7401fdcfc | 1602 | my_red = 1; |
smejky | 8:b6e7401fdcfc | 1603 | my_green = 1; |
smejky | 8:b6e7401fdcfc | 1604 | my_blue = 1; |
smejky | 9:d1385f7171af | 1605 | spi.set_orientation(3); |
smejky | 3:dadb214885c1 | 1606 | spi.FastWindow(true); |
smejky | 0:6abf63b83992 | 1607 | touch.InitTouch(); |
smejky | 0:6abf63b83992 | 1608 | touch.SetPrecision(PREC_EXTREME); |
smejky | 8:b6e7401fdcfc | 1609 | spi.background(Black); |
smejky | 8:b6e7401fdcfc | 1610 | spi.foreground(White); |
smejky | 3:dadb214885c1 | 1611 | spi.cls(); |
smejky | 11:4ca8388080c6 | 1612 | send_color(255,20,147,100); |
smejky | 8:b6e7401fdcfc | 1613 | |
smejky | 3:dadb214885c1 | 1614 | grafika(); |
smejky | 9:d1385f7171af | 1615 | |
smejky | 9:d1385f7171af | 1616 | br.period_us(1000); |
smejky | 10:0176705be216 | 1617 | br.write(lcd_jas); |
smejky | 10:0176705be216 | 1618 | |
smejky | 3:dadb214885c1 | 1619 | Button(); |
smejky | 8:b6e7401fdcfc | 1620 | |
smejky | 2:0629f1ddaa92 | 1621 | |
smejky | 0:6abf63b83992 | 1622 | } |
smejky | 4:c7ca936cdd1f | 1623 | |
smejky | 4:c7ca936cdd1f | 1624 | |
smejky | 4:c7ca936cdd1f | 1625 | |
smejky | 4:c7ca936cdd1f | 1626 | |
smejky | 4:c7ca936cdd1f | 1627 | /* fail projekty |
smejky | 4:c7ca936cdd1f | 1628 | //slider |
smejky | 4:c7ca936cdd1f | 1629 | if ((touch_x > cudlik[0]) && (touch_x < cudlik[2]) && (touch_y > cudlik[1]) && (touch_y < cudlik[3]) && (pressure > 0)){ |
smejky | 4:c7ca936cdd1f | 1630 | |
smejky | 4:c7ca936cdd1f | 1631 | |
smejky | 4:c7ca936cdd1f | 1632 | //if je udelany tady pro nastavení minima a maxima |
smejky | 4:c7ca936cdd1f | 1633 | if ((touch_x > 25) && (touch_x < 140)){ |
smejky | 4:c7ca936cdd1f | 1634 | |
smejky | 4:c7ca936cdd1f | 1635 | unsigned short int y0 = cudlik[1]; |
smejky | 4:c7ca936cdd1f | 1636 | unsigned short int y1 = cudlik[3]; |
smejky | 4:c7ca936cdd1f | 1637 | unsigned short int x_zadelavani_chyby = cudlik[0]; |
smejky | 4:c7ca936cdd1f | 1638 | unsigned short int x0 = x_zadelavani_chyby - 8; |
smejky | 4:c7ca936cdd1f | 1639 | |
smejky | 4:c7ca936cdd1f | 1640 | //printf("%d\r\n",touch_x); |
smejky | 4:c7ca936cdd1f | 1641 | stred_cudliku[0] = touch_x; |
smejky | 4:c7ca936cdd1f | 1642 | |
smejky | 4:c7ca936cdd1f | 1643 | cudlik[0] = stred_cudliku[0] - 10; |
smejky | 4:c7ca936cdd1f | 1644 | cudlik[1] = stred_cudliku[1] - 25; |
smejky | 4:c7ca936cdd1f | 1645 | cudlik[2] = stred_cudliku[0] + 10; |
smejky | 4:c7ca936cdd1f | 1646 | cudlik[3] = stred_cudliku[1] + 25; |
smejky | 4:c7ca936cdd1f | 1647 | |
smejky | 4:c7ca936cdd1f | 1648 | |
smejky | 4:c7ca936cdd1f | 1649 | |
smejky | 4:c7ca936cdd1f | 1650 | if (touch_x > 34){ |
smejky | 4:c7ca936cdd1f | 1651 | x0 = x_zadelavani_chyby + 8; |
smejky | 4:c7ca936cdd1f | 1652 | spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Green); |
smejky | 4:c7ca936cdd1f | 1653 | |
smejky | 4:c7ca936cdd1f | 1654 | }else{ |
smejky | 4:c7ca936cdd1f | 1655 | spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Black); |
smejky | 4:c7ca936cdd1f | 1656 | } |
smejky | 4:c7ca936cdd1f | 1657 | |
smejky | 4:c7ca936cdd1f | 1658 | if (touch_x < 34){ |
smejky | 4:c7ca936cdd1f | 1659 | spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Black); |
smejky | 4:c7ca936cdd1f | 1660 | |
smejky | 4:c7ca936cdd1f | 1661 | }else{ |
smejky | 4:c7ca936cdd1f | 1662 | x0 = x_zadelavani_chyby + 8; |
smejky | 4:c7ca936cdd1f | 1663 | spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Green); |
smejky | 4:c7ca936cdd1f | 1664 | } |
smejky | 4:c7ca936cdd1f | 1665 | spi.fillrect(cudlik[0],cudlik[1],cudlik[2],cudlik[3],cudlik[4]); |
smejky | 4:c7ca936cdd1f | 1666 | |
smejky | 4:c7ca936cdd1f | 1667 | |
smejky | 4:c7ca936cdd1f | 1668 | |
smejky | 4:c7ca936cdd1f | 1669 | } |
smejky | 4:c7ca936cdd1f | 1670 | } |
smejky | 4:c7ca936cdd1f | 1671 | |
smejky | 4:c7ca936cdd1f | 1672 | //slider */ |
smejky | 4:c7ca936cdd1f | 1673 | |
smejky | 4:c7ca936cdd1f | 1674 |