display
Dependencies: mbed SPI_TFT_ILI9341 UTouch
display.cpp@0:7573aef67295, 2021-12-01 (annotated)
- Committer:
- smejky
- Date:
- Wed Dec 01 15:34:28 2021 +0000
- Revision:
- 0:7573aef67295
display;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
smejky | 0:7573aef67295 | 1 | #include "mbed.h" |
smejky | 0:7573aef67295 | 2 | #include "SPI_TFT_ILI9341.h" |
smejky | 0:7573aef67295 | 3 | #include "UTouch.h" |
smejky | 0:7573aef67295 | 4 | |
smejky | 0:7573aef67295 | 5 | SPI_TFT_ILI9341 spi(D11,D12,D13,D8, D7, D6, "TFT");// mosi, miso, sclk, chip_select, reset, dc |
smejky | 0:7573aef67295 | 6 | UTouch touch(D4,D9,D3,D2,D5);//clk,chip_select,MOSI,miso,irq(pripojeno je ale nevim co to dela) |
smejky | 0:7573aef67295 | 7 | /* |
smejky | 0:7573aef67295 | 8 | v SPI_TFT_ILI9341.cpp zmeneny framerate ze 70 na 100, toto pomohlo problemu blikání displeje |
smejky | 0:7573aef67295 | 9 | |
smejky | 0:7573aef67295 | 10 | */ |
smejky | 0:7573aef67295 | 11 | |
smejky | 0:7573aef67295 | 12 | void Button(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,int color){ |
smejky | 0:7573aef67295 | 13 | spi.fillrect(x0,y0,x1,y1,color); |
smejky | 0:7573aef67295 | 14 | while(1==1) |
smejky | 0:7573aef67295 | 15 | { |
smejky | 0:7573aef67295 | 16 | if (touch.DataAvailable()) |
smejky | 0:7573aef67295 | 17 | { |
smejky | 0:7573aef67295 | 18 | if(touch.Read()) |
smejky | 0:7573aef67295 | 19 | { |
smejky | 0:7573aef67295 | 20 | unsigned char touch_y = touch.GetX(); |
smejky | 0:7573aef67295 | 21 | unsigned char touch_x = touch.GetY(); |
smejky | 0:7573aef67295 | 22 | touch_x = touch_x - 10; |
smejky | 0:7573aef67295 | 23 | touch_y = touch_y + 10; |
smejky | 0:7573aef67295 | 24 | if ((touch_x >= x0 && touch_x <= x1)&&(touch_y >= y0 && touch_y <= y1)){ |
smejky | 0:7573aef67295 | 25 | spi.fillrect(x0,y0,x1,y1,Black); |
smejky | 0:7573aef67295 | 26 | wait(0.5); |
smejky | 0:7573aef67295 | 27 | spi.fillrect(x0,y0,x1,y1,color); |
smejky | 0:7573aef67295 | 28 | } |
smejky | 0:7573aef67295 | 29 | |
smejky | 0:7573aef67295 | 30 | |
smejky | 0:7573aef67295 | 31 | |
smejky | 0:7573aef67295 | 32 | |
smejky | 0:7573aef67295 | 33 | } |
smejky | 0:7573aef67295 | 34 | } |
smejky | 0:7573aef67295 | 35 | } |
smejky | 0:7573aef67295 | 36 | } |
smejky | 0:7573aef67295 | 37 | |
smejky | 0:7573aef67295 | 38 | |
smejky | 0:7573aef67295 | 39 | |
smejky | 0:7573aef67295 | 40 | main(){ |
smejky | 0:7573aef67295 | 41 | |
smejky | 0:7573aef67295 | 42 | spi.background(White); |
smejky | 0:7573aef67295 | 43 | spi.cls(); |
smejky | 0:7573aef67295 | 44 | spi.circle(1, 1, 20, Black); |
smejky | 0:7573aef67295 | 45 | touch.InitTouch(); |
smejky | 0:7573aef67295 | 46 | touch.SetPrecision(PREC_LOW); |
smejky | 0:7573aef67295 | 47 | //spi.fillrect(0,0,220,100, Blue); |
smejky | 0:7573aef67295 | 48 | Button(0,0,220,100,Green); |
smejky | 0:7573aef67295 | 49 | |
smejky | 0:7573aef67295 | 50 | |
smejky | 0:7573aef67295 | 51 | |
smejky | 0:7573aef67295 | 52 | } |