-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreviousCode.txt
More file actions
140 lines (109 loc) · 3.04 KB
/
PreviousCode.txt
File metadata and controls
140 lines (109 loc) · 3.04 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include <Adafruit_TFTLCD.h>
#include <Adafruit_GFX.h>
#include <TouchScreen.h>
#include <MCUFRIEND_kbv.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 500
#define TS_MAXY 680
#define YP A1
#define XM A2
#define YM 7
#define XP 6
/*
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A3 // must be an analog pin, use "An" notation!
#define YM 8 // can be a digital pin
#define XP 9 // can be a digital pin
*/
#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, 334);
boolean buttonEnabled = true;
void setup() {
Serial.begin(115200);
tft.reset();
uint16_t identifier = tft.readID();
tft.begin(identifier);
tft.setRotation(1);
tft.fillScreen(BLACK);
tft.drawRect(0, 0, 319, 240, YELLOW);
for (int i = 100; i > 5; i -= 5) {
tft.drawCircle(160, 120, i, GREEN);
delay(30);
}
for(int i= 10; i<50; i+=5){
tft.drawTriangle(200,360+i, 150+i, 460-i, 250-i, 460-i, BLUE);
}
delay(2000);
tft.fillScreen(WHITE);
tft.setCursor(30, 40);
tft.setTextColor(BLACK);
tft.setTextSize(2);
tft.print("Dashboard For EV");
tft.setCursor(115, 80);
tft.setTextColor(BLACK);
tft.setTextSize(2);
tft.print("Project\n\n by");
tft.setCursor(55, 155);
tft.setTextColor(BLUE);
tft.setTextSize(2);
tft.print("Chip Soul Tech");
tft.fillRect(50, 180, 210, 40, BLUE);
tft.drawRect(50, 180, 210, 40, RED);
tft.setCursor(60, 190);
tft.setTextColor(RED);
tft.setTextSize(2);
tft.print("Click For Menu");
}
void loop() {
TSPoint p = ts.getPoint(); //TO Make clickable button on these pixels area
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 > -180 && p.x < 250 && p.y > 300 && p.y < 430 && buttonEnabled) { //button clikable range
Serial.println("Touch button press");
Serial.println(p.x);
Serial.println(p.y);
delay(30);
buttonEnabled = false;
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
tft.fillScreen(WHITE);
tft.drawRect(0, 0, 319, 240, YELLOW);
// tft.setCursor(50, 70);
// tft.setTextColor(BLACK);
// tft.setTextSize(3);
tft.fillRect(30, 50, 240, 40, YELLOW);
tft.drawRect(30, 50, 240, 40, RED);
tft.setCursor(55, 60);
tft.setTextColor(BLUE);
tft.setTextSize(2);
tft.print("Battery Voltage:");
tft.fillRect(30, 100, 240, 40, YELLOW);
tft.drawRect(30, 100, 240, 40, RED);
tft.setCursor(85, 110);
tft.setTextColor(BLUE);
tft.setTextSize(2.9);
tft.print("Current:");
tft.fillRect(30, 150, 280, 40, YELLOW);
tft.drawRect(30, 150, 280, 40, RED);
tft.setCursor(55, 160);
tft.setTextColor(BLUE);
tft.setTextSize(2);
tft.print("Remaining Capacity:");
}
}
}