-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ino
91 lines (70 loc) · 1.96 KB
/
main.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <Adafruit_TFTLCD.h>
#include <Adafruit_GFX.h>
#include <TouchScreen.h>
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define TS_MINX 122
#define TS_MINY 111
#define TS_MAXX 942
#define TS_MAXY 890
#define YP A3
#define XM A2
#define YM 9
#define XP 8
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 364);
boolean buttonEnabled = true;
void setup() {
tft.reset();
uint16_t identifier = tft.readID();
tft.begin(identifier);
tft.setRotation(1);
tft.fillScreen(WHITE);
tft.drawRect(0,0,319,240,YELLOW);
tft.setCursor(30,40);
tft.setTextColor(BLACK);
tft.setTextSize(2);
tft.print("TFT LCD Touch Screen");
tft.setCursor(115,80);
tft.setTextColor(BLACK);
tft.setTextSize(2);
tft.print("Project\n\n by");
tft.setCursor(30,150);
tft.setTextColor(BLUE);
tft.setTextSize(2);
tft.print("Abhineet Raj");
tft.fillRect(50,180, 210, 40, BLACK);
tft.drawRect(50,180,210,40,BLACK);
tft.setCursor(60,190);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.print("Follow github");
}
void loop() {
TSPoint p = ts.getPoint();
if (p.z > ts.pressureThreshhold) {
p.x = map(p.x, TS_MAXX, TS_MINX, 0, 320);
p.y = map(p.y, TS_MAXY, TS_MINY, 0, 480);
if(p.x>50 && p.x<260 && p.y>180 && p.y<270 && buttonEnabled){
buttonEnabled = false;
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
tft.fillScreen(WHITE);
tft.setCursor(50,70);
tft.setTextColor(BLACK);
tft.setTextSize(3);
tft.print(" Thank you\n\n -> Star your favourite\n repository in my \n github account");
}
}
}