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

Dependencies:   mbed mbed-rtos UTouch_vyrobek UniGraphic

Committer:
smejky
Date:
Mon Dec 06 22:21:09 2021 +0000
Revision:
1:4dd546219e30
Parent:
0:6abf63b83992
Child:
2:0629f1ddaa92
button_working;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
smejky 0:6abf63b83992 1 #include "mbed.h"
smejky 0:6abf63b83992 2 #include "ILI9341.h"
smejky 0:6abf63b83992 3 #include "UTouch.h"
smejky 0:6abf63b83992 4
smejky 0:6abf63b83992 5
smejky 0:6abf63b83992 6 ILI9341 spi(SPI_8,320000000,PTD2,PTD3,PTD1,PTC12, PTC3, PTC2, "TFT",240,320);// mosi, miso, sclk, chip_select, reset, dc
smejky 0:6abf63b83992 7 UTouch touch(D4,D9,D3,D2,D5);//clk,chip_select,MOSI,miso,irq(pripojeno je ale nevim co to dela)
smejky 0:6abf63b83992 8
smejky 0:6abf63b83992 9
smejky 0:6abf63b83992 10 /*
smejky 0:6abf63b83992 11 v ILI9341.cpp zmeneny framerate ze 70 na 100, toto pomohlo problemu blikání displeje
smejky 0:6abf63b83992 12
smejky 0:6abf63b83992 13 */
smejky 0:6abf63b83992 14
smejky 0:6abf63b83992 15 void Button(unsigned short int x0, unsigned short int y0,unsigned short int x1, unsigned short int y1,int color){
smejky 0:6abf63b83992 16 spi.fillrect(x0,y0,x1,y1,color);
smejky 1:4dd546219e30 17 while(1==1)
smejky 1:4dd546219e30 18 {
smejky 0:6abf63b83992 19 if (touch.DataAvailable())
smejky 0:6abf63b83992 20 {
smejky 0:6abf63b83992 21 if(touch.Read())
smejky 0:6abf63b83992 22 {
smejky 0:6abf63b83992 23 unsigned short int touch_y = touch.GetX();
smejky 1:4dd546219e30 24 unsigned short int touch_x = touch.GetY();
smejky 0:6abf63b83992 25 touch_x = touch_x - 10;
smejky 1:4dd546219e30 26 touch_y = touch_y + 10;
smejky 0:6abf63b83992 27 if ((touch_x >= x0 && touch_x <= x1)&&(touch_y >= y0 && touch_y <= y1)){
smejky 0:6abf63b83992 28 spi.fillrect(x0,y0,x1,y1,Black);
smejky 1:4dd546219e30 29 wait(0.5);
smejky 1:4dd546219e30 30 spi.fillrect(x0,y0,x1,y1,color);
smejky 0:6abf63b83992 31 }
smejky 1:4dd546219e30 32
smejky 1:4dd546219e30 33
smejky 0:6abf63b83992 34
smejky 0:6abf63b83992 35
smejky 1:4dd546219e30 36 }
smejky 1:4dd546219e30 37 }
smejky 1:4dd546219e30 38 }
smejky 1:4dd546219e30 39 }
smejky 0:6abf63b83992 40
smejky 0:6abf63b83992 41
smejky 0:6abf63b83992 42
smejky 0:6abf63b83992 43 main(){
smejky 0:6abf63b83992 44 spi.background(White);
smejky 0:6abf63b83992 45 spi.cls();
smejky 0:6abf63b83992 46 spi.circle(240, 320, 20, Black);
smejky 0:6abf63b83992 47 touch.InitTouch();
smejky 0:6abf63b83992 48 touch.SetPrecision(PREC_EXTREME);
smejky 1:4dd546219e30 49
smejky 0:6abf63b83992 50
smejky 1:4dd546219e30 51 Button(0,0,180,70,Blue);
smejky 1:4dd546219e30 52 Button(0,320,180,250,Blue);
smejky 0:6abf63b83992 53 }