#include <TFT9341.h>
#include <touch.h>
#include <SPI.h>
#define IRQ 2 //IRQ Touch
int x,y;
void setup()
{
lcd,begin();
lcdtouch.begin();
lcdtouch.InitTypeTouch(2);//0,1,2
lcd.setRotation(2);//0,1,2,3
lcd.clscr(GRAY);
lcd.setColor(YELLOW);
lcd.setFont(4);
lcd.gotoxy(40,50);
lcd.print("Touch test");
lcd.setFont(3);
}
void loop()
{
while(digitalRead(IRG)==1);
lcdtouch.readxy();
x=lcdtouch.readx();
y=lcdtouch.ready();
lcd.drawRoundRect (20,160,280,50,10,RED);
lcd.fillRoundRect(21,161,278,48,10,BLUE);
lcd.setcolor(GREEN,BLUE);
lcd.gotoxy(30,170);
lcd.print("x =");
lcd.print(x);
lcd.gotoxy(170,170);
lcd.print("y = ");
lcd.print(y);
}
Loading
ili9341-cap-touch
ili9341-cap-touch