display
Dependencies: mbed SPI_TFT_ILI9341 UTouch
display.cpp
- Committer:
- smejky
- Date:
- 2021-12-01
- Revision:
- 0:7573aef67295
File content as of revision 0:7573aef67295:
#include "mbed.h" #include "SPI_TFT_ILI9341.h" #include "UTouch.h" SPI_TFT_ILI9341 spi(D11,D12,D13,D8, D7, D6, "TFT");// mosi, miso, sclk, chip_select, reset, dc UTouch touch(D4,D9,D3,D2,D5);//clk,chip_select,MOSI,miso,irq(pripojeno je ale nevim co to dela) /* v SPI_TFT_ILI9341.cpp zmeneny framerate ze 70 na 100, toto pomohlo problemu blikání displeje */ void Button(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,int color){ spi.fillrect(x0,y0,x1,y1,color); while(1==1) { if (touch.DataAvailable()) { if(touch.Read()) { unsigned char touch_y = touch.GetX(); unsigned char touch_x = touch.GetY(); touch_x = touch_x - 10; touch_y = touch_y + 10; if ((touch_x >= x0 && touch_x <= x1)&&(touch_y >= y0 && touch_y <= y1)){ spi.fillrect(x0,y0,x1,y1,Black); wait(0.5); spi.fillrect(x0,y0,x1,y1,color); } } } } } main(){ spi.background(White); spi.cls(); spi.circle(1, 1, 20, Black); touch.InitTouch(); touch.SetPrecision(PREC_LOW); //spi.fillrect(0,0,220,100, Blue); Button(0,0,220,100,Green); }