-
Notifications
You must be signed in to change notification settings - Fork 1
/
ArduinoILI9341Touch.ino
58 lines (47 loc) · 1.39 KB
/
ArduinoILI9341Touch.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "URTouch.h"
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST 8
#define TFT_MISO 12
#define TFT_MOSI 11
#define TFT_CLK 13
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
#define t_SCK 3
#define t_CS 4
#define t_MOSI 5
#define t_MISO 6
#define t_IRQ 7
URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
void setup(){
tft.begin();
tft.setRotation(3);
ts.InitTouch();
ts.setPrecision(PREC_EXTREME);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.setCursor(85,5);
tft.print("Touch Demo");
tft.setTextColor(ILI9341_GREEN);
tft.setCursor(20,220);
tft.print("http://www.educ8s.tv");
}
void loop()
{
int x, y;
while(ts.dataAvailable())
{
ts.read();
x = ts.getX();
y = ts.getY();
if((x!=-1) && (y!=-1))
{
x += 13;
y += 4;
int radius = 4;
tft.fillCircle(x, y, radius, ILI9341_YELLOW);
}
}
}