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

Dependencies:   mbed mbed-rtos UTouch_vyrobek UniGraphic

Committer:
smejky
Date:
Mon Dec 27 15:33:50 2021 +0000
Revision:
8:b6e7401fdcfc
Parent:
7:91b982ccf255
Child:
9:d1385f7171af
save pred tim nez predelam cely projekt kvuli spi.set_orientation(0)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
smejky 7:91b982ccf255 1 #include "display.h"
smejky 7:91b982ccf255 2 #include "rtos.h"
smejky 8:b6e7401fdcfc 3
smejky 3:dadb214885c1 4 UTouch touch(D4,D9,D3,D2,D5);//clk,chip_select,MOSI,miso,irq(pripojeno je ale nevim co to dela)
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 3:dadb214885c1 11
smejky 7:91b982ccf255 12 void led2_thread()
smejky 7:91b982ccf255 13 {
smejky 7:91b982ccf255 14 while (true) {
smejky 7:91b982ccf255 15 led2 = !led2;
smejky 7:91b982ccf255 16 Thread::wait(1000);
smejky 7:91b982ccf255 17 }
smejky 7:91b982ccf255 18 }
smejky 0:6abf63b83992 19
smejky 0:6abf63b83992 20
smejky 0:6abf63b83992 21 /*
smejky 0:6abf63b83992 22 v ILI9341.cpp zmeneny framerate ze 70 na 100, toto pomohlo problemu blikání displeje
smejky 3:dadb214885c1 23 velikost fotky pro čudlik 180x70
smejky 3:dadb214885c1 24 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 25
smejky 0:6abf63b83992 26 */
smejky 0:6abf63b83992 27
smejky 7:91b982ccf255 28
smejky 8:b6e7401fdcfc 29 void grafika(unsigned short int press = 0){
smejky 7:91b982ccf255 30 //int levy[] = {34,274,165,320,Blue};
smejky 5:7c757a7c97c5 31 // int cudlik[] = {20,80,38,130,Red};
smejky 7:91b982ccf255 32 //int spodni_levy[] = {200,240,240,320,Green};
smejky 7:91b982ccf255 33 //int stredni_levy[] = {200,159,240,239,Red};
smejky 4:c7ca936cdd1f 34 int stredni_pravy[] = {200,78,240,158,Purple};
smejky 5:7c757a7c97c5 35 int spodni_pravy[] = {200,0,240,77,Yellow};
smejky 5:7c757a7c97c5 36
smejky 4:c7ca936cdd1f 37
smejky 2:0629f1ddaa92 38 switch(press)
smejky 2:0629f1ddaa92 39 {
smejky 2:0629f1ddaa92 40 case 1:
smejky 7:91b982ccf255 41 //spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]);// pravy
smejky 7:91b982ccf255 42
smejky 7:91b982ccf255 43 spi.Bitmap(34,0,38,46,(unsigned char*)gImage_vrch);
smejky 7:91b982ccf255 44 spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik);// pravy
smejky 7:91b982ccf255 45 spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 46 spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 47
smejky 2:0629f1ddaa92 48 break;
smejky 4:c7ca936cdd1f 49 case 2:
smejky 7:91b982ccf255 50 //spi.fillrect(levy[0],levy[1],levy[2],levy[3],levy[4]);// levy
smejky 7:91b982ccf255 51 spi.Bitmap(34,274,38,46,(unsigned char*)gImage_vrch);
smejky 7:91b982ccf255 52 spi.Bitmap(72,274,42,46,(unsigned char*)gImage_cudlik_otoc);// levy
smejky 7:91b982ccf255 53 spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 54 spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek);
smejky 4:c7ca936cdd1f 55 break;
smejky 4:c7ca936cdd1f 56 case 3:
smejky 7:91b982ccf255 57 spi.Bitmap(200,240,40,80,(unsigned char*)gImage_spodni_levy);// levy kraj spodni
smejky 7:91b982ccf255 58
smejky 7:91b982ccf255 59 //spi.fillrect(spodni_levy[0],spodni_levy[1],spodni_levy[2],spodni_levy[3],spodni_levy[4]);// levy kraj spodni
smejky 2:0629f1ddaa92 60 break;
smejky 4:c7ca936cdd1f 61 case 4:
smejky 7:91b982ccf255 62 //spi.fillrect(stredni_levy[0],stredni_levy[1],stredni_levy[2],stredni_levy[3],stredni_levy[4]);// stred levy spodni
smejky 7:91b982ccf255 63 spi.Bitmap(200,160,40,80,(unsigned char*)gImage_stredni_levy);
smejky 7:91b982ccf255 64
smejky 4:c7ca936cdd1f 65 break;
smejky 4:c7ca936cdd1f 66 case 5:
smejky 4:c7ca936cdd1f 67 spi.fillrect(stredni_pravy[0],stredni_pravy[1],stredni_pravy[2],stredni_pravy[3],stredni_pravy[4]);//stred pravy spodni
smejky 4:c7ca936cdd1f 68 break;
smejky 4:c7ca936cdd1f 69 case 6:
smejky 4:c7ca936cdd1f 70 spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]); //pravy kraj spodni
smejky 4:c7ca936cdd1f 71 break;
smejky 4:c7ca936cdd1f 72
smejky 4:c7ca936cdd1f 73
smejky 4:c7ca936cdd1f 74 default:
smejky 8:b6e7401fdcfc 75 spi.Bitmap(0,46,200,228,(unsigned char*)gImage_pozadi);
smejky 7:91b982ccf255 76
smejky 8:b6e7401fdcfc 77 spi.Bitmap(0,0,36,46,(unsigned char*)gImage_vypln);
smejky 8:b6e7401fdcfc 78 spi.Bitmap(165,0,36,46,(unsigned char*)gImage_vypln);
smejky 8:b6e7401fdcfc 79 spi.Bitmap(0,274,36,46,(unsigned char*)gImage_vypln);
smejky 8:b6e7401fdcfc 80 spi.Bitmap(165,274,36,46,(unsigned char*)gImage_vypln);
smejky 7:91b982ccf255 81
smejky 7:91b982ccf255 82 spi.Bitmap(34,0,38,46,(unsigned char*)gImage_vrch);
smejky 7:91b982ccf255 83 spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik); // pravy
smejky 7:91b982ccf255 84 spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 85 spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek); //pravy
smejky 7:91b982ccf255 86
smejky 7:91b982ccf255 87 spi.Bitmap(34,274,38,46,(unsigned char*)gImage_vrch);
smejky 7:91b982ccf255 88 spi.Bitmap(72,274,42,46,(unsigned char*)gImage_cudlik_otoc);// levy
smejky 7:91b982ccf255 89 spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 90 spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 91
smejky 7:91b982ccf255 92 spi.Bitmap(200,240,40,80,(unsigned char*)gImage_spodni_levy);
smejky 7:91b982ccf255 93 spi.Bitmap(200,160,40,80,(unsigned char*)gImage_stredni_levy);
smejky 8:b6e7401fdcfc 94
smejky 8:b6e7401fdcfc 95
smejky 4:c7ca936cdd1f 96 spi.fillrect(stredni_pravy[0],stredni_pravy[1],stredni_pravy[2],stredni_pravy[3],stredni_pravy[4]); //stred pravy spodni
smejky 4:c7ca936cdd1f 97 spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]); //pravy kraj spodni
smejky 2:0629f1ddaa92 98 }
smejky 2:0629f1ddaa92 99 }
smejky 2:0629f1ddaa92 100
smejky 2:0629f1ddaa92 101 void malovani(){
smejky 2:0629f1ddaa92 102
smejky 1:4dd546219e30 103 while(1==1)
smejky 1:4dd546219e30 104 {
smejky 0:6abf63b83992 105 if (touch.DataAvailable())
smejky 0:6abf63b83992 106 {
smejky 0:6abf63b83992 107 if(touch.Read())
smejky 0:6abf63b83992 108 {
smejky 0:6abf63b83992 109 unsigned short int touch_y = touch.GetX();
smejky 1:4dd546219e30 110 unsigned short int touch_x = touch.GetY();
smejky 0:6abf63b83992 111 touch_x = touch_x - 10;
smejky 2:0629f1ddaa92 112 touch_y = touch_y + 10;
smejky 2:0629f1ddaa92 113 spi.pixel(touch_x,touch_y,Blue);
smejky 2:0629f1ddaa92 114 }
smejky 2:0629f1ddaa92 115 }
smejky 2:0629f1ddaa92 116 }
smejky 2:0629f1ddaa92 117 }
smejky 2:0629f1ddaa92 118
smejky 5:7c757a7c97c5 119 /*
smejky 5:7c757a7c97c5 120 else if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy [1])){
smejky 5:7c757a7c97c5 121 R_is_pressed = 1;
smejky 5:7c757a7c97c5 122 spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]);
smejky 5:7c757a7c97c5 123 wait(0.1);
smejky 5:7c757a7c97c5 124 }
smejky 5:7c757a7c97c5 125
smejky 5:7c757a7c97c5 126 */
smejky 5:7c757a7c97c5 127
smejky 5:7c757a7c97c5 128
smejky 5:7c757a7c97c5 129
smejky 7:91b982ccf255 130
smejky 7:91b982ccf255 131
smejky 7:91b982ccf255 132 void Button(int strana = 0){
smejky 7:91b982ccf255 133 int pravy[] = {34,0,165,46}; //pravý čudlík
smejky 7:91b982ccf255 134 int levy[] = {34,274,165,320,Black}; //levý čudlík
smejky 4:c7ca936cdd1f 135 //int cudlik[] = {20,80,42,130,Orange}; //slider nepovedeny projekt
smejky 4:c7ca936cdd1f 136 //int stred_cudliku[] = {30,105,Blue}; //střed čudliku
smejky 4:c7ca936cdd1f 137 int spodni_levy[] = {200,240,240,320,Red}; // levy spodni cudlik
smejky 4:c7ca936cdd1f 138 int stredni_levy[] = {200,159,240,239,Green}; //stred levy spodni cudlik
smejky 4:c7ca936cdd1f 139 int stredni_pravy[] = {200,78,240,158,Yellow}; //stred pravy spodni cudlik
smejky 7:91b982ccf255 140 int spodni_pravy[] = {200,0,240,77,Purple}; // pravy spodni cudlik
smejky 7:91b982ccf255 141
smejky 7:91b982ccf255 142 int cudlik_1[] = {10,213,58,260};
smejky 8:b6e7401fdcfc 143 int cudlik_2[] = {10,137,58,184};
smejky 8:b6e7401fdcfc 144
smejky 8:b6e7401fdcfc 145
smejky 7:91b982ccf255 146
smejky 7:91b982ccf255 147
smejky 7:91b982ccf255 148 switch(strana){
smejky 7:91b982ccf255 149 case 0:
smejky 7:91b982ccf255 150 printf("default");
smejky 7:91b982ccf255 151 break;
smejky 7:91b982ccf255 152 case 1:
smejky 7:91b982ccf255 153 spodni_levy[4] = Purple;
smejky 7:91b982ccf255 154 stredni_levy[4] = Red;
smejky 7:91b982ccf255 155 stredni_pravy[4] = Green;
smejky 7:91b982ccf255 156 spodni_pravy[4] = Yellow;
smejky 7:91b982ccf255 157 break;
smejky 7:91b982ccf255 158 default:
smejky 7:91b982ccf255 159 printf("default");
smejky 7:91b982ccf255 160 }
smejky 3:dadb214885c1 161 while(1)
smejky 2:0629f1ddaa92 162 {
smejky 2:0629f1ddaa92 163 if (touch.DataAvailable())
smejky 2:0629f1ddaa92 164 {
smejky 2:0629f1ddaa92 165 if(touch.Read())
smejky 2:0629f1ddaa92 166 {
smejky 5:7c757a7c97c5 167
smejky 5:7c757a7c97c5 168
smejky 3:dadb214885c1 169 unsigned short int touch_y = touch.GetX(); // 0-320
smejky 3:dadb214885c1 170 unsigned short int touch_x = touch.GetY(); // 0-240
smejky 3:dadb214885c1 171 touch_x = touch_x - 5;
smejky 2:0629f1ddaa92 172 touch_y = touch_y + 10;
smejky 3:dadb214885c1 173 //spi.pixel(touch_x,touch_y,Blue);
smejky 5:7c757a7c97c5 174 //printf("x %d ,y %d\r\n",touch_x,touch_y);
smejky 3:dadb214885c1 175
smejky 3:dadb214885c1 176 //pravý čudlik
smejky 5:7c757a7c97c5 177 if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){
smejky 7:91b982ccf255 178 int m = strana;
smejky 7:91b982ccf255 179 switch(strana){
smejky 7:91b982ccf255 180 case 0:
smejky 7:91b982ccf255 181 m++;
smejky 7:91b982ccf255 182 break;
smejky 7:91b982ccf255 183 case 1:
smejky 7:91b982ccf255 184 m++;
smejky 7:91b982ccf255 185 break;
smejky 7:91b982ccf255 186 default:
smejky 7:91b982ccf255 187 m = 0;
smejky 7:91b982ccf255 188 }
smejky 5:7c757a7c97c5 189 int i = touch.DataAvailable();
smejky 7:91b982ccf255 190 //GRAFIKA**************************************************
smejky 7:91b982ccf255 191 spi.Bitmap(34,0,38,46,(unsigned char*)gImage_vrch_s);
smejky 7:91b982ccf255 192 spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik_stred_s);
smejky 7:91b982ccf255 193 spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek_s);
smejky 7:91b982ccf255 194 spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek_s);
smejky 7:91b982ccf255 195 //GRAFIKA**************************************************
smejky 5:7c757a7c97c5 196 while (i){
smejky 5:7c757a7c97c5 197 i = touch.DataAvailable();
smejky 7:91b982ccf255 198 }
smejky 5:7c757a7c97c5 199 grafika(1);
smejky 7:91b982ccf255 200 Menu(m);
smejky 5:7c757a7c97c5 201 wait(0.2);
smejky 5:7c757a7c97c5 202 }
smejky 5:7c757a7c97c5 203
smejky 3:dadb214885c1 204 //pravý čudlik
smejky 3:dadb214885c1 205
smejky 4:c7ca936cdd1f 206 //levý čudlik
smejky 5:7c757a7c97c5 207 if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){
smejky 7:91b982ccf255 208 int m = strana;
smejky 7:91b982ccf255 209 switch(strana){
smejky 7:91b982ccf255 210 case 1:
smejky 7:91b982ccf255 211 m--;
smejky 7:91b982ccf255 212 break;
smejky 7:91b982ccf255 213 default:
smejky 8:b6e7401fdcfc 214 m = 1;
smejky 7:91b982ccf255 215 }
smejky 7:91b982ccf255 216 //GRAFIKA**************************************************
smejky 7:91b982ccf255 217 spi.Bitmap(34,274,38,46,(unsigned char*)gImage_vrch_s);
smejky 7:91b982ccf255 218 spi.Bitmap(72,274,42,46,(unsigned char*)gImage_stred_otoc_s);
smejky 7:91b982ccf255 219 spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek_s);
smejky 7:91b982ccf255 220 spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek_s);
smejky 7:91b982ccf255 221 //GRAFIKA**************************************************
smejky 7:91b982ccf255 222
smejky 5:7c757a7c97c5 223 int i = touch.DataAvailable();
smejky 5:7c757a7c97c5 224 while (i){
smejky 5:7c757a7c97c5 225 i = touch.DataAvailable();
smejky 5:7c757a7c97c5 226 }
smejky 5:7c757a7c97c5 227 grafika(2);
smejky 7:91b982ccf255 228 wait(0.2);
smejky 7:91b982ccf255 229 Menu(m);
smejky 5:7c757a7c97c5 230 }
smejky 3:dadb214885c1 231 //levý čudlik
smejky 4:c7ca936cdd1f 232
smejky 4:c7ca936cdd1f 233 //levý spodni čudlik
smejky 5:7c757a7c97c5 234 if ((touch_x > spodni_levy[0]) && (touch_x < spodni_levy[2]) && (touch_y < spodni_levy[3]) && (touch_y > spodni_levy[1])){
smejky 7:91b982ccf255 235 spi.Bitmap(200,240,40,80,(unsigned char*)gImage_spodni_levy_s);
smejky 7:91b982ccf255 236
smejky 7:91b982ccf255 237
smejky 7:91b982ccf255 238
smejky 5:7c757a7c97c5 239 int i = touch.DataAvailable();
smejky 7:91b982ccf255 240 //int e = 0;
smejky 5:7c757a7c97c5 241 while (i){
smejky 5:7c757a7c97c5 242 i = touch.DataAvailable();
smejky 7:91b982ccf255 243 //e++;
smejky 5:7c757a7c97c5 244 }
smejky 7:91b982ccf255 245 //printf("%d",e);
smejky 5:7c757a7c97c5 246 grafika(3);
smejky 5:7c757a7c97c5 247 wait(0.2);
smejky 5:7c757a7c97c5 248 }
smejky 4:c7ca936cdd1f 249 //levý spodni čudlik
smejky 3:dadb214885c1 250
smejky 4:c7ca936cdd1f 251
smejky 4:c7ca936cdd1f 252 //stred levy spodni cudlik
smejky 5:7c757a7c97c5 253 if ((touch_x > stredni_levy[0]) && (touch_x < stredni_levy[2]) && (touch_y < stredni_levy[3]) && (touch_y > stredni_levy[1])){
smejky 5:7c757a7c97c5 254 int i = touch.DataAvailable();
smejky 7:91b982ccf255 255
smejky 7:91b982ccf255 256 spi.Bitmap(200,160,40,80,(unsigned char*)gImage_stredni_levy_s);
smejky 7:91b982ccf255 257
smejky 7:91b982ccf255 258
smejky 7:91b982ccf255 259 thread.start(led2_thread);
smejky 7:91b982ccf255 260
smejky 5:7c757a7c97c5 261 while (i){
smejky 5:7c757a7c97c5 262 i = touch.DataAvailable();
smejky 5:7c757a7c97c5 263 }
smejky 5:7c757a7c97c5 264 grafika(4);
smejky 5:7c757a7c97c5 265 wait(0.2);
smejky 5:7c757a7c97c5 266 }
smejky 4:c7ca936cdd1f 267 //stred levy spodni cudlik
smejky 4:c7ca936cdd1f 268
smejky 4:c7ca936cdd1f 269
smejky 4:c7ca936cdd1f 270 //stred pravy spodni cudlik
smejky 5:7c757a7c97c5 271 if ((touch_x > stredni_pravy[0]) && (touch_x < stredni_pravy[2]) && (touch_y < stredni_pravy[3]) && (touch_y > stredni_pravy[1])){
smejky 7:91b982ccf255 272
smejky 7:91b982ccf255 273 thread.terminate();
smejky 7:91b982ccf255 274
smejky 5:7c757a7c97c5 275 int i = touch.DataAvailable();
smejky 5:7c757a7c97c5 276 while (i){
smejky 4:c7ca936cdd1f 277 spi.fillrect(stredni_pravy[0],stredni_pravy[1],stredni_pravy[2],stredni_pravy[3],stredni_pravy[4]);
smejky 5:7c757a7c97c5 278 i = touch.DataAvailable();
smejky 5:7c757a7c97c5 279 }
smejky 5:7c757a7c97c5 280 grafika(5);
smejky 5:7c757a7c97c5 281 wait(0.2);
smejky 5:7c757a7c97c5 282 }
smejky 4:c7ca936cdd1f 283 //stred pravy spodni cudlik
smejky 4:c7ca936cdd1f 284
smejky 4:c7ca936cdd1f 285 //kraj pravy spodni cudlik
smejky 5:7c757a7c97c5 286 if ((touch_x > spodni_pravy[0]) && (touch_x < spodni_pravy[2]) && (touch_y < spodni_pravy[3]) && (touch_y > spodni_pravy[1])){
smejky 5:7c757a7c97c5 287 int i = touch.DataAvailable();
smejky 5:7c757a7c97c5 288 while (i){
smejky 4:c7ca936cdd1f 289 spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]);
smejky 5:7c757a7c97c5 290 i = touch.DataAvailable();
smejky 5:7c757a7c97c5 291 }
smejky 5:7c757a7c97c5 292 grafika(6);
smejky 5:7c757a7c97c5 293 wait(0.2);
smejky 4:c7ca936cdd1f 294 }
smejky 4:c7ca936cdd1f 295 //kraj pravy spodni cudlik
smejky 7:91b982ccf255 296
smejky 7:91b982ccf255 297 //MENU CUDLIKY**********************************************************************************************************************************************************************************
smejky 7:91b982ccf255 298 //prvni
smejky 8:b6e7401fdcfc 299 if ((touch_x > cudlik_1[0]) && (touch_x < cudlik_1[2]) && (touch_y < cudlik_1[3]) && (touch_y > cudlik_1[1]) && (strana == 1)){
smejky 7:91b982ccf255 300 spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1s_vrch);
smejky 7:91b982ccf255 301 spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1s_spodek);
smejky 7:91b982ccf255 302 int i = touch.DataAvailable();
smejky 7:91b982ccf255 303 while (i){
smejky 7:91b982ccf255 304 i = touch.DataAvailable();
smejky 7:91b982ccf255 305 }
smejky 7:91b982ccf255 306 spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 307 spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 308 wait(0.2);
smejky 8:b6e7401fdcfc 309 Static();
smejky 7:91b982ccf255 310 }
smejky 7:91b982ccf255 311
smejky 7:91b982ccf255 312
smejky 7:91b982ccf255 313 //prvni
smejky 8:b6e7401fdcfc 314 //druhy
smejky 8:b6e7401fdcfc 315 if ((touch_x > cudlik_2[0]) && (touch_x < cudlik_2[2]) && (touch_y < cudlik_2[3]) && (touch_y > cudlik_2[1]) && (strana == 1)){
smejky 8:b6e7401fdcfc 316 spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1s_vrch);
smejky 8:b6e7401fdcfc 317 spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1s_spodek);
smejky 8:b6e7401fdcfc 318 int i = touch.DataAvailable();
smejky 8:b6e7401fdcfc 319 while (i){
smejky 8:b6e7401fdcfc 320 i = touch.DataAvailable();
smejky 8:b6e7401fdcfc 321 }
smejky 8:b6e7401fdcfc 322 spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 8:b6e7401fdcfc 323 spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 8:b6e7401fdcfc 324 wait(0.2);
smejky 8:b6e7401fdcfc 325
smejky 8:b6e7401fdcfc 326 }
smejky 8:b6e7401fdcfc 327
smejky 8:b6e7401fdcfc 328
smejky 8:b6e7401fdcfc 329 //druhy
smejky 3:dadb214885c1 330
smejky 1:4dd546219e30 331 }
smejky 1:4dd546219e30 332 }
smejky 1:4dd546219e30 333 }
smejky 1:4dd546219e30 334 }
smejky 0:6abf63b83992 335
smejky 0:6abf63b83992 336
smejky 0:6abf63b83992 337
smejky 2:0629f1ddaa92 338
smejky 7:91b982ccf255 339
smejky 8:b6e7401fdcfc 340 void Menu(int strana = 0){
smejky 7:91b982ccf255 341 switch(strana)
smejky 7:91b982ccf255 342 {
smejky 7:91b982ccf255 343 case 1:
smejky 7:91b982ccf255 344 spi.Bitmap(0,46,200,228,(unsigned char*)gImage_pozadi);
smejky 7:91b982ccf255 345
smejky 7:91b982ccf255 346
smejky 7:91b982ccf255 347 //CUDLIKY*******************************************************************************
smejky 7:91b982ccf255 348 //prvni rada
smejky 7:91b982ccf255 349 spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 350 spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 351
smejky 8:b6e7401fdcfc 352 spi.Bitmap(10,137,24,47,(unsigned char*)gImage_cudlik2_vrch);
smejky 8:b6e7401fdcfc 353 spi.Bitmap(34,137,24,47,(unsigned char*)gImage_cudlik2_spodek);
smejky 8:b6e7401fdcfc 354
smejky 8:b6e7401fdcfc 355 spi.Bitmap(10,60,24,47,(unsigned char*)gImage_cudlik3_vrch);
smejky 8:b6e7401fdcfc 356 spi.Bitmap(34,60,24,47,(unsigned char*)gImage_cudlik3_spodek);
smejky 7:91b982ccf255 357 //prvni rada
smejky 7:91b982ccf255 358
smejky 7:91b982ccf255 359 //druha rada
smejky 8:b6e7401fdcfc 360 spi.Bitmap(76,213,24,47,(unsigned char*)gImage_cudlik4_vrch);
smejky 8:b6e7401fdcfc 361 spi.Bitmap(100,213,24,47,(unsigned char*)gImage_cudlik4_spodek);
smejky 7:91b982ccf255 362
smejky 7:91b982ccf255 363 spi.Bitmap(76,137,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 364 spi.Bitmap(100,137,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 365
smejky 7:91b982ccf255 366 spi.Bitmap(76,60,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 367 spi.Bitmap(100,60,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 368 // druha rada
smejky 7:91b982ccf255 369
smejky 7:91b982ccf255 370 //treti rada
smejky 7:91b982ccf255 371 spi.Bitmap(142,213,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 372 spi.Bitmap(166,213,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 373
smejky 7:91b982ccf255 374 spi.Bitmap(142,137,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 375 spi.Bitmap(166,137,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 376
smejky 7:91b982ccf255 377 spi.Bitmap(142,60,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 378 spi.Bitmap(166,60,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 379 // treti rada
smejky 7:91b982ccf255 380
smejky 7:91b982ccf255 381 //CUDLIKY*******************************************************************************
smejky 8:b6e7401fdcfc 382
smejky 8:b6e7401fdcfc 383 strana = 1;
smejky 8:b6e7401fdcfc 384 Button(strana);
smejky 8:b6e7401fdcfc 385
smejky 8:b6e7401fdcfc 386 break;
smejky 7:91b982ccf255 387 default:
smejky 8:b6e7401fdcfc 388 spi.Bitmap(0,46,200,228,(unsigned char*)gImage_pozadi);
smejky 7:91b982ccf255 389 strana = 0;
smejky 7:91b982ccf255 390 Button(strana);
smejky 7:91b982ccf255 391 }
smejky 7:91b982ccf255 392 }
smejky 7:91b982ccf255 393
smejky 8:b6e7401fdcfc 394 void Static(){
smejky 8:b6e7401fdcfc 395 int red[] = {76,213,124,260};
smejky 8:b6e7401fdcfc 396 int green[] = {76,137,124,184};
smejky 8:b6e7401fdcfc 397 int blue[] = {76,60,124,107};
smejky 8:b6e7401fdcfc 398
smejky 8:b6e7401fdcfc 399
smejky 8:b6e7401fdcfc 400 int pravy[] = {34,0,165,46}; //pravý čudlík
smejky 8:b6e7401fdcfc 401 int levy[] = {34,274,165,320}; //levý čudlík
smejky 8:b6e7401fdcfc 402
smejky 8:b6e7401fdcfc 403 spi.Bitmap(0,46,200,228,(unsigned char*)gImage_pozadi);
smejky 8:b6e7401fdcfc 404 spi.fillrect(red[0],red[1],red[2],red[3],Red);
smejky 8:b6e7401fdcfc 405 spi.fillrect(green[0],green[1],green[2],green[3],Green);
smejky 8:b6e7401fdcfc 406 spi.fillrect(blue[0],blue[1],blue[2],blue[3],Blue);
smejky 8:b6e7401fdcfc 407
smejky 8:b6e7401fdcfc 408
smejky 8:b6e7401fdcfc 409 int r = 1;
smejky 8:b6e7401fdcfc 410 int g = 1;
smejky 8:b6e7401fdcfc 411 int b = 1;
smejky 8:b6e7401fdcfc 412 while(1)
smejky 8:b6e7401fdcfc 413 {
smejky 8:b6e7401fdcfc 414 if (touch.DataAvailable())
smejky 8:b6e7401fdcfc 415 {
smejky 8:b6e7401fdcfc 416 if(touch.Read())
smejky 8:b6e7401fdcfc 417 {
smejky 8:b6e7401fdcfc 418 unsigned short int touch_y = touch.GetX(); // 0-320
smejky 8:b6e7401fdcfc 419 unsigned short int touch_x = touch.GetY(); // 0-240
smejky 8:b6e7401fdcfc 420
smejky 8:b6e7401fdcfc 421 //pravý čudlik
smejky 8:b6e7401fdcfc 422 if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){
smejky 8:b6e7401fdcfc 423 int i = touch.DataAvailable();
smejky 8:b6e7401fdcfc 424 //GRAFIKA**************************************************
smejky 8:b6e7401fdcfc 425 spi.Bitmap(34,0,38,46,(unsigned char*)gImage_vrch_s);
smejky 8:b6e7401fdcfc 426 spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik_stred_s);
smejky 8:b6e7401fdcfc 427 spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek_s);
smejky 8:b6e7401fdcfc 428 spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek_s);
smejky 8:b6e7401fdcfc 429 //GRAFIKA**************************************************
smejky 8:b6e7401fdcfc 430 while (i){
smejky 8:b6e7401fdcfc 431 i = touch.DataAvailable();
smejky 8:b6e7401fdcfc 432 }
smejky 8:b6e7401fdcfc 433 my_red = r;
smejky 8:b6e7401fdcfc 434 my_green = g;
smejky 8:b6e7401fdcfc 435 my_blue = b;
smejky 8:b6e7401fdcfc 436 grafika(1);
smejky 8:b6e7401fdcfc 437 Menu();
smejky 8:b6e7401fdcfc 438 wait(0.2);
smejky 8:b6e7401fdcfc 439 }
smejky 8:b6e7401fdcfc 440 //pravý čudlik
smejky 8:b6e7401fdcfc 441
smejky 8:b6e7401fdcfc 442 //levý čudlik
smejky 8:b6e7401fdcfc 443 if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){
smejky 8:b6e7401fdcfc 444 //GRAFIKA**************************************************
smejky 8:b6e7401fdcfc 445 spi.Bitmap(34,274,38,46,(unsigned char*)gImage_vrch_s);
smejky 8:b6e7401fdcfc 446 spi.Bitmap(72,274,42,46,(unsigned char*)gImage_stred_otoc_s);
smejky 8:b6e7401fdcfc 447 spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek_s);
smejky 8:b6e7401fdcfc 448 spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek_s);
smejky 8:b6e7401fdcfc 449 //GRAFIKA**************************************************
smejky 8:b6e7401fdcfc 450
smejky 8:b6e7401fdcfc 451 int i = touch.DataAvailable();
smejky 8:b6e7401fdcfc 452 while (i){
smejky 8:b6e7401fdcfc 453 i = touch.DataAvailable();
smejky 8:b6e7401fdcfc 454 }
smejky 8:b6e7401fdcfc 455 grafika(2);
smejky 8:b6e7401fdcfc 456 wait(0.2);
smejky 8:b6e7401fdcfc 457 Menu();
smejky 8:b6e7401fdcfc 458 }
smejky 8:b6e7401fdcfc 459 //levý čudlik
smejky 8:b6e7401fdcfc 460
smejky 8:b6e7401fdcfc 461 if((touch_x > red[0]) && (touch_x < red[2]) && (touch_y < red[3]) && (touch_y > red[1])){
smejky 8:b6e7401fdcfc 462 r = !r;
smejky 8:b6e7401fdcfc 463 printf("%d",r);
smejky 8:b6e7401fdcfc 464 wait(0.2);
smejky 8:b6e7401fdcfc 465 }
smejky 8:b6e7401fdcfc 466
smejky 8:b6e7401fdcfc 467 if((touch_x > green[0]) && (touch_x < green[2]) && (touch_y < green[3]) && (touch_y > green[1])){
smejky 8:b6e7401fdcfc 468 g = !g;
smejky 8:b6e7401fdcfc 469 printf("%d",g);
smejky 8:b6e7401fdcfc 470 wait(0.2);
smejky 8:b6e7401fdcfc 471 }
smejky 8:b6e7401fdcfc 472
smejky 8:b6e7401fdcfc 473 if((touch_x > blue[0]) && (touch_x < blue[2]) && (touch_y < blue[3]) && (touch_y > blue[1])){
smejky 8:b6e7401fdcfc 474 b = !b;
smejky 8:b6e7401fdcfc 475 printf("%d",b);
smejky 8:b6e7401fdcfc 476 wait(0.2);
smejky 8:b6e7401fdcfc 477 }
smejky 8:b6e7401fdcfc 478
smejky 8:b6e7401fdcfc 479 }
smejky 8:b6e7401fdcfc 480 }
smejky 8:b6e7401fdcfc 481 }
smejky 8:b6e7401fdcfc 482
smejky 8:b6e7401fdcfc 483 }
smejky 8:b6e7401fdcfc 484
smejky 8:b6e7401fdcfc 485 void hodiny(){
smejky 8:b6e7401fdcfc 486 set_time(971208480);
smejky 8:b6e7401fdcfc 487 spi.set_font((unsigned char*)Arial19x19);
smejky 8:b6e7401fdcfc 488 while(1){
smejky 8:b6e7401fdcfc 489 time_t seconds = time(NULL);
smejky 8:b6e7401fdcfc 490 seconds = seconds + 7200;
smejky 8:b6e7401fdcfc 491 char buffer[32];
smejky 8:b6e7401fdcfc 492 strftime(buffer, 32, "%R", localtime(&seconds));
smejky 8:b6e7401fdcfc 493 spi.set_orientation(3);
smejky 8:b6e7401fdcfc 494 spi.locate(255,210);
smejky 8:b6e7401fdcfc 495 spi.printf("%s",buffer);
smejky 8:b6e7401fdcfc 496 spi.set_orientation(0);
smejky 8:b6e7401fdcfc 497 wait_ms(1000);
smejky 8:b6e7401fdcfc 498 }
smejky 8:b6e7401fdcfc 499 }
smejky 7:91b982ccf255 500
smejky 0:6abf63b83992 501 main(){
smejky 8:b6e7401fdcfc 502 my_red = 1;
smejky 8:b6e7401fdcfc 503 my_green = 1;
smejky 8:b6e7401fdcfc 504 my_blue = 1;
smejky 8:b6e7401fdcfc 505
smejky 3:dadb214885c1 506 spi.FastWindow(true);
smejky 0:6abf63b83992 507 touch.InitTouch();
smejky 0:6abf63b83992 508 touch.SetPrecision(PREC_EXTREME);
smejky 8:b6e7401fdcfc 509 spi.background(Black);
smejky 8:b6e7401fdcfc 510 spi.foreground(White);
smejky 3:dadb214885c1 511 spi.cls();
smejky 4:c7ca936cdd1f 512 //spi.circle(240,320,20,Black);
smejky 7:91b982ccf255 513 //wait_us();
smejky 8:b6e7401fdcfc 514
smejky 3:dadb214885c1 515 grafika();
smejky 8:b6e7401fdcfc 516 thread.start(hodiny);
smejky 3:dadb214885c1 517 Button();
smejky 8:b6e7401fdcfc 518
smejky 2:0629f1ddaa92 519
smejky 0:6abf63b83992 520 }
smejky 4:c7ca936cdd1f 521
smejky 4:c7ca936cdd1f 522
smejky 4:c7ca936cdd1f 523
smejky 4:c7ca936cdd1f 524
smejky 4:c7ca936cdd1f 525 /* fail projekty
smejky 4:c7ca936cdd1f 526 //slider
smejky 4:c7ca936cdd1f 527 if ((touch_x > cudlik[0]) && (touch_x < cudlik[2]) && (touch_y > cudlik[1]) && (touch_y < cudlik[3]) && (pressure > 0)){
smejky 4:c7ca936cdd1f 528
smejky 4:c7ca936cdd1f 529
smejky 4:c7ca936cdd1f 530 //if je udelany tady pro nastavení minima a maxima
smejky 4:c7ca936cdd1f 531 if ((touch_x > 25) && (touch_x < 140)){
smejky 4:c7ca936cdd1f 532
smejky 4:c7ca936cdd1f 533 unsigned short int y0 = cudlik[1];
smejky 4:c7ca936cdd1f 534 unsigned short int y1 = cudlik[3];
smejky 4:c7ca936cdd1f 535 unsigned short int x_zadelavani_chyby = cudlik[0];
smejky 4:c7ca936cdd1f 536 unsigned short int x0 = x_zadelavani_chyby - 8;
smejky 4:c7ca936cdd1f 537
smejky 4:c7ca936cdd1f 538 //printf("%d\r\n",touch_x);
smejky 4:c7ca936cdd1f 539 stred_cudliku[0] = touch_x;
smejky 4:c7ca936cdd1f 540
smejky 4:c7ca936cdd1f 541 cudlik[0] = stred_cudliku[0] - 10;
smejky 4:c7ca936cdd1f 542 cudlik[1] = stred_cudliku[1] - 25;
smejky 4:c7ca936cdd1f 543 cudlik[2] = stred_cudliku[0] + 10;
smejky 4:c7ca936cdd1f 544 cudlik[3] = stred_cudliku[1] + 25;
smejky 4:c7ca936cdd1f 545
smejky 4:c7ca936cdd1f 546
smejky 4:c7ca936cdd1f 547
smejky 4:c7ca936cdd1f 548 if (touch_x > 34){
smejky 4:c7ca936cdd1f 549 x0 = x_zadelavani_chyby + 8;
smejky 4:c7ca936cdd1f 550 spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Green);
smejky 4:c7ca936cdd1f 551
smejky 4:c7ca936cdd1f 552 }else{
smejky 4:c7ca936cdd1f 553 spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Black);
smejky 4:c7ca936cdd1f 554 }
smejky 4:c7ca936cdd1f 555
smejky 4:c7ca936cdd1f 556 if (touch_x < 34){
smejky 4:c7ca936cdd1f 557 spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Black);
smejky 4:c7ca936cdd1f 558
smejky 4:c7ca936cdd1f 559 }else{
smejky 4:c7ca936cdd1f 560 x0 = x_zadelavani_chyby + 8;
smejky 4:c7ca936cdd1f 561 spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Green);
smejky 4:c7ca936cdd1f 562 }
smejky 4:c7ca936cdd1f 563 spi.fillrect(cudlik[0],cudlik[1],cudlik[2],cudlik[3],cudlik[4]);
smejky 4:c7ca936cdd1f 564
smejky 4:c7ca936cdd1f 565
smejky 4:c7ca936cdd1f 566
smejky 4:c7ca936cdd1f 567 }
smejky 4:c7ca936cdd1f 568 }
smejky 4:c7ca936cdd1f 569
smejky 4:c7ca936cdd1f 570 //slider */
smejky 4:c7ca936cdd1f 571
smejky 4:c7ca936cdd1f 572