Toto je má konečná verze maturitního projektu
Dependencies: mbed mbed-rtos UTouch_vyrobek UniGraphic
Diff: display.cpp
- Revision:
- 5:7c757a7c97c5
- Parent:
- 4:c7ca936cdd1f
- Child:
- 6:8b186158b2a3
--- a/display.cpp Sat Dec 11 19:12:09 2021 +0000 +++ b/display.cpp Sun Dec 12 10:02:41 2021 +0000 @@ -15,13 +15,15 @@ */ void grafika(unsigned short int press = 0){ - int pravy[] = {0,0,200,70,Blue}; + int pozadi[] = {0,0,200,320,White}; //pozadi + int pravy[] = {0,0,199,70,Blue}; int levy[] = {0,250,199,320,Blue}; - int cudlik[] = {20,80,38,130,Red}; + // int cudlik[] = {20,80,38,130,Red}; int spodni_levy[] = {200,240,240,320,Green}; int stredni_levy[] = {200,159,240,239,Red}; int stredni_pravy[] = {200,78,240,158,Purple}; - int spodni_pravy[] = {200,0,240,77,Yellow}; + int spodni_pravy[] = {200,0,240,77,Yellow}; + switch(press) { @@ -46,8 +48,8 @@ default: - spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]); //pravy - spi.fillrect(0,140,180,71,Green); //stred + spi.fillrect(pozadi[0],pozadi[1],pozadi[2],pozadi[3],pozadi[4]); //pozadi + spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]); //pravy spi.fillrect(levy[0],levy[1],levy[2],levy[3],levy[4]); //levy spi.fillrect(spodni_levy[0],spodni_levy[1],spodni_levy[2],spodni_levy[3],spodni_levy[4]); //levy kraj spodni spi.fillrect(stredni_levy[0],stredni_levy[1],stredni_levy[2],stredni_levy[3],stredni_levy[4]); //stred levy spodni @@ -74,117 +76,118 @@ } } -void Button(){ - int R_is_pressed = 0; //pro pravy čudlik - int L_is_pressed = 0; //pro levy čudlik - int Ls_is_pressed = 0; //pro levy spodni čudlik - int Sl_is_pressed = 0; //pro levy stredni čudlik - int Sr_is_pressed = 0; //pro pravy stredni čudlik - int Rs_is_pressed = 0; //pro pravy spodni čudlik - +/* +else if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy [1])){ + R_is_pressed = 1; + spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]); + wait(0.1); + } + +*/ + + + +void Button(){ int pravy[] = {0,0,200,70,Black}; //pravý čudlík - int levy[] = {0,250,199,320,Black}; //levý čudlík + int levy[] = {0,250,200,320,Black}; //levý čudlík //int cudlik[] = {20,80,42,130,Orange}; //slider nepovedeny projekt //int stred_cudliku[] = {30,105,Blue}; //střed čudliku int spodni_levy[] = {200,240,240,320,Red}; // levy spodni cudlik int stredni_levy[] = {200,159,240,239,Green}; //stred levy spodni cudlik int stredni_pravy[] = {200,78,240,158,Yellow}; //stred pravy spodni cudlik - int spodni_pravy[] = {200,0,240,77,Purple}; // pravy spodni cudlik - - + int spodni_pravy[] = {200,0,240,77,Purple}; // pravy spodni cudlik while(1) { if (touch.DataAvailable()) { if(touch.Read()) { + + unsigned short int touch_y = touch.GetX(); // 0-320 unsigned short int touch_x = touch.GetY(); // 0-240 touch_x = touch_x - 5; touch_y = touch_y + 10; //spi.pixel(touch_x,touch_y,Blue); - int pressure = touch.GetPressure(); - printf("x %d ,y %d\r\n",touch_x,touch_y); + //printf("x %d ,y %d\r\n",touch_x,touch_y); //pravý čudlik - if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1]) && (R_is_pressed == 1)){ - grafika(R_is_pressed); - R_is_pressed = 0; - wait(0.3); - }else if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy [1])){ - R_is_pressed = 1; + if ((touch_x > pravy[0]) && (touch_x < pravy[2]) && (touch_y < pravy[3]) && (touch_y > pravy[1])){ + int i = touch.DataAvailable(); + while (i){ spi.fillrect(pravy[0],pravy[1],pravy[2],pravy[3],pravy[4]); - wait(0.3); - } + i = touch.DataAvailable(); + } + grafika(1); + wait(0.2); + } + //pravý čudlik //levý čudlik - if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1]) && (L_is_pressed == 2)){ - grafika(L_is_pressed); - L_is_pressed = 0; - wait(0.3); - }else if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ - L_is_pressed = 2; + if ((touch_x > levy[0]) && (touch_x < levy[2]) && (touch_y < levy[3]) && (touch_y > levy[1])){ + int i = touch.DataAvailable(); + while (i){ spi.fillrect(levy[0],levy[1],levy[2],levy[3],levy[4]); - wait(0.3); - } + i = touch.DataAvailable(); + } + grafika(2); + wait(0.2); + } //levý čudlik //levý spodni čudlik - if ((touch_x > spodni_levy[0]) && (touch_x < spodni_levy[2]) && (touch_y < spodni_levy[3]) && (touch_y > spodni_levy[1]) && (Ls_is_pressed == 3)){ - grafika(Ls_is_pressed); - Ls_is_pressed = 0; - wait(0.3); - }else if ((touch_x > spodni_levy[0]) && (touch_x < spodni_levy[2]) && (touch_y < spodni_levy[3]) && (touch_y > spodni_levy[1])){ - Ls_is_pressed = 3; + if ((touch_x > spodni_levy[0]) && (touch_x < spodni_levy[2]) && (touch_y < spodni_levy[3]) && (touch_y > spodni_levy[1])){ + int i = touch.DataAvailable(); + int e = 0; + while (i){ spi.fillrect(spodni_levy[0],spodni_levy[1],spodni_levy[2],spodni_levy[3],spodni_levy[4]); - wait(0.3); - } + i = touch.DataAvailable(); + e++; + } + printf("%d",e); + grafika(3); + wait(0.2); + } //levý spodni čudlik //stred levy spodni cudlik - if ((touch_x > stredni_levy[0]) && (touch_x < stredni_levy[2]) && (touch_y < stredni_levy[3]) && (touch_y > stredni_levy[1]) && (Sl_is_pressed == 4)){ - grafika(Sl_is_pressed); - Sl_is_pressed = 0; - wait(0.3); - }else if ((touch_x > stredni_levy[0]) && (touch_x < stredni_levy[2]) && (touch_y < stredni_levy[3]) && (touch_y > stredni_levy[1])){ - Sl_is_pressed = 4; + if ((touch_x > stredni_levy[0]) && (touch_x < stredni_levy[2]) && (touch_y < stredni_levy[3]) && (touch_y > stredni_levy[1])){ + int i = touch.DataAvailable(); + while (i){ spi.fillrect(stredni_levy[0],stredni_levy[1],stredni_levy[2],stredni_levy[3],stredni_levy[4]); - wait(0.3); - } + i = touch.DataAvailable(); + } + grafika(4); + wait(0.2); + } //stred levy spodni cudlik //stred pravy spodni cudlik - if ((touch_x > stredni_pravy[0]) && (touch_x < stredni_pravy[2]) && (touch_y < stredni_pravy[3]) && (touch_y > stredni_pravy[1]) && (Sr_is_pressed == 5)){ - grafika(Sr_is_pressed); - Sr_is_pressed = 0; - wait(0.3); - }else if ((touch_x > stredni_pravy[0]) && (touch_x < stredni_pravy[2]) && (touch_y < stredni_pravy[3]) && (touch_y > stredni_pravy[1])){ - Sr_is_pressed = 5; + if ((touch_x > stredni_pravy[0]) && (touch_x < stredni_pravy[2]) && (touch_y < stredni_pravy[3]) && (touch_y > stredni_pravy[1])){ + int i = touch.DataAvailable(); + while (i){ spi.fillrect(stredni_pravy[0],stredni_pravy[1],stredni_pravy[2],stredni_pravy[3],stredni_pravy[4]); - wait(0.3); - } + i = touch.DataAvailable(); + } + grafika(5); + wait(0.2); + } //stred pravy spodni cudlik //kraj pravy spodni cudlik - if ((touch_x > spodni_pravy[0]) && (touch_x < spodni_pravy[2]) && (touch_y < spodni_pravy[3]) && (touch_y > spodni_pravy[1]) && (Rs_is_pressed == 6)){ - grafika(Rs_is_pressed); - Rs_is_pressed = 0; - wait(0.3); - }else if ((touch_x > spodni_pravy[0]) && (touch_x < spodni_pravy[2]) && (touch_y < spodni_pravy[3]) && (touch_y > spodni_pravy[1])){ - Rs_is_pressed = 6; + if ((touch_x > spodni_pravy[0]) && (touch_x < spodni_pravy[2]) && (touch_y < spodni_pravy[3]) && (touch_y > spodni_pravy[1])){ + int i = touch.DataAvailable(); + while (i){ spi.fillrect(spodni_pravy[0],spodni_pravy[1],spodni_pravy[2],spodni_pravy[3],spodni_pravy[4]); - wait(0.3); + i = touch.DataAvailable(); + } + grafika(6); + wait(0.2); } //kraj pravy spodni cudlik - - - - - - } }