-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSenior_Design.ino
312 lines (286 loc) · 14.8 KB
/
Senior_Design.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#include "SPI.h"
#include "TFT_22_ILI9225.h"
#include "math.h"
#include <Wire.h>
#include <VL53L0X.h>
#include <PololuLedStrip.h>
VL53L0X sensor;
PololuLedStrip<3> ledStrip;
#define LED_COUNT 60
rgb_color colors[LED_COUNT];
rgb_color color;
#if defined (ARDUINO_ARCH_STM32F1)
#define TFT_RST PA1
#define TFT_RS PA2
#define TFT_CS PA0 // SS
#define TFT_SDI PA7 // MOSI
#define TFT_CLK PA5 // SCK
#define TFT_LED 0 // 0 if wired to +5V directly
#elif defined(ESP8266)
#define TFT_RST 4 // D2
#define TFT_RS 5 // D1
#define TFT_CLK 14 // D5 SCK
//#define TFT_SDO 12 // D6 MISO
#define TFT_SDI 13 // D7 MOSI
#define TFT_CS 15 // D8 SS
#define TFT_LED 2 // D4 set 0 if wired to +5V directly -> D3=0 is not possible !!
#elif defined(ESP32)
#define TFT_RST 26 // IO 26
#define TFT_RS 25 // IO 25
#define TFT_CLK 14 // HSPI-SCK
//#define TFT_SDO 12 // HSPI-MISO
#define TFT_SDI 13 // HSPI-MOSI
#define TFT_CS 15 // HSPI-SS0
#define TFT_LED 0 // 0 if wired to +5V directly
#else
#define TFT_RST 8
#define TFT_RS 9
#define TFT_CS 10 // SS
#define TFT_SDI 11 // MOSI
#define TFT_CLK 13 // SCK
#define TFT_LED 3 // 0 if wired to +5V directly
#endif
#define TFT_BRIGHTNESS 200 // Initial brightness of TFT backlight (optional)
// Use hardware SPI (faster - on Uno: 13-SCK, 12-MISO, 11-MOSI)
TFT_22_ILI9225 tft = TFT_22_ILI9225(TFT_RST, TFT_RS, TFT_CS, TFT_LED, TFT_BRIGHTNESS);
int button_pin = 7;
int piezo_pin = 6;
// 'pre-ccap logo_small', 220x51px
const unsigned char myBitmap [] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x80, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x04, 0x07, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0e, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xe6, 0x0e, 0x1c, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x87,
0x00, 0x3c, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x00, 0x0c, 0x1f, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff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xff, 0xf0, 0x3e, 0x07,
0x81, 0xfc, 0x0f, 0x03, 0xff, 0xff, 0xe2, 0x1f, 0x80, 0x3f, 0x0e, 0xfe, 0x03, 0xf8, 0x7c, 0x07,
0xf0, 0xff, 0x80, 0x07, 0xf8, 0x1f, 0x01, 0xf0, 0xff, 0xf0, 0x3e, 0x07, 0x81, 0xf8, 0x0f, 0x03,
0xff, 0xff, 0xee, 0x1f, 0x00, 0x1f, 0x8c, 0xfe, 0x07, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0x02, 0x07,
0xf8, 0x1f, 0x01, 0xf0, 0xff, 0xf0, 0x3c, 0x07, 0x81, 0xf0, 0x1f, 0x00, 0x00, 0xff, 0xe6, 0x1f,
0x00, 0x0f, 0x80, 0xfc, 0x07, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0x03, 0x03, 0xf8, 0x1e, 0x03, 0xf0,
0xff, 0xf0, 0x00, 0x0f, 0x80, 0x00, 0x3f, 0x00, 0x00, 0xff, 0xe2, 0x3f, 0x00, 0x0f, 0x80, 0xfc,
0x07, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0x03, 0x03, 0xf8, 0x00, 0x03, 0xf0, 0xff, 0xf0, 0x00, 0x0f,
0x80, 0x00, 0x7f, 0x00, 0x00, 0xff, 0xe0, 0x3f, 0x00, 0x0f, 0x80, 0xfc, 0x07, 0xff, 0xfc, 0x0f,
0xff, 0xfe, 0x07, 0x01, 0xf8, 0x00, 0x03, 0xf0, 0xff, 0xf0, 0x00, 0x1f, 0x80, 0x01, 0xff, 0x00,
0x00, 0xff, 0xe0, 0x3f, 0x00, 0x0f, 0x80, 0xfc, 0x07, 0xff, 0xfc, 0x0f, 0xff, 0xfe, 0x07, 0x81,
0xf8, 0x00, 0x07, 0xf0, 0xff, 0xf0, 0x00, 0x7f, 0x81, 0x80, 0xff, 0x03, 0xff, 0xff, 0xe0, 0x3f,
0x00, 0x0f, 0x84, 0xfc, 0x07, 0xff, 0xfc, 0x0f, 0x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0xc3, 0xff, 0xf8, 0x23, 0xff, 0xc0, 0x00, 0xff, 0x80, 0x01, 0xf0, 0x1f, 0xe0,
0x38, 0x1f, 0xff, 0xf0, 0xff, 0xe0, 0x3f, 0xff, 0x81, 0xfc, 0x07, 0x00, 0x00, 0x3f, 0xfc, 0xe0,
0xff, 0xe0, 0x73, 0xff, 0xf0, 0x01, 0xff, 0xe0, 0x03, 0xf0, 0x3f, 0xe0, 0x38, 0x1f, 0xff, 0xf0,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xe0, 0x3f, 0x80, 0x77, 0xff,
0xf8, 0x07, 0xff, 0xf0, 0x07, 0xf0, 0x3f, 0xf0, 0x38, 0x1f, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xc0, 0x00, 0x00, 0x0f, 0xff, 0xe0, 0x01, 0xff, 0xc0,
0x03, 0xf0, 0x3f, 0xe0, 0x38, 0x1f, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff,
0xcf, 0xff, 0xff, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xc0, 0x00, 0xff, 0x80, 0x01, 0xf8, 0x3f, 0xe0,
0x38, 0x1f, 0xff, 0xf0, 0xff, 0x70, 0xba, 0x6f, 0xa8, 0xea, 0x09, 0x84, 0x90, 0x5d, 0xb7, 0x87,
0x00, 0x1c, 0x1f, 0xff, 0x80, 0x00, 0x52, 0x00, 0x00, 0x70, 0x1b, 0x40, 0x50, 0x0e, 0xbf, 0xf0,
0xfe, 0xc9, 0x2a, 0xe7, 0x19, 0x60, 0x3b, 0x8a, 0x94, 0x3d, 0xcf, 0xc7, 0x80, 0x1c, 0x7f, 0xff,
0xfe, 0x80, 0x26, 0x02, 0x10, 0x30, 0x02, 0x01, 0x68, 0x16, 0xbf, 0xf0, 0xff, 0xff, 0xff, 0xef,
0xff, 0xeb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0x0f, 0x0c, 0xff, 0xff, 0xff, 0xfc, 0x5c, 0x07,
0xf8, 0x3c, 0x03, 0x11, 0xf4, 0x9f, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf8, 0x0e, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xfe, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0x04, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf0
};
// Setup
void setup() {
pinMode(button_pin, INPUT);
pinMode(piezo_pin, OUTPUT);
Serial.begin(9600);
Wire.begin();
sensor.init();
sensor.setTimeout(500);
sensor.startContinuous();
tft.begin();
tft.clear();
}
// Loop
void loop() {
int hz;
int pump = 0;
int prev_pump = 0;
int tx = 13;
int ty = 46;
int tx2 = 13;
int ty2 = 126;
int x;
int temp;
int pres;
int on = false;
tft.setOrientation(3);
tft.setBackgroundColor(COLOR_WHITE);
tft.fillRectangle(0, 0, tft.maxX(), tft.maxY(), COLOR_WHITE); //220 x 176
tft.drawBitmap(0, tft.maxY()/2 - 51/2, myBitmap, 224, 51, COLOR_WHITE, COLOR_ORANGE);
RGB_color(255,0,0);
tone(piezo_pin, 50);
delay(200);
tone(piezo_pin, 250);
tft.drawBitmap(0, tft.maxY()/2 - 51/2, myBitmap, 224, 51, COLOR_WHITE, COLOR_RED);
RGB_color(0,255,0);
delay(150);
tone(piezo_pin, 10);
tft.drawBitmap(0, tft.maxY()/2 - 51/2, myBitmap, 224, 51, COLOR_WHITE, COLOR_BLUE);
RGB_color(0,0,255);
delay(150);
tone(piezo_pin, 80);
tft.drawBitmap(0, tft.maxY()/2 - 51/2, myBitmap, 224, 51, COLOR_WHITE, COLOR_BLACK);
RGB_color(0,0,0);
delay(150);
tone(piezo_pin, 250);
delay(200);
noTone(piezo_pin);
delay(1500);
if (on == false){
on = true;
delay(100);
tft.setFont(Terminal12x16);
tft.fillRectangle(0, 0, tft.maxX(), tft.maxY(), COLOR_WHITE); //220 x 176
//Draw rect1
tft.drawText(tft.maxX()/2 - 60, 10, "Temperature", COLOR_RED);
tft.drawRectangle(tft.maxX()/2 - 100, 30, tft.maxX()/2 + 100, 45, COLOR_BLACK);
//Draw rect1 filling
tft.fillRectangle(tft.maxX()/2 - 99, 31, tft.maxX()/2 - 40, 44, COLOR_BLUE);
tft.fillRectangle(tft.maxX()/2 - 40, 31, tft.maxX()/2 + 10, 44, COLOR_GREEN);
tft.fillRectangle(tft.maxX()/2 + 10, 31, tft.maxX()/2 + 40, 44, COLOR_YELLOW);
tft.fillRectangle(tft.maxX()/2 + 40, 31, tft.maxX()/2 + 70, 44, COLOR_ORANGE);
tft.fillRectangle(tft.maxX()/2 + 70, 31, tft.maxX()/2 + 99, 44, COLOR_RED);
//Draw rect2
tft.drawText(tft.maxX()/2 - 40, 90, "Pressure", COLOR_BLUE);
tft.drawRectangle(tft.maxX()/2 - 100, 110, tft.maxX()/2 + 100, 125, COLOR_BLACK);
//Draw rect2 filling
tft.fillRectangle(tft.maxX()/2 - 99, 111, tft.maxX()/2 - 40, 124, COLOR_BLUE);
tft.fillRectangle(tft.maxX()/2 - 40, 111, tft.maxX()/2 + 10, 124, COLOR_GREEN);
tft.fillRectangle(tft.maxX()/2 + 10, 111, tft.maxX()/2 + 40, 124, COLOR_YELLOW);
tft.fillRectangle(tft.maxX()/2 + 40, 111, tft.maxX()/2 + 70, 124, COLOR_ORANGE);
tft.fillRectangle(tft.maxX()/2 + 70, 111, tft.maxX()/2 + 99, 124, COLOR_RED);
tft.drawText(tft.maxX()/2 - 20 ,ty + 15, String(0) + "C", COLOR_BLACK);
tft.drawText(tft.maxX()/2 - 20 ,ty2 + 15, String(0) + "MPa", COLOR_BLACK);
while(true){
// if (on == false){
// on = false;
// delay(100);
// }
x = sensor.readRangeContinuousMillimeters();
Serial.print(x);
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
Serial.println();
if (x <= 55){
pump++;
while (x <= 73){
x = sensor.readRangeContinuousMillimeters();
Serial.print(x);
Serial.println();
}
}
if (pump < 4){
RGB_color(0,0,255);
}
else if (pump >= 4 && pump < 7){
RGB_color(0,255,0);
}
else if (pump >= 7 && pump < 8){
RGB_color(255,255,0);
}
else if (pump >= 8 && pump < 10){
RGB_color(255,50,0);
}
else if (pump >= 10){
RGB_color(255,0,0);
}
else{
RGB_color(0,0,0);
}
if (pump <= 11){
hz = map(pump, 8, 11, 0, 500);
}
if (pump < 8 || pump > 11){
noTone(piezo_pin);
}
else{
tone(piezo_pin, hz);
}
temp = map(pump,0,11,100,2000);
pres = map(pump,0,11,30,450);
if (pump < 12){
tx = map(pump,0,11,13,209);
tx2 = map(pump,0,11,13,170);
tft.drawText(tft.maxX()/2 - 30 ,ty + 15, String(temp) + " C", COLOR_BLACK);
tft.drawText(tft.maxX()/2 - 30 ,ty2 + 15, String(pres) + " MPa", COLOR_BLACK);
}
if (prev_pump < pump){
tft.fillRectangle(0,ty,tft.maxX(),ty + 10,COLOR_WHITE);
tft.fillRectangle(0,ty2,tft.maxX(),ty2 + 10,COLOR_WHITE);
}
tft.fillTriangle(tx,ty,tx - 7,ty + 7,tx + 10,ty + 7,COLOR_BLACK);
tft.fillTriangle(tx2,ty2,tx2 - 7,ty2 + 7,tx2 + 10,ty2 + 7,COLOR_BLACK);
prev_pump = pump;
}
} //Turn on display
} //End of main
void RGB_color(int red_light_value, int green_light_value, int blue_light_value)
{
color.red = red_light_value;
color.green = green_light_value;
color.blue = blue_light_value;
for(uint16_t i = 0; i < LED_COUNT; i++)
{
colors[i] = color;
}
ledStrip.write(colors, LED_COUNT);
}