Toto je má konečná verze maturitního projektu
Dependencies: mbed mbed-rtos UTouch_vyrobek UniGraphic
display.cpp@10:0176705be216, 2022-01-16 (annotated)
- Committer:
- smejky
- Date:
- Sun Jan 16 12:06:03 2022 +0000
- Revision:
- 10:0176705be216
- Parent:
- 9:d1385f7171af
- Child:
- 11:4ca8388080c6
pridane nastaveni casu ktere funguje
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
smejky | 7:91b982ccf255 | 1 | #include "display.h" |
smejky | 7:91b982ccf255 | 2 | #include "rtos.h" |
smejky | 8:b6e7401fdcfc | 3 | |
smejky | 9:d1385f7171af | 4 | UTouch touch(D4,D9,D3,D2,D5);//clk,chip_select,MOSI,miso,irq |
smejky | 0:6abf63b83992 | 5 | ILI9341 spi(SPI_8,320000000,PTD2,PTD3,PTD1,PTC12, PTC3, PTC2, "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 | 10:0176705be216 | 11 | PwmOut br(D10); |
smejky | 9:d1385f7171af | 12 | |
smejky | 10:0176705be216 | 13 | float lcd_jas = 0.50f; |
smejky | 10:0176705be216 | 14 | int jas[] = {Green,Red}; |
smejky | 10:0176705be216 | 15 | int jas_s = 2; |
smejky | 10:0176705be216 | 16 | int jazyk_s = 0; |
smejky | 10:0176705be216 | 17 | int cas_hodiny = 0; |
smejky | 10:0176705be216 | 18 | int cas_minuty = 0; |
smejky | 9:d1385f7171af | 19 | int cas_nastavit = 1037059200; |
smejky | 10:0176705be216 | 20 | int time_on = 1037074920; |
smejky | 10:0176705be216 | 21 | int time_off = 1037075100; |
smejky | 9:d1385f7171af | 22 | int lang = 0; |
smejky | 10:0176705be216 | 23 | char minutka[32]; |
smejky | 10:0176705be216 | 24 | char hodinka[32]; |
smejky | 9:d1385f7171af | 25 | char buffer[32]; |
smejky | 10:0176705be216 | 26 | char jazyk [4][150] = { |
smejky | 9:d1385f7171af | 27 | "Czech", |
smejky | 9:d1385f7171af | 28 | "English", |
smejky | 10:0176705be216 | 29 | " Set Time", |
smejky | 10:0176705be216 | 30 | "Brightness" |
smejky | 9:d1385f7171af | 31 | }; |
smejky | 10:0176705be216 | 32 | char en[4][150] = { |
smejky | 9:d1385f7171af | 33 | "Czech", |
smejky | 9:d1385f7171af | 34 | "English", |
smejky | 10:0176705be216 | 35 | " Set Time", |
smejky | 10:0176705be216 | 36 | "Brightness" |
smejky | 9:d1385f7171af | 37 | }; |
smejky | 10:0176705be216 | 38 | char cz[4][150] = { |
smejky | 9:d1385f7171af | 39 | "Cestina", |
smejky | 9:d1385f7171af | 40 | "Anglictina", |
smejky | 10:0176705be216 | 41 | "Nastavit cas", |
smejky | 10:0176705be216 | 42 | " Jas" |
smejky | 9:d1385f7171af | 43 | }; |
smejky | 9:d1385f7171af | 44 | |
smejky | 9:d1385f7171af | 45 | |
smejky | 9:d1385f7171af | 46 | |
smejky | 9:d1385f7171af | 47 | void hold(){ |
smejky | 9:d1385f7171af | 48 | int i = touch.DataAvailable(); |
smejky | 9:d1385f7171af | 49 | while (i){ |
smejky | 9:d1385f7171af | 50 | i = touch.DataAvailable(); |
smejky | 9:d1385f7171af | 51 | } |
smejky | 9:d1385f7171af | 52 | |
smejky | 9:d1385f7171af | 53 | } |
smejky | 9:d1385f7171af | 54 | |
smejky | 3:dadb214885c1 | 55 | |
smejky | 7:91b982ccf255 | 56 | void led2_thread() |
smejky | 7:91b982ccf255 | 57 | { |
smejky | 7:91b982ccf255 | 58 | while (true) { |
smejky | 7:91b982ccf255 | 59 | led2 = !led2; |
smejky | 7:91b982ccf255 | 60 | Thread::wait(1000); |
smejky | 7:91b982ccf255 | 61 | } |
smejky | 7:91b982ccf255 | 62 | } |
smejky | 0:6abf63b83992 | 63 | |
smejky | 0:6abf63b83992 | 64 | |
smejky | 0:6abf63b83992 | 65 | /* |
smejky | 0:6abf63b83992 | 66 | v ILI9341.cpp zmeneny framerate ze 70 na 100, toto pomohlo problemu blikání displeje |
smejky | 3:dadb214885c1 | 67 | velikost fotky pro čudlik 180x70 |
smejky | 3:dadb214885c1 | 68 | 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 | 69 | |
smejky | 10:0176705be216 | 70 | 4x doprava jas pro cudliky v menu |
smejky | 10:0176705be216 | 71 | |
smejky | 10:0176705be216 | 72 | |
smejky | 0:6abf63b83992 | 73 | */ |
smejky | 0:6abf63b83992 | 74 | |
smejky | 7:91b982ccf255 | 75 | |
smejky | 8:b6e7401fdcfc | 76 | void grafika(unsigned short int press = 0){ |
smejky | 9:d1385f7171af | 77 | int spodni_pravy[] = {239,200,320,240,Black}; |
smejky | 5:7c757a7c97c5 | 78 | |
smejky | 4:c7ca936cdd1f | 79 | |
smejky | 2:0629f1ddaa92 | 80 | switch(press) |
smejky | 2:0629f1ddaa92 | 81 | { |
smejky | 2:0629f1ddaa92 | 82 | case 1: |
smejky | 9:d1385f7171af | 83 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 9:d1385f7171af | 84 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_cudlik_otoc); // pravy |
smejky | 9:d1385f7171af | 85 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 86 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek); //pravy |
smejky | 7:91b982ccf255 | 87 | |
smejky | 2:0629f1ddaa92 | 88 | break; |
smejky | 4:c7ca936cdd1f | 89 | case 2: |
smejky | 9:d1385f7171af | 90 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 9:d1385f7171af | 91 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_cudlik);// levy |
smejky | 9:d1385f7171af | 92 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 93 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 94 | break; |
smejky | 9:d1385f7171af | 95 | case 7: //zrusit |
smejky | 9:d1385f7171af | 96 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 10:0176705be216 | 97 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit); |
smejky | 9:d1385f7171af | 98 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 99 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 100 | break; |
smejky | 9:d1385f7171af | 101 | case 9: //potvrdit |
smejky | 9:d1385f7171af | 102 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 10:0176705be216 | 103 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit); |
smejky | 9:d1385f7171af | 104 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 10:0176705be216 | 105 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek); |
smejky | 4:c7ca936cdd1f | 106 | break; |
smejky | 4:c7ca936cdd1f | 107 | case 3: |
smejky | 9:d1385f7171af | 108 | spi.Bitmap(0,200,80,40,(unsigned char*)gImage_spodni_levy); |
smejky | 2:0629f1ddaa92 | 109 | break; |
smejky | 4:c7ca936cdd1f | 110 | case 4: |
smejky | 9:d1385f7171af | 111 | spi.Bitmap(80,200,80,40,(unsigned char*)gImage_stredni_levy); |
smejky | 4:c7ca936cdd1f | 112 | break; |
smejky | 4:c7ca936cdd1f | 113 | case 5: |
smejky | 9:d1385f7171af | 114 | spi.Bitmap(160,200,80,40,(unsigned char*)gImage_stredni_pravy); |
smejky | 4:c7ca936cdd1f | 115 | break; |
smejky | 4:c7ca936cdd1f | 116 | case 6: |
smejky | 4:c7ca936cdd1f | 117 | spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]); //pravy kraj spodni |
smejky | 4:c7ca936cdd1f | 118 | break; |
smejky | 9:d1385f7171af | 119 | case 8: |
smejky | 9:d1385f7171af | 120 | spi.Bitmap(0,200,80,40,(unsigned char*)gImage_spodni_levy); |
smejky | 9:d1385f7171af | 121 | break; |
smejky | 4:c7ca936cdd1f | 122 | |
smejky | 4:c7ca936cdd1f | 123 | default: |
smejky | 9:d1385f7171af | 124 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 7:91b982ccf255 | 125 | |
smejky | 9:d1385f7171af | 126 | spi.Bitmap(274,0,46,36,(unsigned char*)gImage_vypln);//pravy |
smejky | 9:d1385f7171af | 127 | spi.Bitmap(274,165,46,36,(unsigned char*)gImage_vypln);//pravy |
smejky | 9:d1385f7171af | 128 | spi.Bitmap(0,0,46,36,(unsigned char*)gImage_vypln);//levy |
smejky | 9:d1385f7171af | 129 | spi.Bitmap(0,165,46,36,(unsigned char*)gImage_vypln);//levy |
smejky | 7:91b982ccf255 | 130 | |
smejky | 9:d1385f7171af | 131 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 9:d1385f7171af | 132 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_cudlik_otoc); // pravy |
smejky | 9:d1385f7171af | 133 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 134 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek); //pravy |
smejky | 7:91b982ccf255 | 135 | |
smejky | 9:d1385f7171af | 136 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch); |
smejky | 9:d1385f7171af | 137 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_cudlik);// levy |
smejky | 9:d1385f7171af | 138 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 139 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek); |
smejky | 9:d1385f7171af | 140 | |
smejky | 8:b6e7401fdcfc | 141 | |
smejky | 9:d1385f7171af | 142 | //spi.Bitmap(160,200,80,40,(unsigned char*)gImage_stredni_levy); |
smejky | 9:d1385f7171af | 143 | spi.Bitmap(0,200,80,40,(unsigned char*)gImage_spodni_levy); |
smejky | 9:d1385f7171af | 144 | spi.Bitmap(80,200,80,40,(unsigned char*)gImage_stredni_levy); |
smejky | 9:d1385f7171af | 145 | spi.Bitmap(160,200,80,40,(unsigned char*)gImage_stredni_pravy); //stred pravy spodni |
smejky | 4:c7ca936cdd1f | 146 | spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]); //pravy kraj spodni |
smejky | 2:0629f1ddaa92 | 147 | } |
smejky | 2:0629f1ddaa92 | 148 | } |
smejky | 2:0629f1ddaa92 | 149 | |
smejky | 2:0629f1ddaa92 | 150 | void malovani(){ |
smejky | 2:0629f1ddaa92 | 151 | |
smejky | 1:4dd546219e30 | 152 | while(1==1) |
smejky | 1:4dd546219e30 | 153 | { |
smejky | 0:6abf63b83992 | 154 | if (touch.DataAvailable()) |
smejky | 0:6abf63b83992 | 155 | { |
smejky | 0:6abf63b83992 | 156 | if(touch.Read()) |
smejky | 0:6abf63b83992 | 157 | { |
smejky | 0:6abf63b83992 | 158 | unsigned short int touch_y = touch.GetX(); |
smejky | 1:4dd546219e30 | 159 | unsigned short int touch_x = touch.GetY(); |
smejky | 0:6abf63b83992 | 160 | touch_x = touch_x - 10; |
smejky | 2:0629f1ddaa92 | 161 | touch_y = touch_y + 10; |
smejky | 2:0629f1ddaa92 | 162 | spi.pixel(touch_x,touch_y,Blue); |
smejky | 2:0629f1ddaa92 | 163 | } |
smejky | 2:0629f1ddaa92 | 164 | } |
smejky | 2:0629f1ddaa92 | 165 | } |
smejky | 2:0629f1ddaa92 | 166 | } |
smejky | 2:0629f1ddaa92 | 167 | |
smejky | 5:7c757a7c97c5 | 168 | /* |
smejky | 5:7c757a7c97c5 | 169 | else if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy [1])){ |
smejky | 5:7c757a7c97c5 | 170 | R_is_pressed = 1; |
smejky | 5:7c757a7c97c5 | 171 | spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]); |
smejky | 5:7c757a7c97c5 | 172 | wait(0.1); |
smejky | 5:7c757a7c97c5 | 173 | } |
smejky | 5:7c757a7c97c5 | 174 | |
smejky | 5:7c757a7c97c5 | 175 | */ |
smejky | 5:7c757a7c97c5 | 176 | |
smejky | 5:7c757a7c97c5 | 177 | |
smejky | 5:7c757a7c97c5 | 178 | |
smejky | 7:91b982ccf255 | 179 | |
smejky | 7:91b982ccf255 | 180 | |
smejky | 7:91b982ccf255 | 181 | void Button(int strana = 0){ |
smejky | 7:91b982ccf255 | 182 | int pravy[] = {34,0,165,46}; //pravý čudlík |
smejky | 9:d1385f7171af | 183 | int levy[] = {34,274,165,320}; //levý čudlík |
smejky | 4:c7ca936cdd1f | 184 | //int cudlik[] = {20,80,42,130,Orange}; //slider nepovedeny projekt |
smejky | 4:c7ca936cdd1f | 185 | //int stred_cudliku[] = {30,105,Blue}; //střed čudliku |
smejky | 9:d1385f7171af | 186 | int spodni_levy[] = {200,240,240,320}; // levy spodni cudlik |
smejky | 9:d1385f7171af | 187 | int stredni_levy[] = {200,160,240,239}; //stred levy spodni cudlik |
smejky | 9:d1385f7171af | 188 | int stredni_pravy[] = {200,80,240,158}; //stred pravy spodni cudlik |
smejky | 9:d1385f7171af | 189 | int spodni_pravy[] = {200,0,240,77}; // pravy spodni cudlik |
smejky | 7:91b982ccf255 | 190 | |
smejky | 7:91b982ccf255 | 191 | int cudlik_1[] = {10,213,58,260}; |
smejky | 8:b6e7401fdcfc | 192 | int cudlik_2[] = {10,137,58,184}; |
smejky | 8:b6e7401fdcfc | 193 | |
smejky | 8:b6e7401fdcfc | 194 | |
smejky | 7:91b982ccf255 | 195 | |
smejky | 7:91b982ccf255 | 196 | |
smejky | 9:d1385f7171af | 197 | |
smejky | 3:dadb214885c1 | 198 | while(1) |
smejky | 2:0629f1ddaa92 | 199 | { |
smejky | 2:0629f1ddaa92 | 200 | if (touch.DataAvailable()) |
smejky | 2:0629f1ddaa92 | 201 | { |
smejky | 2:0629f1ddaa92 | 202 | if(touch.Read()) |
smejky | 2:0629f1ddaa92 | 203 | { |
smejky | 5:7c757a7c97c5 | 204 | |
smejky | 5:7c757a7c97c5 | 205 | |
smejky | 3:dadb214885c1 | 206 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 3:dadb214885c1 | 207 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 3:dadb214885c1 | 208 | touch_x = touch_x - 5; |
smejky | 2:0629f1ddaa92 | 209 | touch_y = touch_y + 10; |
smejky | 3:dadb214885c1 | 210 | //spi.pixel(touch_x,touch_y,Blue); |
smejky | 5:7c757a7c97c5 | 211 | //printf("x %d ,y %d\r\n",touch_x,touch_y); |
smejky | 3:dadb214885c1 | 212 | |
smejky | 3:dadb214885c1 | 213 | //pravý čudlik |
smejky | 5:7c757a7c97c5 | 214 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 7:91b982ccf255 | 215 | int m = strana; |
smejky | 7:91b982ccf255 | 216 | switch(strana){ |
smejky | 7:91b982ccf255 | 217 | case 0: |
smejky | 7:91b982ccf255 | 218 | m++; |
smejky | 7:91b982ccf255 | 219 | break; |
smejky | 7:91b982ccf255 | 220 | case 1: |
smejky | 7:91b982ccf255 | 221 | m++; |
smejky | 7:91b982ccf255 | 222 | break; |
smejky | 7:91b982ccf255 | 223 | default: |
smejky | 7:91b982ccf255 | 224 | m = 0; |
smejky | 7:91b982ccf255 | 225 | } |
smejky | 7:91b982ccf255 | 226 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 227 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 228 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_cudlik_otoc_s); |
smejky | 9:d1385f7171af | 229 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 230 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 7:91b982ccf255 | 231 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 232 | hold(); |
smejky | 5:7c757a7c97c5 | 233 | grafika(1); |
smejky | 7:91b982ccf255 | 234 | Menu(m); |
smejky | 5:7c757a7c97c5 | 235 | wait(0.2); |
smejky | 5:7c757a7c97c5 | 236 | } |
smejky | 5:7c757a7c97c5 | 237 | |
smejky | 3:dadb214885c1 | 238 | //pravý čudlik |
smejky | 3:dadb214885c1 | 239 | |
smejky | 4:c7ca936cdd1f | 240 | //levý čudlik |
smejky | 5:7c757a7c97c5 | 241 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 7:91b982ccf255 | 242 | int m = strana; |
smejky | 7:91b982ccf255 | 243 | switch(strana){ |
smejky | 7:91b982ccf255 | 244 | case 1: |
smejky | 7:91b982ccf255 | 245 | m--; |
smejky | 7:91b982ccf255 | 246 | break; |
smejky | 7:91b982ccf255 | 247 | default: |
smejky | 8:b6e7401fdcfc | 248 | m = 1; |
smejky | 7:91b982ccf255 | 249 | } |
smejky | 7:91b982ccf255 | 250 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 251 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 252 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_cudlik_s);// levy |
smejky | 9:d1385f7171af | 253 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 254 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 7:91b982ccf255 | 255 | //GRAFIKA************************************************** |
smejky | 7:91b982ccf255 | 256 | |
smejky | 9:d1385f7171af | 257 | hold(); |
smejky | 5:7c757a7c97c5 | 258 | grafika(2); |
smejky | 7:91b982ccf255 | 259 | wait(0.2); |
smejky | 7:91b982ccf255 | 260 | Menu(m); |
smejky | 5:7c757a7c97c5 | 261 | } |
smejky | 3:dadb214885c1 | 262 | //levý čudlik |
smejky | 4:c7ca936cdd1f | 263 | |
smejky | 4:c7ca936cdd1f | 264 | //levý spodni čudlik |
smejky | 5:7c757a7c97c5 | 265 | if ((touch_x > spodni_levy[0]) && (touch_x < spodni_levy[2]) && (touch_y < spodni_levy[3]) && (touch_y > spodni_levy[1])){ |
smejky | 9:d1385f7171af | 266 | spi.Bitmap(0,200,80,40,(unsigned char*)gImage_spodni_levy_s); |
smejky | 9:d1385f7171af | 267 | |
smejky | 9:d1385f7171af | 268 | hold(); |
smejky | 9:d1385f7171af | 269 | |
smejky | 9:d1385f7171af | 270 | grafika(9); |
smejky | 9:d1385f7171af | 271 | grafika(8); |
smejky | 9:d1385f7171af | 272 | grafika(7); |
smejky | 9:d1385f7171af | 273 | nastaveni(); |
smejky | 5:7c757a7c97c5 | 274 | wait(0.2); |
smejky | 5:7c757a7c97c5 | 275 | } |
smejky | 4:c7ca936cdd1f | 276 | //levý spodni čudlik |
smejky | 3:dadb214885c1 | 277 | |
smejky | 4:c7ca936cdd1f | 278 | |
smejky | 4:c7ca936cdd1f | 279 | //stred levy spodni cudlik |
smejky | 5:7c757a7c97c5 | 280 | if ((touch_x > stredni_levy[0]) && (touch_x < stredni_levy[2]) && (touch_y < stredni_levy[3]) && (touch_y > stredni_levy[1])){ |
smejky | 9:d1385f7171af | 281 | |
smejky | 7:91b982ccf255 | 282 | |
smejky | 9:d1385f7171af | 283 | spi.Bitmap(80,200,80,40,(unsigned char*)gImage_stredni_levy_s); |
smejky | 9:d1385f7171af | 284 | |
smejky | 7:91b982ccf255 | 285 | |
smejky | 7:91b982ccf255 | 286 | thread.start(led2_thread); |
smejky | 7:91b982ccf255 | 287 | |
smejky | 9:d1385f7171af | 288 | hold(); |
smejky | 5:7c757a7c97c5 | 289 | grafika(4); |
smejky | 5:7c757a7c97c5 | 290 | wait(0.2); |
smejky | 5:7c757a7c97c5 | 291 | } |
smejky | 4:c7ca936cdd1f | 292 | //stred levy spodni cudlik |
smejky | 4:c7ca936cdd1f | 293 | |
smejky | 4:c7ca936cdd1f | 294 | |
smejky | 4:c7ca936cdd1f | 295 | //stred pravy spodni cudlik |
smejky | 5:7c757a7c97c5 | 296 | if ((touch_x > stredni_pravy[0]) && (touch_x < stredni_pravy[2]) && (touch_y < stredni_pravy[3]) && (touch_y > stredni_pravy[1])){ |
smejky | 9:d1385f7171af | 297 | spi.Bitmap(160,200,80,40,(unsigned char*)gImage_stredni_pravy_s); |
smejky | 7:91b982ccf255 | 298 | |
smejky | 7:91b982ccf255 | 299 | thread.terminate(); |
smejky | 9:d1385f7171af | 300 | hold(); |
smejky | 5:7c757a7c97c5 | 301 | grafika(5); |
smejky | 5:7c757a7c97c5 | 302 | wait(0.2); |
smejky | 5:7c757a7c97c5 | 303 | } |
smejky | 4:c7ca936cdd1f | 304 | //stred pravy spodni cudlik |
smejky | 4:c7ca936cdd1f | 305 | |
smejky | 4:c7ca936cdd1f | 306 | //kraj pravy spodni cudlik |
smejky | 5:7c757a7c97c5 | 307 | if ((touch_x > spodni_pravy[0]) && (touch_x < spodni_pravy[2]) && (touch_y < spodni_pravy[3]) && (touch_y > spodni_pravy[1])){ |
smejky | 9:d1385f7171af | 308 | |
smejky | 9:d1385f7171af | 309 | hold(); |
smejky | 9:d1385f7171af | 310 | |
smejky | 9:d1385f7171af | 311 | spi.locate(255,210); |
smejky | 9:d1385f7171af | 312 | spi.printf("%s",buffer); |
smejky | 9:d1385f7171af | 313 | |
smejky | 9:d1385f7171af | 314 | // grafika(6); |
smejky | 5:7c757a7c97c5 | 315 | wait(0.2); |
smejky | 4:c7ca936cdd1f | 316 | } |
smejky | 4:c7ca936cdd1f | 317 | //kraj pravy spodni cudlik |
smejky | 7:91b982ccf255 | 318 | |
smejky | 7:91b982ccf255 | 319 | //MENU CUDLIKY********************************************************************************************************************************************************************************** |
smejky | 7:91b982ccf255 | 320 | //prvni |
smejky | 8:b6e7401fdcfc | 321 | 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 | 322 | spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1s_vrch); |
smejky | 9:d1385f7171af | 323 | spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1s_spodek); |
smejky | 9:d1385f7171af | 324 | hold(); |
smejky | 9:d1385f7171af | 325 | spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 326 | spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 10:0176705be216 | 327 | wait(0.2); |
smejky | 10:0176705be216 | 328 | grafika(7); |
smejky | 10:0176705be216 | 329 | grafika(9); |
smejky | 8:b6e7401fdcfc | 330 | Static(); |
smejky | 7:91b982ccf255 | 331 | } |
smejky | 7:91b982ccf255 | 332 | |
smejky | 7:91b982ccf255 | 333 | |
smejky | 7:91b982ccf255 | 334 | //prvni |
smejky | 8:b6e7401fdcfc | 335 | //druhy |
smejky | 8:b6e7401fdcfc | 336 | 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 | 337 | spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1s_vrch); |
smejky | 9:d1385f7171af | 338 | spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1s_spodek); |
smejky | 9:d1385f7171af | 339 | hold(); |
smejky | 9:d1385f7171af | 340 | spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 341 | spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 8:b6e7401fdcfc | 342 | wait(0.2); |
smejky | 8:b6e7401fdcfc | 343 | |
smejky | 8:b6e7401fdcfc | 344 | } |
smejky | 8:b6e7401fdcfc | 345 | |
smejky | 8:b6e7401fdcfc | 346 | |
smejky | 8:b6e7401fdcfc | 347 | //druhy |
smejky | 3:dadb214885c1 | 348 | |
smejky | 1:4dd546219e30 | 349 | } |
smejky | 1:4dd546219e30 | 350 | } |
smejky | 1:4dd546219e30 | 351 | } |
smejky | 1:4dd546219e30 | 352 | } |
smejky | 0:6abf63b83992 | 353 | |
smejky | 0:6abf63b83992 | 354 | |
smejky | 0:6abf63b83992 | 355 | |
smejky | 2:0629f1ddaa92 | 356 | |
smejky | 7:91b982ccf255 | 357 | |
smejky | 8:b6e7401fdcfc | 358 | void Menu(int strana = 0){ |
smejky | 7:91b982ccf255 | 359 | switch(strana) |
smejky | 7:91b982ccf255 | 360 | { |
smejky | 7:91b982ccf255 | 361 | case 1: |
smejky | 9:d1385f7171af | 362 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 7:91b982ccf255 | 363 | |
smejky | 7:91b982ccf255 | 364 | |
smejky | 7:91b982ccf255 | 365 | //CUDLIKY******************************************************************************* |
smejky | 7:91b982ccf255 | 366 | //prvni rada |
smejky | 9:d1385f7171af | 367 | spi.Bitmap(213,10,48,24,(unsigned char*)gImage_cudlik3_vrch); |
smejky | 9:d1385f7171af | 368 | spi.Bitmap(213,34,48,24,(unsigned char*)gImage_cudlik3_spodek); |
smejky | 7:91b982ccf255 | 369 | |
smejky | 9:d1385f7171af | 370 | spi.Bitmap(137,10,48,24,(unsigned char*)gImage_cudlik2_vrch); |
smejky | 9:d1385f7171af | 371 | spi.Bitmap(137,34,48,24,(unsigned char*)gImage_cudlik2_spodek); |
smejky | 8:b6e7401fdcfc | 372 | |
smejky | 9:d1385f7171af | 373 | spi.Bitmap(60,10,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 374 | spi.Bitmap(60,34,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 9:d1385f7171af | 375 | |
smejky | 7:91b982ccf255 | 376 | //prvni rada |
smejky | 7:91b982ccf255 | 377 | |
smejky | 7:91b982ccf255 | 378 | //druha rada |
smejky | 9:d1385f7171af | 379 | spi.Bitmap(213,76,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 380 | spi.Bitmap(213,100,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 7:91b982ccf255 | 381 | |
smejky | 9:d1385f7171af | 382 | spi.Bitmap(137,76,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 383 | spi.Bitmap(137,100,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 7:91b982ccf255 | 384 | |
smejky | 9:d1385f7171af | 385 | spi.Bitmap(60,76,48,24,(unsigned char*)gImage_cudlik4_vrch); |
smejky | 9:d1385f7171af | 386 | spi.Bitmap(60,100,48,24,(unsigned char*)gImage_cudlik4_spodek); |
smejky | 7:91b982ccf255 | 387 | // druha rada |
smejky | 7:91b982ccf255 | 388 | |
smejky | 7:91b982ccf255 | 389 | //treti rada |
smejky | 9:d1385f7171af | 390 | spi.Bitmap(213,142,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 391 | spi.Bitmap(213,166,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 7:91b982ccf255 | 392 | |
smejky | 9:d1385f7171af | 393 | spi.Bitmap(137,142,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 394 | spi.Bitmap(137,166,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 7:91b982ccf255 | 395 | |
smejky | 9:d1385f7171af | 396 | spi.Bitmap(60,142,48,24,(unsigned char*)gImage_cudlik1_vrch); |
smejky | 9:d1385f7171af | 397 | spi.Bitmap(60,166,48,24,(unsigned char*)gImage_cudlik1_spodek); |
smejky | 7:91b982ccf255 | 398 | // treti rada |
smejky | 7:91b982ccf255 | 399 | |
smejky | 7:91b982ccf255 | 400 | //CUDLIKY******************************************************************************* |
smejky | 8:b6e7401fdcfc | 401 | |
smejky | 8:b6e7401fdcfc | 402 | strana = 1; |
smejky | 8:b6e7401fdcfc | 403 | Button(strana); |
smejky | 8:b6e7401fdcfc | 404 | |
smejky | 8:b6e7401fdcfc | 405 | break; |
smejky | 7:91b982ccf255 | 406 | default: |
smejky | 9:d1385f7171af | 407 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 7:91b982ccf255 | 408 | strana = 0; |
smejky | 7:91b982ccf255 | 409 | Button(strana); |
smejky | 7:91b982ccf255 | 410 | } |
smejky | 7:91b982ccf255 | 411 | } |
smejky | 7:91b982ccf255 | 412 | |
smejky | 8:b6e7401fdcfc | 413 | void Static(){ |
smejky | 9:d1385f7171af | 414 | int red1[] = {213,76,260,124}; |
smejky | 9:d1385f7171af | 415 | int green1[] = {137,76,184,124}; |
smejky | 9:d1385f7171af | 416 | int blue1[] = {60,76,107,124}; |
smejky | 9:d1385f7171af | 417 | |
smejky | 9:d1385f7171af | 418 | |
smejky | 8:b6e7401fdcfc | 419 | int red[] = {76,213,124,260}; |
smejky | 8:b6e7401fdcfc | 420 | int green[] = {76,137,124,184}; |
smejky | 8:b6e7401fdcfc | 421 | int blue[] = {76,60,124,107}; |
smejky | 9:d1385f7171af | 422 | |
smejky | 8:b6e7401fdcfc | 423 | |
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 | 9:d1385f7171af | 428 | spi.fillrect(red1[0],red1[1],red1[2],red1[3],Red); |
smejky | 9:d1385f7171af | 429 | spi.fillrect(green1[0],green1[1],green1[2],green1[3],Green); |
smejky | 9:d1385f7171af | 430 | spi.fillrect(blue1[0],blue1[1],blue1[2],blue1[3],Blue); |
smejky | 8:b6e7401fdcfc | 431 | |
smejky | 8:b6e7401fdcfc | 432 | |
smejky | 8:b6e7401fdcfc | 433 | int r = 1; |
smejky | 8:b6e7401fdcfc | 434 | int g = 1; |
smejky | 8:b6e7401fdcfc | 435 | int b = 1; |
smejky | 8:b6e7401fdcfc | 436 | while(1) |
smejky | 8:b6e7401fdcfc | 437 | { |
smejky | 8:b6e7401fdcfc | 438 | if (touch.DataAvailable()) |
smejky | 8:b6e7401fdcfc | 439 | { |
smejky | 8:b6e7401fdcfc | 440 | if(touch.Read()) |
smejky | 8:b6e7401fdcfc | 441 | { |
smejky | 8:b6e7401fdcfc | 442 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 8:b6e7401fdcfc | 443 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 8:b6e7401fdcfc | 444 | |
smejky | 8:b6e7401fdcfc | 445 | //pravý čudlik |
smejky | 8:b6e7401fdcfc | 446 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 9:d1385f7171af | 447 | |
smejky | 8:b6e7401fdcfc | 448 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 449 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 10:0176705be216 | 450 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit_s); |
smejky | 9:d1385f7171af | 451 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 452 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 8:b6e7401fdcfc | 453 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 454 | hold(); |
smejky | 8:b6e7401fdcfc | 455 | my_red = r; |
smejky | 8:b6e7401fdcfc | 456 | my_green = g; |
smejky | 8:b6e7401fdcfc | 457 | my_blue = b; |
smejky | 8:b6e7401fdcfc | 458 | grafika(1); |
smejky | 10:0176705be216 | 459 | grafika(2); |
smejky | 8:b6e7401fdcfc | 460 | Menu(); |
smejky | 8:b6e7401fdcfc | 461 | wait(0.2); |
smejky | 8:b6e7401fdcfc | 462 | } |
smejky | 8:b6e7401fdcfc | 463 | //pravý čudlik |
smejky | 8:b6e7401fdcfc | 464 | |
smejky | 8:b6e7401fdcfc | 465 | //levý čudlik |
smejky | 8:b6e7401fdcfc | 466 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 8:b6e7401fdcfc | 467 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 468 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 10:0176705be216 | 469 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit_s);// levy |
smejky | 9:d1385f7171af | 470 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 471 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 8:b6e7401fdcfc | 472 | //GRAFIKA************************************************** |
smejky | 8:b6e7401fdcfc | 473 | |
smejky | 9:d1385f7171af | 474 | hold(); |
smejky | 8:b6e7401fdcfc | 475 | grafika(2); |
smejky | 10:0176705be216 | 476 | grafika(1); |
smejky | 8:b6e7401fdcfc | 477 | wait(0.2); |
smejky | 8:b6e7401fdcfc | 478 | Menu(); |
smejky | 8:b6e7401fdcfc | 479 | } |
smejky | 8:b6e7401fdcfc | 480 | //levý čudlik |
smejky | 8:b6e7401fdcfc | 481 | |
smejky | 9:d1385f7171af | 482 | if((touch_x > red[0]) && (touch_x < red[2]) && (touch_y < red[3]) && (touch_y > red[1])){ |
smejky | 9:d1385f7171af | 483 | hold(); |
smejky | 8:b6e7401fdcfc | 484 | r = !r; |
smejky | 8:b6e7401fdcfc | 485 | printf("%d",r); |
smejky | 8:b6e7401fdcfc | 486 | wait(0.2); |
smejky | 8:b6e7401fdcfc | 487 | } |
smejky | 8:b6e7401fdcfc | 488 | |
smejky | 9:d1385f7171af | 489 | if((touch_x > green[0]) && (touch_x < green[2]) && (touch_y < green[3]) && (touch_y > green[1])){ |
smejky | 9:d1385f7171af | 490 | hold(); |
smejky | 8:b6e7401fdcfc | 491 | g = !g; |
smejky | 8:b6e7401fdcfc | 492 | printf("%d",g); |
smejky | 8:b6e7401fdcfc | 493 | wait(0.2); |
smejky | 8:b6e7401fdcfc | 494 | } |
smejky | 8:b6e7401fdcfc | 495 | |
smejky | 9:d1385f7171af | 496 | if((touch_x > blue[0]) && (touch_x < blue[2]) && (touch_y < blue[3]) && (touch_y > blue[1])){ |
smejky | 9:d1385f7171af | 497 | hold(); |
smejky | 8:b6e7401fdcfc | 498 | b = !b; |
smejky | 8:b6e7401fdcfc | 499 | printf("%d",b); |
smejky | 8:b6e7401fdcfc | 500 | wait(0.2); |
smejky | 8:b6e7401fdcfc | 501 | } |
smejky | 8:b6e7401fdcfc | 502 | |
smejky | 8:b6e7401fdcfc | 503 | } |
smejky | 8:b6e7401fdcfc | 504 | } |
smejky | 8:b6e7401fdcfc | 505 | } |
smejky | 8:b6e7401fdcfc | 506 | |
smejky | 8:b6e7401fdcfc | 507 | } |
smejky | 8:b6e7401fdcfc | 508 | |
smejky | 9:d1385f7171af | 509 | void nastaveni(){ |
smejky | 9:d1385f7171af | 510 | int pravy[] = {34,0,165,46}; //pravý čudlík |
smejky | 9:d1385f7171af | 511 | int levy[] = {34,274,165,320}; //levý čudlík |
smejky | 9:d1385f7171af | 512 | int i = 0; |
smejky | 10:0176705be216 | 513 | |
smejky | 9:d1385f7171af | 514 | |
smejky | 9:d1385f7171af | 515 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 9:d1385f7171af | 516 | int check1[] = {66,10,96,40}; |
smejky | 9:d1385f7171af | 517 | int check2[] = {66,56,96,86}; |
smejky | 9:d1385f7171af | 518 | |
smejky | 10:0176705be216 | 519 | int prvni[] = {46,0,273,46}; //prvni čudlík |
smejky | 10:0176705be216 | 520 | int druhy[] = {46,46,273,92}; //druhy čudlík |
smejky | 10:0176705be216 | 521 | int treti[] = {46,92,273,138}; //treti čudlík |
smejky | 10:0176705be216 | 522 | int ctvrty[] = {46,138,273,184}; //treti čudlík |
smejky | 10:0176705be216 | 523 | |
smejky | 9:d1385f7171af | 524 | |
smejky | 9:d1385f7171af | 525 | spi.background(MojeSeda); |
smejky | 9:d1385f7171af | 526 | spi.fillrect(prvni[0],prvni[1],prvni[2],prvni[3],MojeSeda); //prvni |
smejky | 9:d1385f7171af | 527 | spi.rect(prvni[0],prvni[1],prvni[2],prvni[3],White); //prvni |
smejky | 9:d1385f7171af | 528 | spi.set_font((unsigned char*) Arial28x28); |
smejky | 9:d1385f7171af | 529 | spi.locate(140,14); |
smejky | 9:d1385f7171af | 530 | spi.printf(jazyk[0]); |
smejky | 9:d1385f7171af | 531 | |
smejky | 9:d1385f7171af | 532 | spi.fillrect(druhy[0],druhy[1],druhy[2],druhy[3],MojeSeda); //druhy |
smejky | 9:d1385f7171af | 533 | spi.rect(druhy[0],druhy[1],druhy[2],druhy[3],White); //druhy |
smejky | 9:d1385f7171af | 534 | spi.locate(140,60); |
smejky | 9:d1385f7171af | 535 | spi.printf(jazyk[1]); |
smejky | 9:d1385f7171af | 536 | |
smejky | 9:d1385f7171af | 537 | switch(lang) |
smejky | 9:d1385f7171af | 538 | { |
smejky | 9:d1385f7171af | 539 | case 1: |
smejky | 9:d1385f7171af | 540 | spi.fillrect(check1[0],check1[1],check1[2],check1[3],Green); |
smejky | 9:d1385f7171af | 541 | spi.fillrect(check2[0],check2[1],check2[2],check2[3],Red); |
smejky | 9:d1385f7171af | 542 | break; |
smejky | 9:d1385f7171af | 543 | default: |
smejky | 9:d1385f7171af | 544 | spi.fillrect(check1[0],check1[1],check1[2],check1[3],Red); |
smejky | 9:d1385f7171af | 545 | spi.fillrect(check2[0],check2[1],check2[2],check2[3],Green); |
smejky | 9:d1385f7171af | 546 | } |
smejky | 9:d1385f7171af | 547 | |
smejky | 9:d1385f7171af | 548 | |
smejky | 9:d1385f7171af | 549 | spi.fillrect(treti[0],treti[1],treti[2],treti[3],MojeSeda); //treti |
smejky | 9:d1385f7171af | 550 | spi.rect(treti[0],treti[1],treti[2],treti[3],White); //treti |
smejky | 9:d1385f7171af | 551 | spi.locate(90,106); |
smejky | 9:d1385f7171af | 552 | spi.printf(jazyk[2]); |
smejky | 10:0176705be216 | 553 | |
smejky | 10:0176705be216 | 554 | spi.fillrect(ctvrty[0],ctvrty[1],ctvrty[2],ctvrty[3],MojeSeda); //ctvrty |
smejky | 10:0176705be216 | 555 | spi.rect(ctvrty[0],ctvrty[1],ctvrty[2],ctvrty[3],White); //ctvrty |
smejky | 10:0176705be216 | 556 | spi.locate(95,152); |
smejky | 10:0176705be216 | 557 | spi.printf(jazyk[3]); |
smejky | 10:0176705be216 | 558 | |
smejky | 10:0176705be216 | 559 | |
smejky | 9:d1385f7171af | 560 | while(1){ |
smejky | 9:d1385f7171af | 561 | if (touch.DataAvailable()) |
smejky | 9:d1385f7171af | 562 | { |
smejky | 9:d1385f7171af | 563 | if(touch.Read()) |
smejky | 9:d1385f7171af | 564 | { |
smejky | 9:d1385f7171af | 565 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 9:d1385f7171af | 566 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 9:d1385f7171af | 567 | |
smejky | 9:d1385f7171af | 568 | //pravý čudlik |
smejky | 9:d1385f7171af | 569 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 9:d1385f7171af | 570 | |
smejky | 9:d1385f7171af | 571 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 572 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 573 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit_s); |
smejky | 9:d1385f7171af | 574 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 575 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 576 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 577 | hold(); |
smejky | 9:d1385f7171af | 578 | switch(jazyk_s) |
smejky | 9:d1385f7171af | 579 | { |
smejky | 9:d1385f7171af | 580 | case 1: |
smejky | 10:0176705be216 | 581 | while(i < 4){ |
smejky | 9:d1385f7171af | 582 | strcpy(jazyk[i], cz[i]); |
smejky | 9:d1385f7171af | 583 | i++; |
smejky | 9:d1385f7171af | 584 | } |
smejky | 9:d1385f7171af | 585 | break; |
smejky | 9:d1385f7171af | 586 | default: |
smejky | 10:0176705be216 | 587 | while(i < 4){ |
smejky | 9:d1385f7171af | 588 | strcpy(jazyk[i], en[i]); |
smejky | 9:d1385f7171af | 589 | i++; |
smejky | 9:d1385f7171af | 590 | } |
smejky | 9:d1385f7171af | 591 | } |
smejky | 9:d1385f7171af | 592 | i = 0; |
smejky | 9:d1385f7171af | 593 | grafika(1); |
smejky | 9:d1385f7171af | 594 | grafika(2); |
smejky | 9:d1385f7171af | 595 | Menu(); |
smejky | 9:d1385f7171af | 596 | wait(0.2); |
smejky | 9:d1385f7171af | 597 | } |
smejky | 9:d1385f7171af | 598 | //pravý čudlik |
smejky | 9:d1385f7171af | 599 | |
smejky | 9:d1385f7171af | 600 | //levý čudlik |
smejky | 9:d1385f7171af | 601 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 9:d1385f7171af | 602 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 603 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 604 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit_s);// levy |
smejky | 9:d1385f7171af | 605 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 606 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 607 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 608 | |
smejky | 9:d1385f7171af | 609 | hold(); |
smejky | 9:d1385f7171af | 610 | |
smejky | 9:d1385f7171af | 611 | grafika(2); |
smejky | 9:d1385f7171af | 612 | grafika(1); |
smejky | 9:d1385f7171af | 613 | Menu(); |
smejky | 9:d1385f7171af | 614 | wait(0.2); |
smejky | 9:d1385f7171af | 615 | } |
smejky | 9:d1385f7171af | 616 | //levý čudlik |
smejky | 9:d1385f7171af | 617 | |
smejky | 9:d1385f7171af | 618 | if((touch_x > prvni[1]) && (touch_x < prvni[3]) && (touch_y < prvni[2]) && (touch_y > prvni[0])){ |
smejky | 9:d1385f7171af | 619 | hold(); |
smejky | 9:d1385f7171af | 620 | jazyk_s = 1; |
smejky | 9:d1385f7171af | 621 | lang = jazyk_s; |
smejky | 9:d1385f7171af | 622 | spi.fillrect(check1[0],check1[1],check1[2],check1[3],Green); |
smejky | 9:d1385f7171af | 623 | spi.fillrect(check2[0],check2[1],check2[2],check2[3],Red); |
smejky | 9:d1385f7171af | 624 | wait(0.2); |
smejky | 9:d1385f7171af | 625 | } |
smejky | 9:d1385f7171af | 626 | if((touch_x > druhy[1]) && (touch_x < druhy[3]) && (touch_y < druhy[2]) && (touch_y > druhy[0])){ |
smejky | 9:d1385f7171af | 627 | hold(); |
smejky | 9:d1385f7171af | 628 | jazyk_s = 0; |
smejky | 9:d1385f7171af | 629 | lang = jazyk_s; |
smejky | 9:d1385f7171af | 630 | spi.fillrect(check1[0],check1[1],check1[2],check1[3],Red); |
smejky | 9:d1385f7171af | 631 | spi.fillrect(check2[0],check2[1],check2[2],check2[3],Green); |
smejky | 9:d1385f7171af | 632 | wait(0.2); |
smejky | 9:d1385f7171af | 633 | } |
smejky | 9:d1385f7171af | 634 | if((touch_x > treti[1]) && (touch_x < treti[3]) && (touch_y < treti[2]) && (touch_y > treti[0])){ |
smejky | 9:d1385f7171af | 635 | hold(); |
smejky | 9:d1385f7171af | 636 | nastavit_hodiny(); |
smejky | 9:d1385f7171af | 637 | } |
smejky | 10:0176705be216 | 638 | if((touch_x > ctvrty[1]) && (touch_x < ctvrty[3]) && (touch_y < ctvrty[2]) && (touch_y > ctvrty[0])){ |
smejky | 10:0176705be216 | 639 | hold(); |
smejky | 10:0176705be216 | 640 | brightness(); |
smejky | 10:0176705be216 | 641 | } |
smejky | 9:d1385f7171af | 642 | |
smejky | 9:d1385f7171af | 643 | |
smejky | 9:d1385f7171af | 644 | } |
smejky | 9:d1385f7171af | 645 | } |
smejky | 9:d1385f7171af | 646 | } |
smejky | 9:d1385f7171af | 647 | |
smejky | 9:d1385f7171af | 648 | } |
smejky | 9:d1385f7171af | 649 | |
smejky | 10:0176705be216 | 650 | |
smejky | 10:0176705be216 | 651 | void brightness(){ |
smejky | 10:0176705be216 | 652 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 9:d1385f7171af | 653 | int pravy[] = {34,0,165,46}; //pravý čudlík |
smejky | 9:d1385f7171af | 654 | int levy[] = {34,274,165,320}; //levý čudlík |
smejky | 9:d1385f7171af | 655 | |
smejky | 10:0176705be216 | 656 | int p10t[] = {229,52,264,147}; |
smejky | 10:0176705be216 | 657 | int p30t[] = {186,52,221,147}; |
smejky | 10:0176705be216 | 658 | int p50t[] = {143,52,178,147}; |
smejky | 10:0176705be216 | 659 | int p70t[] = {100,52,135,147}; |
smejky | 10:0176705be216 | 660 | int p90t[] = {57,52,92,147}; |
smejky | 10:0176705be216 | 661 | |
smejky | 10:0176705be216 | 662 | int p10[] = {57,52,92,147}; |
smejky | 10:0176705be216 | 663 | int p30[] = {100,52,135,147}; |
smejky | 10:0176705be216 | 664 | int p50[] = {143,52,178,147}; |
smejky | 10:0176705be216 | 665 | int p70[] = {186,52,221,147}; |
smejky | 10:0176705be216 | 666 | int p90[] = {229,52,264,147}; |
smejky | 10:0176705be216 | 667 | |
smejky | 10:0176705be216 | 668 | switch(jas_s){ |
smejky | 10:0176705be216 | 669 | case 0: |
smejky | 10:0176705be216 | 670 | spi.fillrect(p10[0],p10[1],p10[2],p10[3],jas[0]); |
smejky | 10:0176705be216 | 671 | spi.fillrect(p30[0],p30[1],p30[2],p30[3],jas[1]); |
smejky | 10:0176705be216 | 672 | spi.fillrect(p50[0],p50[1],p50[2],p50[3],jas[1]); |
smejky | 10:0176705be216 | 673 | spi.fillrect(p70[0],p70[1],p70[2],p70[3],jas[1]); |
smejky | 10:0176705be216 | 674 | spi.fillrect(p90[0],p90[1],p90[2],p90[3],jas[1]); |
smejky | 10:0176705be216 | 675 | break; |
smejky | 10:0176705be216 | 676 | case 1: |
smejky | 10:0176705be216 | 677 | spi.fillrect(p10[0],p10[1],p10[2],p10[3],jas[0]); |
smejky | 10:0176705be216 | 678 | spi.fillrect(p30[0],p30[1],p30[2],p30[3],jas[0]); |
smejky | 10:0176705be216 | 679 | spi.fillrect(p50[0],p50[1],p50[2],p50[3],jas[1]); |
smejky | 10:0176705be216 | 680 | spi.fillrect(p70[0],p70[1],p70[2],p70[3],jas[1]); |
smejky | 10:0176705be216 | 681 | spi.fillrect(p90[0],p90[1],p90[2],p90[3],jas[1]); |
smejky | 10:0176705be216 | 682 | break; |
smejky | 10:0176705be216 | 683 | case 2: |
smejky | 10:0176705be216 | 684 | spi.fillrect(p10[0],p10[1],p10[2],p10[3],jas[0]); |
smejky | 10:0176705be216 | 685 | spi.fillrect(p30[0],p30[1],p30[2],p30[3],jas[0]); |
smejky | 10:0176705be216 | 686 | spi.fillrect(p50[0],p50[1],p50[2],p50[3],jas[0]); |
smejky | 10:0176705be216 | 687 | spi.fillrect(p70[0],p70[1],p70[2],p70[3],jas[1]); |
smejky | 10:0176705be216 | 688 | spi.fillrect(p90[0],p90[1],p90[2],p90[3],jas[1]); |
smejky | 10:0176705be216 | 689 | break; |
smejky | 10:0176705be216 | 690 | case 3: |
smejky | 10:0176705be216 | 691 | spi.fillrect(p10[0],p10[1],p10[2],p10[3],jas[0]); |
smejky | 10:0176705be216 | 692 | spi.fillrect(p30[0],p30[1],p30[2],p30[3],jas[0]); |
smejky | 10:0176705be216 | 693 | spi.fillrect(p50[0],p50[1],p50[2],p50[3],jas[0]); |
smejky | 10:0176705be216 | 694 | spi.fillrect(p70[0],p70[1],p70[2],p70[3],jas[0]); |
smejky | 10:0176705be216 | 695 | spi.fillrect(p90[0],p90[1],p90[2],p90[3],jas[1]); |
smejky | 10:0176705be216 | 696 | break; |
smejky | 10:0176705be216 | 697 | case 4: |
smejky | 10:0176705be216 | 698 | spi.fillrect(p10[0],p10[1],p10[2],p10[3],jas[0]); |
smejky | 10:0176705be216 | 699 | spi.fillrect(p30[0],p30[1],p30[2],p30[3],jas[0]); |
smejky | 10:0176705be216 | 700 | spi.fillrect(p50[0],p50[1],p50[2],p50[3],jas[0]); |
smejky | 10:0176705be216 | 701 | spi.fillrect(p70[0],p70[1],p70[2],p70[3],jas[0]); |
smejky | 10:0176705be216 | 702 | spi.fillrect(p90[0],p90[1],p90[2],p90[3],jas[0]); |
smejky | 10:0176705be216 | 703 | break; |
smejky | 10:0176705be216 | 704 | default: |
smejky | 10:0176705be216 | 705 | printf("err"); |
smejky | 9:d1385f7171af | 706 | |
smejky | 10:0176705be216 | 707 | } |
smejky | 9:d1385f7171af | 708 | |
smejky | 9:d1385f7171af | 709 | while(1){ |
smejky | 9:d1385f7171af | 710 | if (touch.DataAvailable()) |
smejky | 9:d1385f7171af | 711 | { |
smejky | 9:d1385f7171af | 712 | if(touch.Read()) |
smejky | 9:d1385f7171af | 713 | { |
smejky | 9:d1385f7171af | 714 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 9:d1385f7171af | 715 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 9:d1385f7171af | 716 | |
smejky | 9:d1385f7171af | 717 | //pravý čudlik |
smejky | 9:d1385f7171af | 718 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 9:d1385f7171af | 719 | |
smejky | 9:d1385f7171af | 720 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 721 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 722 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit_s); |
smejky | 9:d1385f7171af | 723 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 724 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 725 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 726 | hold(); |
smejky | 9:d1385f7171af | 727 | |
smejky | 9:d1385f7171af | 728 | grafika(9); |
smejky | 10:0176705be216 | 729 | br.write(lcd_jas); |
smejky | 9:d1385f7171af | 730 | nastaveni(); |
smejky | 9:d1385f7171af | 731 | wait(0.2); |
smejky | 9:d1385f7171af | 732 | } |
smejky | 9:d1385f7171af | 733 | //pravý čudlik |
smejky | 9:d1385f7171af | 734 | |
smejky | 9:d1385f7171af | 735 | //levý čudlik |
smejky | 9:d1385f7171af | 736 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 9:d1385f7171af | 737 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 738 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 9:d1385f7171af | 739 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit_s);// levy |
smejky | 9:d1385f7171af | 740 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 741 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 9:d1385f7171af | 742 | //GRAFIKA************************************************** |
smejky | 9:d1385f7171af | 743 | |
smejky | 9:d1385f7171af | 744 | hold(); |
smejky | 10:0176705be216 | 745 | lcd_jas = 0.00f; |
smejky | 9:d1385f7171af | 746 | grafika(7); |
smejky | 9:d1385f7171af | 747 | nastaveni(); |
smejky | 9:d1385f7171af | 748 | wait(0.2); |
smejky | 9:d1385f7171af | 749 | } |
smejky | 9:d1385f7171af | 750 | //levý čudlik |
smejky | 9:d1385f7171af | 751 | |
smejky | 10:0176705be216 | 752 | if((touch_x > p10t[1]) && (touch_x < p10t[3]) && (touch_y < p10t[2]) && (touch_y > p10t[0])){ |
smejky | 10:0176705be216 | 753 | hold(); |
smejky | 10:0176705be216 | 754 | jas_s = 0; |
smejky | 10:0176705be216 | 755 | lcd_jas = 0.10f; |
smejky | 10:0176705be216 | 756 | brightness(); |
smejky | 10:0176705be216 | 757 | |
smejky | 10:0176705be216 | 758 | } |
smejky | 10:0176705be216 | 759 | |
smejky | 10:0176705be216 | 760 | if((touch_x > p30t[1]) && (touch_x < p30t[3]) && (touch_y < p30t[2]) && (touch_y > p30t[0])){ |
smejky | 10:0176705be216 | 761 | hold(); |
smejky | 10:0176705be216 | 762 | jas_s = 1; |
smejky | 10:0176705be216 | 763 | lcd_jas = 0.30f; |
smejky | 10:0176705be216 | 764 | brightness(); |
smejky | 10:0176705be216 | 765 | } |
smejky | 10:0176705be216 | 766 | if((touch_x > p50t[1]) && (touch_x < p50t[3]) && (touch_y < p50t[2]) && (touch_y > p50t[0])){ |
smejky | 10:0176705be216 | 767 | hold(); |
smejky | 10:0176705be216 | 768 | jas_s = 2; |
smejky | 10:0176705be216 | 769 | lcd_jas = 0.50f; |
smejky | 10:0176705be216 | 770 | brightness(); |
smejky | 10:0176705be216 | 771 | |
smejky | 10:0176705be216 | 772 | } |
smejky | 10:0176705be216 | 773 | if((touch_x > p70t[1]) && (touch_x < p70t[3]) && (touch_y < p70t[2]) && (touch_y > p70t[0])){ |
smejky | 10:0176705be216 | 774 | hold(); |
smejky | 10:0176705be216 | 775 | jas_s = 3; |
smejky | 10:0176705be216 | 776 | lcd_jas = 0.70f; |
smejky | 10:0176705be216 | 777 | brightness(); |
smejky | 10:0176705be216 | 778 | } |
smejky | 10:0176705be216 | 779 | if((touch_x > p90t[1]) && (touch_x < p90t[3]) && (touch_y < p90t[2]) && (touch_y > p90t[0])){ |
smejky | 10:0176705be216 | 780 | hold(); |
smejky | 10:0176705be216 | 781 | jas_s = 4; |
smejky | 10:0176705be216 | 782 | lcd_jas = 0.90f; |
smejky | 10:0176705be216 | 783 | brightness(); |
smejky | 10:0176705be216 | 784 | } |
smejky | 10:0176705be216 | 785 | |
smejky | 10:0176705be216 | 786 | |
smejky | 10:0176705be216 | 787 | } |
smejky | 10:0176705be216 | 788 | } |
smejky | 10:0176705be216 | 789 | } |
smejky | 10:0176705be216 | 790 | } |
smejky | 10:0176705be216 | 791 | |
smejky | 10:0176705be216 | 792 | |
smejky | 10:0176705be216 | 793 | |
smejky | 10:0176705be216 | 794 | void nastavit_hodiny(){ |
smejky | 10:0176705be216 | 795 | int pravy[] = {34,0,165,46}; //pravý čudlík |
smejky | 10:0176705be216 | 796 | int levy[] = {34,274,165,320}; //levý čudlík |
smejky | 10:0176705be216 | 797 | |
smejky | 10:0176705be216 | 798 | int up1[] = {172,28,258,57}; |
smejky | 10:0176705be216 | 799 | int down1[] = {172,142,258,171}; |
smejky | 10:0176705be216 | 800 | |
smejky | 10:0176705be216 | 801 | int up2[] = {62,28,148,57}; |
smejky | 10:0176705be216 | 802 | int down2[] = {62,142,148,171}; |
smejky | 10:0176705be216 | 803 | |
smejky | 10:0176705be216 | 804 | cas_hodiny = atoi(hodinka); |
smejky | 10:0176705be216 | 805 | cas_minuty = atoi(minutka); |
smejky | 10:0176705be216 | 806 | |
smejky | 10:0176705be216 | 807 | |
smejky | 10:0176705be216 | 808 | int h1 = cas_hodiny / 10; |
smejky | 10:0176705be216 | 809 | int h2 = cas_hodiny % 10; |
smejky | 10:0176705be216 | 810 | |
smejky | 10:0176705be216 | 811 | char cisla[10][3] = { |
smejky | 10:0176705be216 | 812 | "0", |
smejky | 10:0176705be216 | 813 | "1", |
smejky | 10:0176705be216 | 814 | "2", |
smejky | 10:0176705be216 | 815 | "3", |
smejky | 10:0176705be216 | 816 | "4", |
smejky | 10:0176705be216 | 817 | "5", |
smejky | 10:0176705be216 | 818 | "6", |
smejky | 10:0176705be216 | 819 | "7", |
smejky | 10:0176705be216 | 820 | "8", |
smejky | 10:0176705be216 | 821 | "9" |
smejky | 10:0176705be216 | 822 | }; |
smejky | 10:0176705be216 | 823 | |
smejky | 10:0176705be216 | 824 | int m1 = cas_minuty / 10; |
smejky | 10:0176705be216 | 825 | int m2 = cas_minuty % 10; |
smejky | 10:0176705be216 | 826 | |
smejky | 10:0176705be216 | 827 | int blue1[] = {71,65,249,134}; |
smejky | 10:0176705be216 | 828 | |
smejky | 10:0176705be216 | 829 | spi.Bitmap(46,0,228,200,(unsigned char*)gImage_pozadi); |
smejky | 10:0176705be216 | 830 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 10:0176705be216 | 831 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 10:0176705be216 | 832 | |
smejky | 10:0176705be216 | 833 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 10:0176705be216 | 834 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 10:0176705be216 | 835 | |
smejky | 10:0176705be216 | 836 | |
smejky | 10:0176705be216 | 837 | |
smejky | 10:0176705be216 | 838 | spi.fillrect(blue1[0],blue1[1],blue1[2],blue1[3],MojeSeda); |
smejky | 10:0176705be216 | 839 | |
smejky | 10:0176705be216 | 840 | spi.set_font((unsigned char*) Arial48x47); |
smejky | 10:0176705be216 | 841 | spi.background(MojeSeda); |
smejky | 10:0176705be216 | 842 | spi.locate(80,80); |
smejky | 10:0176705be216 | 843 | spi.printf(cisla[h1]); |
smejky | 10:0176705be216 | 844 | spi.locate(110,80); |
smejky | 10:0176705be216 | 845 | spi.printf(cisla[h2]); |
smejky | 10:0176705be216 | 846 | spi.locate(155,80); |
smejky | 10:0176705be216 | 847 | spi.printf(":"); |
smejky | 10:0176705be216 | 848 | spi.locate(189,80); |
smejky | 10:0176705be216 | 849 | spi.printf(cisla[m1]); |
smejky | 10:0176705be216 | 850 | spi.locate(219,80); |
smejky | 10:0176705be216 | 851 | spi.printf(cisla[m2]); |
smejky | 10:0176705be216 | 852 | |
smejky | 10:0176705be216 | 853 | |
smejky | 10:0176705be216 | 854 | while(1){ |
smejky | 10:0176705be216 | 855 | if (touch.DataAvailable()) |
smejky | 10:0176705be216 | 856 | { |
smejky | 10:0176705be216 | 857 | if(touch.Read()) |
smejky | 10:0176705be216 | 858 | { |
smejky | 10:0176705be216 | 859 | unsigned short int touch_y = touch.GetX(); // 0-320 |
smejky | 10:0176705be216 | 860 | unsigned short int touch_x = touch.GetY(); // 0-240 |
smejky | 10:0176705be216 | 861 | |
smejky | 10:0176705be216 | 862 | //pravý čudlik |
smejky | 10:0176705be216 | 863 | if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ |
smejky | 10:0176705be216 | 864 | |
smejky | 10:0176705be216 | 865 | //GRAFIKA************************************************** |
smejky | 10:0176705be216 | 866 | spi.Bitmap(274,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 10:0176705be216 | 867 | spi.Bitmap(274,72,46,42,(unsigned char*)gImage_potvrdit_s); |
smejky | 10:0176705be216 | 868 | spi.Bitmap(274,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 10:0176705be216 | 869 | spi.Bitmap(274,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 10:0176705be216 | 870 | //GRAFIKA************************************************** |
smejky | 10:0176705be216 | 871 | hold(); |
smejky | 10:0176705be216 | 872 | thread.terminate(); |
smejky | 10:0176705be216 | 873 | cas_nastavit = 1037059200 + (cas_hodiny * 3600) + (cas_minuty * 60); |
smejky | 10:0176705be216 | 874 | thread.start(hodiny); |
smejky | 10:0176705be216 | 875 | grafika(9); |
smejky | 10:0176705be216 | 876 | nastaveni(); |
smejky | 10:0176705be216 | 877 | wait(0.2); |
smejky | 10:0176705be216 | 878 | } |
smejky | 10:0176705be216 | 879 | //pravý čudlik |
smejky | 10:0176705be216 | 880 | |
smejky | 10:0176705be216 | 881 | //levý čudlik |
smejky | 10:0176705be216 | 882 | if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ |
smejky | 10:0176705be216 | 883 | //GRAFIKA************************************************** |
smejky | 10:0176705be216 | 884 | spi.Bitmap(0,34,46,38,(unsigned char*)gImage_vrch_s); |
smejky | 10:0176705be216 | 885 | spi.Bitmap(0,72,46,42,(unsigned char*)gImage_zrusit_s);// levy |
smejky | 10:0176705be216 | 886 | spi.Bitmap(0,114,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 10:0176705be216 | 887 | spi.Bitmap(0,140,46,26,(unsigned char*)gImage_spodek_s); |
smejky | 10:0176705be216 | 888 | //GRAFIKA************************************************** |
smejky | 10:0176705be216 | 889 | |
smejky | 10:0176705be216 | 890 | hold(); |
smejky | 10:0176705be216 | 891 | |
smejky | 10:0176705be216 | 892 | |
smejky | 10:0176705be216 | 893 | |
smejky | 10:0176705be216 | 894 | grafika(7); |
smejky | 10:0176705be216 | 895 | nastaveni(); |
smejky | 10:0176705be216 | 896 | wait(0.2); |
smejky | 10:0176705be216 | 897 | } |
smejky | 10:0176705be216 | 898 | //levý čudlik |
smejky | 10:0176705be216 | 899 | if((touch_x > up1[1]) && (touch_x < up1[3]) && (touch_y < up1[2]) && (touch_y > up1[0])){ |
smejky | 10:0176705be216 | 900 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru_s); |
smejky | 10:0176705be216 | 901 | while ((touch.DataAvailable()) && (h2 < 10)){ |
smejky | 10:0176705be216 | 902 | h2++; |
smejky | 10:0176705be216 | 903 | cas_hodiny++; |
smejky | 10:0176705be216 | 904 | if(cas_hodiny == 24){ |
smejky | 10:0176705be216 | 905 | cas_hodiny = 0; |
smejky | 10:0176705be216 | 906 | } |
smejky | 10:0176705be216 | 907 | if(h2 == 10){ |
smejky | 10:0176705be216 | 908 | h2 = 0; |
smejky | 10:0176705be216 | 909 | h1++; |
smejky | 10:0176705be216 | 910 | } |
smejky | 10:0176705be216 | 911 | if((h1 == 2)&&(h2 == 4)){ |
smejky | 10:0176705be216 | 912 | h2 = 0; |
smejky | 10:0176705be216 | 913 | h1 = 0; |
smejky | 10:0176705be216 | 914 | } |
smejky | 10:0176705be216 | 915 | |
smejky | 10:0176705be216 | 916 | spi.locate(80,80); |
smejky | 10:0176705be216 | 917 | spi.printf(cisla[h1]); |
smejky | 10:0176705be216 | 918 | spi.locate(110,80); |
smejky | 10:0176705be216 | 919 | spi.printf(cisla[h2]); |
smejky | 10:0176705be216 | 920 | |
smejky | 10:0176705be216 | 921 | |
smejky | 10:0176705be216 | 922 | wait(0.1); |
smejky | 10:0176705be216 | 923 | } |
smejky | 10:0176705be216 | 924 | spi.Bitmap(62,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 10:0176705be216 | 925 | } |
smejky | 10:0176705be216 | 926 | if((touch_x > down1[1]) && (touch_x < down1[3]) && (touch_y < down1[2]) && (touch_y > down1[0])){ |
smejky | 10:0176705be216 | 927 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu_s); |
smejky | 10:0176705be216 | 928 | while ((touch.DataAvailable()) && (h2 < 10)){ |
smejky | 10:0176705be216 | 929 | h2--; |
smejky | 10:0176705be216 | 930 | if((h2 < 0)&&(h1 == 0)){ |
smejky | 10:0176705be216 | 931 | h2 = 3; |
smejky | 10:0176705be216 | 932 | h1 = 2; |
smejky | 10:0176705be216 | 933 | } |
smejky | 10:0176705be216 | 934 | if(h2 < 0){ |
smejky | 10:0176705be216 | 935 | h2 = 9; |
smejky | 10:0176705be216 | 936 | h1--; |
smejky | 10:0176705be216 | 937 | } |
smejky | 10:0176705be216 | 938 | cas_hodiny--; |
smejky | 10:0176705be216 | 939 | if(cas_hodiny < 0){ |
smejky | 10:0176705be216 | 940 | cas_hodiny = 23; |
smejky | 10:0176705be216 | 941 | } |
smejky | 10:0176705be216 | 942 | spi.locate(80,80); |
smejky | 10:0176705be216 | 943 | spi.printf(cisla[h1]); |
smejky | 10:0176705be216 | 944 | spi.locate(110,80); |
smejky | 10:0176705be216 | 945 | spi.printf(cisla[h2]); |
smejky | 10:0176705be216 | 946 | wait(0.1); |
smejky | 10:0176705be216 | 947 | } |
smejky | 10:0176705be216 | 948 | spi.Bitmap(62,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 10:0176705be216 | 949 | } |
smejky | 10:0176705be216 | 950 | if((touch_x > up2[1]) && (touch_x < up2[3]) && (touch_y < up2[2]) && (touch_y > up2[0])){ |
smejky | 10:0176705be216 | 951 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru_s); |
smejky | 10:0176705be216 | 952 | while ((touch.DataAvailable()) && (m2 < 10)){ |
smejky | 10:0176705be216 | 953 | m2++; |
smejky | 10:0176705be216 | 954 | cas_minuty++; |
smejky | 10:0176705be216 | 955 | if(cas_minuty == 60){ |
smejky | 10:0176705be216 | 956 | cas_minuty = 0; |
smejky | 10:0176705be216 | 957 | } |
smejky | 10:0176705be216 | 958 | if((m1 == 5)&&(m2 == 10)){ |
smejky | 10:0176705be216 | 959 | m2 = 0; |
smejky | 10:0176705be216 | 960 | m1 = 0; |
smejky | 10:0176705be216 | 961 | } |
smejky | 10:0176705be216 | 962 | if(m2 == 10){ |
smejky | 10:0176705be216 | 963 | m2 = 0; |
smejky | 10:0176705be216 | 964 | m1++; |
smejky | 10:0176705be216 | 965 | } |
smejky | 10:0176705be216 | 966 | |
smejky | 10:0176705be216 | 967 | spi.locate(189,80); |
smejky | 10:0176705be216 | 968 | spi.printf(cisla[m1]); |
smejky | 10:0176705be216 | 969 | spi.locate(219,80); |
smejky | 10:0176705be216 | 970 | spi.printf(cisla[m2]); |
smejky | 10:0176705be216 | 971 | wait(0.1); |
smejky | 10:0176705be216 | 972 | } |
smejky | 10:0176705be216 | 973 | |
smejky | 10:0176705be216 | 974 | spi.Bitmap(172,28,86,29,(unsigned char*)gImage_nahoru); |
smejky | 10:0176705be216 | 975 | } |
smejky | 10:0176705be216 | 976 | if((touch_x > down2[1]) && (touch_x < down2[3]) && (touch_y < down2[2]) && (touch_y > down2[0])){ |
smejky | 10:0176705be216 | 977 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu_s); |
smejky | 10:0176705be216 | 978 | while ((touch.DataAvailable()) && (m2 < 10)){ |
smejky | 10:0176705be216 | 979 | m2--; |
smejky | 10:0176705be216 | 980 | if((m2 < 0)&&(m1 == 0)){ |
smejky | 10:0176705be216 | 981 | m2 = 9; |
smejky | 10:0176705be216 | 982 | m1 = 5; |
smejky | 10:0176705be216 | 983 | } |
smejky | 10:0176705be216 | 984 | if(m2 < 0){ |
smejky | 10:0176705be216 | 985 | m2 = 9; |
smejky | 10:0176705be216 | 986 | m1--; |
smejky | 10:0176705be216 | 987 | } |
smejky | 10:0176705be216 | 988 | cas_minuty--; |
smejky | 10:0176705be216 | 989 | if(cas_minuty < 0){ |
smejky | 10:0176705be216 | 990 | cas_minuty = 59; |
smejky | 10:0176705be216 | 991 | } |
smejky | 10:0176705be216 | 992 | spi.locate(189,80); |
smejky | 10:0176705be216 | 993 | spi.printf(cisla[m1]); |
smejky | 10:0176705be216 | 994 | spi.locate(219,80); |
smejky | 10:0176705be216 | 995 | spi.printf(cisla[m2]); |
smejky | 10:0176705be216 | 996 | wait(0.1); |
smejky | 10:0176705be216 | 997 | } |
smejky | 10:0176705be216 | 998 | |
smejky | 10:0176705be216 | 999 | spi.Bitmap(172,142,86,29,(unsigned char*)gImage_dolu); |
smejky | 10:0176705be216 | 1000 | } |
smejky | 10:0176705be216 | 1001 | |
smejky | 9:d1385f7171af | 1002 | |
smejky | 9:d1385f7171af | 1003 | } |
smejky | 9:d1385f7171af | 1004 | } |
smejky | 9:d1385f7171af | 1005 | } |
smejky | 9:d1385f7171af | 1006 | } |
smejky | 9:d1385f7171af | 1007 | |
smejky | 9:d1385f7171af | 1008 | |
smejky | 10:0176705be216 | 1009 | |
smejky | 10:0176705be216 | 1010 | |
smejky | 8:b6e7401fdcfc | 1011 | void hodiny(){ |
smejky | 9:d1385f7171af | 1012 | set_time(cas_nastavit); |
smejky | 8:b6e7401fdcfc | 1013 | while(1){ |
smejky | 8:b6e7401fdcfc | 1014 | time_t seconds = time(NULL); |
smejky | 9:d1385f7171af | 1015 | //seconds = seconds + 7200; |
smejky | 10:0176705be216 | 1016 | if(seconds == time_on){ |
smejky | 10:0176705be216 | 1017 | printf("ON\r\n"); |
smejky | 10:0176705be216 | 1018 | } |
smejky | 10:0176705be216 | 1019 | if(seconds == time_off){ |
smejky | 10:0176705be216 | 1020 | printf("OFF\r\n"); |
smejky | 10:0176705be216 | 1021 | } |
smejky | 8:b6e7401fdcfc | 1022 | strftime(buffer, 32, "%R", localtime(&seconds)); |
smejky | 10:0176705be216 | 1023 | strftime(hodinka, 32, "%H", localtime(&seconds)); |
smejky | 10:0176705be216 | 1024 | strftime(minutka, 32, "%M", localtime(&seconds)); |
smejky | 10:0176705be216 | 1025 | printf("%s\r\n",buffer); |
smejky | 9:d1385f7171af | 1026 | Thread::wait(1000); |
smejky | 8:b6e7401fdcfc | 1027 | } |
smejky | 8:b6e7401fdcfc | 1028 | } |
smejky | 7:91b982ccf255 | 1029 | |
smejky | 0:6abf63b83992 | 1030 | main(){ |
smejky | 9:d1385f7171af | 1031 | |
smejky | 8:b6e7401fdcfc | 1032 | my_red = 1; |
smejky | 8:b6e7401fdcfc | 1033 | my_green = 1; |
smejky | 8:b6e7401fdcfc | 1034 | my_blue = 1; |
smejky | 9:d1385f7171af | 1035 | spi.set_orientation(3); |
smejky | 3:dadb214885c1 | 1036 | spi.FastWindow(true); |
smejky | 0:6abf63b83992 | 1037 | touch.InitTouch(); |
smejky | 0:6abf63b83992 | 1038 | touch.SetPrecision(PREC_EXTREME); |
smejky | 8:b6e7401fdcfc | 1039 | spi.background(Black); |
smejky | 8:b6e7401fdcfc | 1040 | spi.foreground(White); |
smejky | 3:dadb214885c1 | 1041 | spi.cls(); |
smejky | 9:d1385f7171af | 1042 | |
smejky | 8:b6e7401fdcfc | 1043 | |
smejky | 3:dadb214885c1 | 1044 | grafika(); |
smejky | 9:d1385f7171af | 1045 | |
smejky | 9:d1385f7171af | 1046 | br.period_us(1000); |
smejky | 10:0176705be216 | 1047 | br.write(lcd_jas); |
smejky | 10:0176705be216 | 1048 | |
smejky | 9:d1385f7171af | 1049 | |
smejky | 10:0176705be216 | 1050 | /* nastavit_hodiny(); |
smejky | 10:0176705be216 | 1051 | thread.start(hodiny);*/ |
smejky | 3:dadb214885c1 | 1052 | Button(); |
smejky | 8:b6e7401fdcfc | 1053 | |
smejky | 2:0629f1ddaa92 | 1054 | |
smejky | 0:6abf63b83992 | 1055 | } |
smejky | 4:c7ca936cdd1f | 1056 | |
smejky | 4:c7ca936cdd1f | 1057 | |
smejky | 4:c7ca936cdd1f | 1058 | |
smejky | 4:c7ca936cdd1f | 1059 | |
smejky | 4:c7ca936cdd1f | 1060 | /* fail projekty |
smejky | 4:c7ca936cdd1f | 1061 | //slider |
smejky | 4:c7ca936cdd1f | 1062 | if ((touch_x > cudlik[0]) && (touch_x < cudlik[2]) && (touch_y > cudlik[1]) && (touch_y < cudlik[3]) && (pressure > 0)){ |
smejky | 4:c7ca936cdd1f | 1063 | |
smejky | 4:c7ca936cdd1f | 1064 | |
smejky | 4:c7ca936cdd1f | 1065 | //if je udelany tady pro nastavení minima a maxima |
smejky | 4:c7ca936cdd1f | 1066 | if ((touch_x > 25) && (touch_x < 140)){ |
smejky | 4:c7ca936cdd1f | 1067 | |
smejky | 4:c7ca936cdd1f | 1068 | unsigned short int y0 = cudlik[1]; |
smejky | 4:c7ca936cdd1f | 1069 | unsigned short int y1 = cudlik[3]; |
smejky | 4:c7ca936cdd1f | 1070 | unsigned short int x_zadelavani_chyby = cudlik[0]; |
smejky | 4:c7ca936cdd1f | 1071 | unsigned short int x0 = x_zadelavani_chyby - 8; |
smejky | 4:c7ca936cdd1f | 1072 | |
smejky | 4:c7ca936cdd1f | 1073 | //printf("%d\r\n",touch_x); |
smejky | 4:c7ca936cdd1f | 1074 | stred_cudliku[0] = touch_x; |
smejky | 4:c7ca936cdd1f | 1075 | |
smejky | 4:c7ca936cdd1f | 1076 | cudlik[0] = stred_cudliku[0] - 10; |
smejky | 4:c7ca936cdd1f | 1077 | cudlik[1] = stred_cudliku[1] - 25; |
smejky | 4:c7ca936cdd1f | 1078 | cudlik[2] = stred_cudliku[0] + 10; |
smejky | 4:c7ca936cdd1f | 1079 | cudlik[3] = stred_cudliku[1] + 25; |
smejky | 4:c7ca936cdd1f | 1080 | |
smejky | 4:c7ca936cdd1f | 1081 | |
smejky | 4:c7ca936cdd1f | 1082 | |
smejky | 4:c7ca936cdd1f | 1083 | if (touch_x > 34){ |
smejky | 4:c7ca936cdd1f | 1084 | x0 = x_zadelavani_chyby + 8; |
smejky | 4:c7ca936cdd1f | 1085 | spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Green); |
smejky | 4:c7ca936cdd1f | 1086 | |
smejky | 4:c7ca936cdd1f | 1087 | }else{ |
smejky | 4:c7ca936cdd1f | 1088 | spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Black); |
smejky | 4:c7ca936cdd1f | 1089 | } |
smejky | 4:c7ca936cdd1f | 1090 | |
smejky | 4:c7ca936cdd1f | 1091 | if (touch_x < 34){ |
smejky | 4:c7ca936cdd1f | 1092 | spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Black); |
smejky | 4:c7ca936cdd1f | 1093 | |
smejky | 4:c7ca936cdd1f | 1094 | }else{ |
smejky | 4:c7ca936cdd1f | 1095 | x0 = x_zadelavani_chyby + 8; |
smejky | 4:c7ca936cdd1f | 1096 | spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Green); |
smejky | 4:c7ca936cdd1f | 1097 | } |
smejky | 4:c7ca936cdd1f | 1098 | spi.fillrect(cudlik[0],cudlik[1],cudlik[2],cudlik[3],cudlik[4]); |
smejky | 4:c7ca936cdd1f | 1099 | |
smejky | 4:c7ca936cdd1f | 1100 | |
smejky | 4:c7ca936cdd1f | 1101 | |
smejky | 4:c7ca936cdd1f | 1102 | } |
smejky | 4:c7ca936cdd1f | 1103 | } |
smejky | 4:c7ca936cdd1f | 1104 | |
smejky | 4:c7ca936cdd1f | 1105 | //slider */ |
smejky | 4:c7ca936cdd1f | 1106 | |
smejky | 4:c7ca936cdd1f | 1107 |