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

Dependencies:   mbed mbed-rtos UTouch_vyrobek UniGraphic

Committer:
smejky
Date:
Sat Dec 18 14:50:58 2021 +0000
Revision:
7:91b982ccf255
Parent:
6:8b186158b2a3
Child:
8:b6e7401fdcfc
pridane tlacitka + hose

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 3:dadb214885c1 3 UTouch touch(D4,D9,D3,D2,D5);//clk,chip_select,MOSI,miso,irq(pripojeno je ale nevim co to dela)
smejky 0:6abf63b83992 4 ILI9341 spi(SPI_8,320000000,PTD2,PTD3,PTD1,PTC12, PTC3, PTC2, "TFT",240,320);// mosi, miso, sclk, chip_select, reset, dc
smejky 7:91b982ccf255 5 DigitalOut led2(LED2);
smejky 7:91b982ccf255 6 Thread thread;
smejky 3:dadb214885c1 7
smejky 7:91b982ccf255 8 void led2_thread()
smejky 7:91b982ccf255 9 {
smejky 7:91b982ccf255 10 while (true) {
smejky 7:91b982ccf255 11 led2 = !led2;
smejky 7:91b982ccf255 12 Thread::wait(1000);
smejky 7:91b982ccf255 13 }
smejky 7:91b982ccf255 14 }
smejky 0:6abf63b83992 15
smejky 0:6abf63b83992 16
smejky 0:6abf63b83992 17 /*
smejky 0:6abf63b83992 18 v ILI9341.cpp zmeneny framerate ze 70 na 100, toto pomohlo problemu blikání displeje
smejky 3:dadb214885c1 19 velikost fotky pro čudlik 180x70
smejky 3:dadb214885c1 20 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 21
smejky 0:6abf63b83992 22 */
smejky 0:6abf63b83992 23
smejky 7:91b982ccf255 24
smejky 4:c7ca936cdd1f 25 void grafika(unsigned short int press = 0){
smejky 5:7c757a7c97c5 26 int pozadi[] = {0,0,200,320,White}; //pozadi
smejky 7:91b982ccf255 27
smejky 7:91b982ccf255 28
smejky 7:91b982ccf255 29 //int levy[] = {34,274,165,320,Blue};
smejky 5:7c757a7c97c5 30 // int cudlik[] = {20,80,38,130,Red};
smejky 7:91b982ccf255 31 //int spodni_levy[] = {200,240,240,320,Green};
smejky 7:91b982ccf255 32 //int stredni_levy[] = {200,159,240,239,Red};
smejky 4:c7ca936cdd1f 33 int stredni_pravy[] = {200,78,240,158,Purple};
smejky 5:7c757a7c97c5 34 int spodni_pravy[] = {200,0,240,77,Yellow};
smejky 5:7c757a7c97c5 35
smejky 4:c7ca936cdd1f 36
smejky 2:0629f1ddaa92 37 switch(press)
smejky 2:0629f1ddaa92 38 {
smejky 2:0629f1ddaa92 39 case 1:
smejky 7:91b982ccf255 40 //spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]);// pravy
smejky 7:91b982ccf255 41
smejky 7:91b982ccf255 42 spi.Bitmap(34,0,38,46,(unsigned char*)gImage_vrch);
smejky 7:91b982ccf255 43 spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik);// pravy
smejky 7:91b982ccf255 44 spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 45 spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 46
smejky 2:0629f1ddaa92 47 break;
smejky 4:c7ca936cdd1f 48 case 2:
smejky 7:91b982ccf255 49 //spi.fillrect(levy[0],levy[1],levy[2],levy[3],levy[4]);// levy
smejky 7:91b982ccf255 50 spi.Bitmap(34,274,38,46,(unsigned char*)gImage_vrch);
smejky 7:91b982ccf255 51 spi.Bitmap(72,274,42,46,(unsigned char*)gImage_cudlik_otoc);// levy
smejky 7:91b982ccf255 52 spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 53 spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek);
smejky 4:c7ca936cdd1f 54 break;
smejky 4:c7ca936cdd1f 55 case 3:
smejky 7:91b982ccf255 56 spi.Bitmap(200,240,40,80,(unsigned char*)gImage_spodni_levy);// levy kraj spodni
smejky 7:91b982ccf255 57
smejky 7:91b982ccf255 58 //spi.fillrect(spodni_levy[0],spodni_levy[1],spodni_levy[2],spodni_levy[3],spodni_levy[4]);// levy kraj spodni
smejky 2:0629f1ddaa92 59 break;
smejky 4:c7ca936cdd1f 60 case 4:
smejky 7:91b982ccf255 61 //spi.fillrect(stredni_levy[0],stredni_levy[1],stredni_levy[2],stredni_levy[3],stredni_levy[4]);// stred levy spodni
smejky 7:91b982ccf255 62 spi.Bitmap(200,160,40,80,(unsigned char*)gImage_stredni_levy);
smejky 7:91b982ccf255 63
smejky 4:c7ca936cdd1f 64 break;
smejky 4:c7ca936cdd1f 65 case 5:
smejky 4:c7ca936cdd1f 66 spi.fillrect(stredni_pravy[0],stredni_pravy[1],stredni_pravy[2],stredni_pravy[3],stredni_pravy[4]);//stred pravy spodni
smejky 4:c7ca936cdd1f 67 break;
smejky 4:c7ca936cdd1f 68 case 6:
smejky 4:c7ca936cdd1f 69 spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]); //pravy kraj spodni
smejky 4:c7ca936cdd1f 70 break;
smejky 4:c7ca936cdd1f 71
smejky 4:c7ca936cdd1f 72
smejky 4:c7ca936cdd1f 73 default:
smejky 7:91b982ccf255 74 spi.fillrect(pozadi[0],pozadi[1],pozadi[2],pozadi[3],pozadi[4]);//pozadi
smejky 7:91b982ccf255 75
smejky 7:91b982ccf255 76
smejky 7:91b982ccf255 77 spi.Bitmap(34,0,38,46,(unsigned char*)gImage_vrch);
smejky 7:91b982ccf255 78 spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik); // pravy
smejky 7:91b982ccf255 79 spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 80 spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek); //pravy
smejky 7:91b982ccf255 81
smejky 7:91b982ccf255 82 spi.Bitmap(34,274,38,46,(unsigned char*)gImage_vrch);
smejky 7:91b982ccf255 83 spi.Bitmap(72,274,42,46,(unsigned char*)gImage_cudlik_otoc);// levy
smejky 7:91b982ccf255 84 spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 85 spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek);
smejky 7:91b982ccf255 86
smejky 7:91b982ccf255 87 //spi.fillrect(levy[0],levy[1],levy[2],levy[3],levy[4]); //levy
smejky 7:91b982ccf255 88 //spi.fillrect(spodni_levy[0],spodni_levy[1],spodni_levy[2],spodni_levy[3],spodni_levy[4]); //levy kraj spodni
smejky 7:91b982ccf255 89 spi.Bitmap(200,240,40,80,(unsigned char*)gImage_spodni_levy);
smejky 7:91b982ccf255 90 spi.Bitmap(200,160,40,80,(unsigned char*)gImage_stredni_levy);
smejky 7:91b982ccf255 91 //spi.fillrect(stredni_levy[0],stredni_levy[1],stredni_levy[2],stredni_levy[3],stredni_levy[4]); //stred levy spodni
smejky 4:c7ca936cdd1f 92 spi.fillrect(stredni_pravy[0],stredni_pravy[1],stredni_pravy[2],stredni_pravy[3],stredni_pravy[4]); //stred pravy spodni
smejky 4:c7ca936cdd1f 93 spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]); //pravy kraj spodni
smejky 2:0629f1ddaa92 94 }
smejky 2:0629f1ddaa92 95 }
smejky 2:0629f1ddaa92 96
smejky 2:0629f1ddaa92 97 void malovani(){
smejky 2:0629f1ddaa92 98
smejky 1:4dd546219e30 99 while(1==1)
smejky 1:4dd546219e30 100 {
smejky 0:6abf63b83992 101 if (touch.DataAvailable())
smejky 0:6abf63b83992 102 {
smejky 0:6abf63b83992 103 if(touch.Read())
smejky 0:6abf63b83992 104 {
smejky 0:6abf63b83992 105 unsigned short int touch_y = touch.GetX();
smejky 1:4dd546219e30 106 unsigned short int touch_x = touch.GetY();
smejky 0:6abf63b83992 107 touch_x = touch_x - 10;
smejky 2:0629f1ddaa92 108 touch_y = touch_y + 10;
smejky 2:0629f1ddaa92 109 spi.pixel(touch_x,touch_y,Blue);
smejky 2:0629f1ddaa92 110 }
smejky 2:0629f1ddaa92 111 }
smejky 2:0629f1ddaa92 112 }
smejky 2:0629f1ddaa92 113 }
smejky 2:0629f1ddaa92 114
smejky 5:7c757a7c97c5 115 /*
smejky 5:7c757a7c97c5 116 else if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy [1])){
smejky 5:7c757a7c97c5 117 R_is_pressed = 1;
smejky 5:7c757a7c97c5 118 spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]);
smejky 5:7c757a7c97c5 119 wait(0.1);
smejky 5:7c757a7c97c5 120 }
smejky 5:7c757a7c97c5 121
smejky 5:7c757a7c97c5 122 */
smejky 5:7c757a7c97c5 123
smejky 5:7c757a7c97c5 124
smejky 5:7c757a7c97c5 125
smejky 7:91b982ccf255 126
smejky 7:91b982ccf255 127
smejky 7:91b982ccf255 128 void Button(int strana = 0){
smejky 7:91b982ccf255 129 int pravy[] = {34,0,165,46}; //pravý čudlík
smejky 7:91b982ccf255 130 int levy[] = {34,274,165,320,Black}; //levý čudlík
smejky 4:c7ca936cdd1f 131 //int cudlik[] = {20,80,42,130,Orange}; //slider nepovedeny projekt
smejky 4:c7ca936cdd1f 132 //int stred_cudliku[] = {30,105,Blue}; //střed čudliku
smejky 4:c7ca936cdd1f 133 int spodni_levy[] = {200,240,240,320,Red}; // levy spodni cudlik
smejky 4:c7ca936cdd1f 134 int stredni_levy[] = {200,159,240,239,Green}; //stred levy spodni cudlik
smejky 4:c7ca936cdd1f 135 int stredni_pravy[] = {200,78,240,158,Yellow}; //stred pravy spodni cudlik
smejky 7:91b982ccf255 136 int spodni_pravy[] = {200,0,240,77,Purple}; // pravy spodni cudlik
smejky 7:91b982ccf255 137
smejky 7:91b982ccf255 138 int cudlik_1[] = {10,213,58,260};
smejky 7:91b982ccf255 139
smejky 7:91b982ccf255 140
smejky 7:91b982ccf255 141 switch(strana){
smejky 7:91b982ccf255 142 case 0:
smejky 7:91b982ccf255 143 printf("default");
smejky 7:91b982ccf255 144 break;
smejky 7:91b982ccf255 145 case 1:
smejky 7:91b982ccf255 146 spodni_levy[4] = Purple;
smejky 7:91b982ccf255 147 stredni_levy[4] = Red;
smejky 7:91b982ccf255 148 stredni_pravy[4] = Green;
smejky 7:91b982ccf255 149 spodni_pravy[4] = Yellow;
smejky 7:91b982ccf255 150 break;
smejky 7:91b982ccf255 151 default:
smejky 7:91b982ccf255 152 printf("default");
smejky 7:91b982ccf255 153 }
smejky 3:dadb214885c1 154 while(1)
smejky 2:0629f1ddaa92 155 {
smejky 2:0629f1ddaa92 156 if (touch.DataAvailable())
smejky 2:0629f1ddaa92 157 {
smejky 2:0629f1ddaa92 158 if(touch.Read())
smejky 2:0629f1ddaa92 159 {
smejky 5:7c757a7c97c5 160
smejky 5:7c757a7c97c5 161
smejky 3:dadb214885c1 162 unsigned short int touch_y = touch.GetX(); // 0-320
smejky 3:dadb214885c1 163 unsigned short int touch_x = touch.GetY(); // 0-240
smejky 3:dadb214885c1 164 touch_x = touch_x - 5;
smejky 2:0629f1ddaa92 165 touch_y = touch_y + 10;
smejky 3:dadb214885c1 166 //spi.pixel(touch_x,touch_y,Blue);
smejky 5:7c757a7c97c5 167 //printf("x %d ,y %d\r\n",touch_x,touch_y);
smejky 3:dadb214885c1 168
smejky 3:dadb214885c1 169 //pravý čudlik
smejky 5:7c757a7c97c5 170 if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){
smejky 7:91b982ccf255 171 int m = strana;
smejky 7:91b982ccf255 172 switch(strana){
smejky 7:91b982ccf255 173 case 0:
smejky 7:91b982ccf255 174 m++;
smejky 7:91b982ccf255 175 break;
smejky 7:91b982ccf255 176 case 1:
smejky 7:91b982ccf255 177 m++;
smejky 7:91b982ccf255 178 break;
smejky 7:91b982ccf255 179 case 2:
smejky 7:91b982ccf255 180 m++;
smejky 7:91b982ccf255 181 break;
smejky 7:91b982ccf255 182 default:
smejky 7:91b982ccf255 183 m = 0;
smejky 7:91b982ccf255 184 }
smejky 5:7c757a7c97c5 185 int i = touch.DataAvailable();
smejky 7:91b982ccf255 186 //GRAFIKA**************************************************
smejky 7:91b982ccf255 187 spi.Bitmap(34,0,38,46,(unsigned char*)gImage_vrch_s);
smejky 7:91b982ccf255 188 spi.Bitmap(72,0,42,46,(unsigned char*)gImage_cudlik_stred_s);
smejky 7:91b982ccf255 189 spi.Bitmap(114,0,26,46,(unsigned char*)gImage_spodek_s);
smejky 7:91b982ccf255 190 spi.Bitmap(140,0,26,46,(unsigned char*)gImage_spodek_s);
smejky 7:91b982ccf255 191 //GRAFIKA**************************************************
smejky 5:7c757a7c97c5 192 while (i){
smejky 5:7c757a7c97c5 193 i = touch.DataAvailable();
smejky 7:91b982ccf255 194 }
smejky 5:7c757a7c97c5 195 grafika(1);
smejky 7:91b982ccf255 196 Menu(m);
smejky 5:7c757a7c97c5 197 wait(0.2);
smejky 5:7c757a7c97c5 198 }
smejky 5:7c757a7c97c5 199
smejky 3:dadb214885c1 200 //pravý čudlik
smejky 3:dadb214885c1 201
smejky 4:c7ca936cdd1f 202 //levý čudlik
smejky 5:7c757a7c97c5 203 if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){
smejky 7:91b982ccf255 204 int m = strana;
smejky 7:91b982ccf255 205 switch(strana){
smejky 7:91b982ccf255 206 case 1:
smejky 7:91b982ccf255 207 m--;
smejky 7:91b982ccf255 208 break;
smejky 7:91b982ccf255 209 case 2:
smejky 7:91b982ccf255 210 m--;
smejky 7:91b982ccf255 211 break;
smejky 7:91b982ccf255 212 default:
smejky 7:91b982ccf255 213 m = 2;
smejky 7:91b982ccf255 214 }
smejky 7:91b982ccf255 215 //GRAFIKA**************************************************
smejky 7:91b982ccf255 216 spi.Bitmap(34,274,38,46,(unsigned char*)gImage_vrch_s);
smejky 7:91b982ccf255 217 spi.Bitmap(72,274,42,46,(unsigned char*)gImage_stred_otoc_s);
smejky 7:91b982ccf255 218 spi.Bitmap(114,274,26,46,(unsigned char*)gImage_spodek_s);
smejky 7:91b982ccf255 219 spi.Bitmap(140,274,26,46,(unsigned char*)gImage_spodek_s);
smejky 7:91b982ccf255 220 //GRAFIKA**************************************************
smejky 7:91b982ccf255 221
smejky 5:7c757a7c97c5 222 int i = touch.DataAvailable();
smejky 5:7c757a7c97c5 223 while (i){
smejky 5:7c757a7c97c5 224 i = touch.DataAvailable();
smejky 5:7c757a7c97c5 225 }
smejky 5:7c757a7c97c5 226 grafika(2);
smejky 7:91b982ccf255 227 wait(0.2);
smejky 7:91b982ccf255 228 Menu(m);
smejky 5:7c757a7c97c5 229 }
smejky 3:dadb214885c1 230 //levý čudlik
smejky 4:c7ca936cdd1f 231
smejky 4:c7ca936cdd1f 232 //levý spodni čudlik
smejky 5:7c757a7c97c5 233 if ((touch_x > spodni_levy[0]) && (touch_x < spodni_levy[2]) && (touch_y < spodni_levy[3]) && (touch_y > spodni_levy[1])){
smejky 7:91b982ccf255 234 spi.Bitmap(200,240,40,80,(unsigned char*)gImage_spodni_levy_s);
smejky 7:91b982ccf255 235
smejky 7:91b982ccf255 236
smejky 7:91b982ccf255 237
smejky 5:7c757a7c97c5 238 int i = touch.DataAvailable();
smejky 7:91b982ccf255 239 //int e = 0;
smejky 5:7c757a7c97c5 240 while (i){
smejky 5:7c757a7c97c5 241 i = touch.DataAvailable();
smejky 7:91b982ccf255 242 //e++;
smejky 5:7c757a7c97c5 243 }
smejky 7:91b982ccf255 244 //printf("%d",e);
smejky 5:7c757a7c97c5 245 grafika(3);
smejky 5:7c757a7c97c5 246 wait(0.2);
smejky 5:7c757a7c97c5 247 }
smejky 4:c7ca936cdd1f 248 //levý spodni čudlik
smejky 3:dadb214885c1 249
smejky 4:c7ca936cdd1f 250
smejky 4:c7ca936cdd1f 251 //stred levy spodni cudlik
smejky 5:7c757a7c97c5 252 if ((touch_x > stredni_levy[0]) && (touch_x < stredni_levy[2]) && (touch_y < stredni_levy[3]) && (touch_y > stredni_levy[1])){
smejky 5:7c757a7c97c5 253 int i = touch.DataAvailable();
smejky 7:91b982ccf255 254
smejky 7:91b982ccf255 255 spi.Bitmap(200,160,40,80,(unsigned char*)gImage_stredni_levy_s);
smejky 7:91b982ccf255 256
smejky 7:91b982ccf255 257
smejky 7:91b982ccf255 258 thread.start(led2_thread);
smejky 7:91b982ccf255 259
smejky 5:7c757a7c97c5 260 while (i){
smejky 5:7c757a7c97c5 261 i = touch.DataAvailable();
smejky 5:7c757a7c97c5 262 }
smejky 5:7c757a7c97c5 263 grafika(4);
smejky 5:7c757a7c97c5 264 wait(0.2);
smejky 5:7c757a7c97c5 265 }
smejky 4:c7ca936cdd1f 266 //stred levy spodni cudlik
smejky 4:c7ca936cdd1f 267
smejky 4:c7ca936cdd1f 268
smejky 4:c7ca936cdd1f 269 //stred pravy spodni cudlik
smejky 5:7c757a7c97c5 270 if ((touch_x > stredni_pravy[0]) && (touch_x < stredni_pravy[2]) && (touch_y < stredni_pravy[3]) && (touch_y > stredni_pravy[1])){
smejky 7:91b982ccf255 271
smejky 7:91b982ccf255 272 thread.terminate();
smejky 7:91b982ccf255 273
smejky 5:7c757a7c97c5 274 int i = touch.DataAvailable();
smejky 5:7c757a7c97c5 275 while (i){
smejky 4:c7ca936cdd1f 276 spi.fillrect(stredni_pravy[0],stredni_pravy[1],stredni_pravy[2],stredni_pravy[3],stredni_pravy[4]);
smejky 5:7c757a7c97c5 277 i = touch.DataAvailable();
smejky 5:7c757a7c97c5 278 }
smejky 5:7c757a7c97c5 279 grafika(5);
smejky 5:7c757a7c97c5 280 wait(0.2);
smejky 5:7c757a7c97c5 281 }
smejky 4:c7ca936cdd1f 282 //stred pravy spodni cudlik
smejky 4:c7ca936cdd1f 283
smejky 4:c7ca936cdd1f 284 //kraj pravy spodni cudlik
smejky 5:7c757a7c97c5 285 if ((touch_x > spodni_pravy[0]) && (touch_x < spodni_pravy[2]) && (touch_y < spodni_pravy[3]) && (touch_y > spodni_pravy[1])){
smejky 5:7c757a7c97c5 286 int i = touch.DataAvailable();
smejky 5:7c757a7c97c5 287 while (i){
smejky 4:c7ca936cdd1f 288 spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]);
smejky 5:7c757a7c97c5 289 i = touch.DataAvailable();
smejky 5:7c757a7c97c5 290 }
smejky 5:7c757a7c97c5 291 grafika(6);
smejky 5:7c757a7c97c5 292 wait(0.2);
smejky 4:c7ca936cdd1f 293 }
smejky 4:c7ca936cdd1f 294 //kraj pravy spodni cudlik
smejky 7:91b982ccf255 295
smejky 7:91b982ccf255 296 //MENU CUDLIKY**********************************************************************************************************************************************************************************
smejky 7:91b982ccf255 297 //prvni
smejky 7:91b982ccf255 298 if ((touch_x > cudlik_1[0]) && (touch_x < cudlik_1[2]) && (touch_y < cudlik_1[3]) && (touch_y > cudlik_1[1]) && (strana == 2)){
smejky 7:91b982ccf255 299 spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1s_vrch);
smejky 7:91b982ccf255 300 spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1s_spodek);
smejky 7:91b982ccf255 301 int i = touch.DataAvailable();
smejky 7:91b982ccf255 302 while (i){
smejky 7:91b982ccf255 303 i = touch.DataAvailable();
smejky 7:91b982ccf255 304 }
smejky 7:91b982ccf255 305 spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 306 spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 307 wait(0.2);
smejky 7:91b982ccf255 308 }
smejky 7:91b982ccf255 309
smejky 7:91b982ccf255 310
smejky 7:91b982ccf255 311 //prvni
smejky 7:91b982ccf255 312
smejky 3:dadb214885c1 313
smejky 1:4dd546219e30 314 }
smejky 1:4dd546219e30 315 }
smejky 1:4dd546219e30 316 }
smejky 1:4dd546219e30 317 }
smejky 0:6abf63b83992 318
smejky 0:6abf63b83992 319
smejky 0:6abf63b83992 320
smejky 2:0629f1ddaa92 321
smejky 7:91b982ccf255 322
smejky 7:91b982ccf255 323 void Menu(int strana = 0){
smejky 7:91b982ccf255 324 int pozadi[] = {0,46,199,273,White}; //pozadi
smejky 7:91b982ccf255 325
smejky 7:91b982ccf255 326 switch(strana)
smejky 7:91b982ccf255 327 {
smejky 7:91b982ccf255 328 case 1:
smejky 7:91b982ccf255 329 pozadi[4] = Green;
smejky 7:91b982ccf255 330 //spi.fillrect(pozadi[0],pozadi[1],pozadi[2],pozadi[3],pozadi[4]); //pozadi
smejky 7:91b982ccf255 331 spi.Bitmap(0,46,200,228,(unsigned char*)gImage_pozadi);
smejky 7:91b982ccf255 332 spi.Bitmap(0,0,34,46,(unsigned char*)gImage_vypln);
smejky 7:91b982ccf255 333 spi.Bitmap(165,0,34,46,(unsigned char*)gImage_vypln);
smejky 7:91b982ccf255 334 spi.Bitmap(0,274,34,46,(unsigned char*)gImage_vypln);
smejky 7:91b982ccf255 335 spi.Bitmap(165,274,34,46,(unsigned char*)gImage_vypln);
smejky 7:91b982ccf255 336
smejky 7:91b982ccf255 337 strana = 1;
smejky 7:91b982ccf255 338 Button(strana);
smejky 7:91b982ccf255 339 break;
smejky 7:91b982ccf255 340
smejky 7:91b982ccf255 341
smejky 7:91b982ccf255 342 case 2:
smejky 7:91b982ccf255 343 pozadi[4] = Orange;
smejky 7:91b982ccf255 344 spi.fillrect(pozadi[0],pozadi[1],pozadi[2],pozadi[3],pozadi[4]); //pozadi
smejky 7:91b982ccf255 345
smejky 7:91b982ccf255 346 //CUDLIKY*******************************************************************************
smejky 7:91b982ccf255 347 //prvni rada
smejky 7:91b982ccf255 348 spi.Bitmap(10,213,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 349 spi.Bitmap(34,213,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 350
smejky 7:91b982ccf255 351 spi.Bitmap(10,137,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 352 spi.Bitmap(34,137,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 353
smejky 7:91b982ccf255 354 spi.Bitmap(10,60,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 355 spi.Bitmap(34,60,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 356 //prvni rada
smejky 7:91b982ccf255 357
smejky 7:91b982ccf255 358 //druha rada
smejky 7:91b982ccf255 359 spi.Bitmap(76,213,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 360 spi.Bitmap(100,213,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 361
smejky 7:91b982ccf255 362 spi.Bitmap(76,137,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 363 spi.Bitmap(100,137,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 364
smejky 7:91b982ccf255 365 spi.Bitmap(76,60,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 366 spi.Bitmap(100,60,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 367 // druha rada
smejky 7:91b982ccf255 368
smejky 7:91b982ccf255 369 //treti rada
smejky 7:91b982ccf255 370 spi.Bitmap(142,213,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 371 spi.Bitmap(166,213,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 372
smejky 7:91b982ccf255 373 spi.Bitmap(142,137,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 374 spi.Bitmap(166,137,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 375
smejky 7:91b982ccf255 376 spi.Bitmap(142,60,24,47,(unsigned char*)gImage_cudlik1_vrch);
smejky 7:91b982ccf255 377 spi.Bitmap(166,60,24,47,(unsigned char*)gImage_cudlik1_spodek);
smejky 7:91b982ccf255 378 // treti rada
smejky 7:91b982ccf255 379
smejky 7:91b982ccf255 380 //CUDLIKY*******************************************************************************
smejky 7:91b982ccf255 381
smejky 7:91b982ccf255 382
smejky 7:91b982ccf255 383
smejky 7:91b982ccf255 384 strana = 2;
smejky 7:91b982ccf255 385 Button(strana);
smejky 7:91b982ccf255 386 break;
smejky 7:91b982ccf255 387
smejky 7:91b982ccf255 388
smejky 7:91b982ccf255 389 default:
smejky 7:91b982ccf255 390 spi.fillrect(pozadi[0],pozadi[1],pozadi[2],pozadi[3],pozadi[4]);
smejky 7:91b982ccf255 391 strana = 0;
smejky 7:91b982ccf255 392 Button(strana);
smejky 7:91b982ccf255 393 }
smejky 7:91b982ccf255 394 }
smejky 7:91b982ccf255 395
smejky 7:91b982ccf255 396
smejky 0:6abf63b83992 397 main(){
smejky 3:dadb214885c1 398 spi.FastWindow(true);
smejky 0:6abf63b83992 399 touch.InitTouch();
smejky 0:6abf63b83992 400 touch.SetPrecision(PREC_EXTREME);
smejky 3:dadb214885c1 401 spi.background(White);
smejky 3:dadb214885c1 402 spi.cls();
smejky 4:c7ca936cdd1f 403 //spi.circle(240,320,20,Black);
smejky 7:91b982ccf255 404 //wait_us();
smejky 7:91b982ccf255 405
smejky 0:6abf63b83992 406
smejky 3:dadb214885c1 407 grafika();
smejky 3:dadb214885c1 408 Button();
smejky 3:dadb214885c1 409
smejky 2:0629f1ddaa92 410
smejky 0:6abf63b83992 411 }
smejky 4:c7ca936cdd1f 412
smejky 4:c7ca936cdd1f 413
smejky 4:c7ca936cdd1f 414
smejky 4:c7ca936cdd1f 415
smejky 4:c7ca936cdd1f 416 /* fail projekty
smejky 4:c7ca936cdd1f 417 //slider
smejky 4:c7ca936cdd1f 418 if ((touch_x > cudlik[0]) && (touch_x < cudlik[2]) && (touch_y > cudlik[1]) && (touch_y < cudlik[3]) && (pressure > 0)){
smejky 4:c7ca936cdd1f 419
smejky 4:c7ca936cdd1f 420
smejky 4:c7ca936cdd1f 421 //if je udelany tady pro nastavení minima a maxima
smejky 4:c7ca936cdd1f 422 if ((touch_x > 25) && (touch_x < 140)){
smejky 4:c7ca936cdd1f 423
smejky 4:c7ca936cdd1f 424 unsigned short int y0 = cudlik[1];
smejky 4:c7ca936cdd1f 425 unsigned short int y1 = cudlik[3];
smejky 4:c7ca936cdd1f 426 unsigned short int x_zadelavani_chyby = cudlik[0];
smejky 4:c7ca936cdd1f 427 unsigned short int x0 = x_zadelavani_chyby - 8;
smejky 4:c7ca936cdd1f 428
smejky 4:c7ca936cdd1f 429 //printf("%d\r\n",touch_x);
smejky 4:c7ca936cdd1f 430 stred_cudliku[0] = touch_x;
smejky 4:c7ca936cdd1f 431
smejky 4:c7ca936cdd1f 432 cudlik[0] = stred_cudliku[0] - 10;
smejky 4:c7ca936cdd1f 433 cudlik[1] = stred_cudliku[1] - 25;
smejky 4:c7ca936cdd1f 434 cudlik[2] = stred_cudliku[0] + 10;
smejky 4:c7ca936cdd1f 435 cudlik[3] = stred_cudliku[1] + 25;
smejky 4:c7ca936cdd1f 436
smejky 4:c7ca936cdd1f 437
smejky 4:c7ca936cdd1f 438
smejky 4:c7ca936cdd1f 439 if (touch_x > 34){
smejky 4:c7ca936cdd1f 440 x0 = x_zadelavani_chyby + 8;
smejky 4:c7ca936cdd1f 441 spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Green);
smejky 4:c7ca936cdd1f 442
smejky 4:c7ca936cdd1f 443 }else{
smejky 4:c7ca936cdd1f 444 spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Black);
smejky 4:c7ca936cdd1f 445 }
smejky 4:c7ca936cdd1f 446
smejky 4:c7ca936cdd1f 447 if (touch_x < 34){
smejky 4:c7ca936cdd1f 448 spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Black);
smejky 4:c7ca936cdd1f 449
smejky 4:c7ca936cdd1f 450 }else{
smejky 4:c7ca936cdd1f 451 x0 = x_zadelavani_chyby + 8;
smejky 4:c7ca936cdd1f 452 spi.fillrect(x0,y0,x_zadelavani_chyby,y1,Green);
smejky 4:c7ca936cdd1f 453 }
smejky 4:c7ca936cdd1f 454 spi.fillrect(cudlik[0],cudlik[1],cudlik[2],cudlik[3],cudlik[4]);
smejky 4:c7ca936cdd1f 455
smejky 4:c7ca936cdd1f 456
smejky 4:c7ca936cdd1f 457
smejky 4:c7ca936cdd1f 458 }
smejky 4:c7ca936cdd1f 459 }
smejky 4:c7ca936cdd1f 460
smejky 4:c7ca936cdd1f 461 //slider */
smejky 4:c7ca936cdd1f 462
smejky 4:c7ca936cdd1f 463