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

Dependencies:   mbed mbed-rtos UTouch_vyrobek UniGraphic

Committer:
smejky
Date:
Mon Dec 06 22:07:00 2021 +0000
Revision:
0:6abf63b83992
Child:
1:4dd546219e30
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 0:6abf63b83992 17 //spi.fillrect(0,320,180,315,Purple);
smejky 0:6abf63b83992 18 //spi.fillrect(0,250,180,245,Purple);
smejky 0:6abf63b83992 19 //spi.fillrect(0,320,5,250,Purple);
smejky 0:6abf63b83992 20 while(1==1){
smejky 0:6abf63b83992 21 if (touch.DataAvailable())
smejky 0:6abf63b83992 22 {
smejky 0:6abf63b83992 23 if(touch.Read())
smejky 0:6abf63b83992 24 {
smejky 0:6abf63b83992 25 unsigned short int touch_y = touch.GetX();
smejky 0:6abf63b83992 26 unsigned short int touch_x = touch.GetY();
smejky 0:6abf63b83992 27 touch_x = touch_x - 10;
smejky 0:6abf63b83992 28 touch_y = touch_y + 10;
smejky 0:6abf63b83992 29 printf("%d \r\n",touch_y);
smejky 0:6abf63b83992 30 if ((touch_x >= x0 && touch_x <= x1)&&(touch_y >= y0 && touch_y <= y1)){
smejky 0:6abf63b83992 31 spi.fillrect(x0,y0,x1,y1,Black);
smejky 0:6abf63b83992 32 wait(500);
smejky 0:6abf63b83992 33
smejky 0:6abf63b83992 34 }
smejky 0:6abf63b83992 35 }
smejky 0:6abf63b83992 36
smejky 0:6abf63b83992 37 }
smejky 0:6abf63b83992 38
smejky 0:6abf63b83992 39 }
smejky 0:6abf63b83992 40
smejky 0:6abf63b83992 41 }
smejky 0:6abf63b83992 42
smejky 0:6abf63b83992 43
smejky 0:6abf63b83992 44
smejky 0:6abf63b83992 45
smejky 0:6abf63b83992 46
smejky 0:6abf63b83992 47 main(){
smejky 0:6abf63b83992 48 spi.background(White);
smejky 0:6abf63b83992 49 spi.cls();
smejky 0:6abf63b83992 50 spi.circle(240, 320, 20, Black);
smejky 0:6abf63b83992 51 touch.InitTouch();
smejky 0:6abf63b83992 52 touch.SetPrecision(PREC_EXTREME);
smejky 0:6abf63b83992 53 while(1){
smejky 0:6abf63b83992 54 if (touch.DataAvailable())
smejky 0:6abf63b83992 55 {
smejky 0:6abf63b83992 56 if(touch.Read())
smejky 0:6abf63b83992 57 {
smejky 0:6abf63b83992 58 unsigned short int touch_y = touch.GetX();
smejky 0:6abf63b83992 59 unsigned short int touch_x = touch.GetY();
smejky 0:6abf63b83992 60 touch_x = touch_x - 10;
smejky 0:6abf63b83992 61 touch_y = touch_y + 10;
smejky 0:6abf63b83992 62 printf("%d \r\n",touch_y);
smejky 0:6abf63b83992 63 spi.pixel(touch_x,touch_y,Blue);
smejky 0:6abf63b83992 64 }
smejky 0:6abf63b83992 65
smejky 0:6abf63b83992 66 }
smejky 0:6abf63b83992 67
smejky 0:6abf63b83992 68 }
smejky 0:6abf63b83992 69
smejky 0:6abf63b83992 70 }