-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsensor_screens.h
More file actions
366 lines (314 loc) · 9.43 KB
/
Copy pathsensor_screens.h
File metadata and controls
366 lines (314 loc) · 9.43 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
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
/*
This file contains code for displaying each sensor's "page(s)".
Each function defines the layout, text size, etc., depending upon the best way to view the given sensor's readings.
*/
// ---------------------- GPS ---------------------- //
void gps_screen(uint8_t num_satellites){
if (gps_en){
while (SerialGPS.available() > 0) {
gps.encode(SerialGPS.read());
}
if (num_satellites > 4) {
gpsState.dist = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), gpsState.originLat, gpsState.originLon);
if (gpsState.dist > gpsState.distMax && abs(gpsState.prevDist - gpsState.dist) < 50) {
gpsState.distMax = gpsState.dist;
}
gpsState.prevDist = gpsState.dist;
if (gps.altitude.meters() > gpsState.altMax) {
gpsState.altMax = gps.altitude.meters();
}
if (gps.speed.mps() > gpsState.spdMax) {
gpsState.spdMax = gps.speed.mps();
}
if (gps.altitude.meters() < gpsState.altMin) {
gpsState.altMin = gps.altitude.meters();
}
}
if (nextSerialTaskTs < millis()) {
display_R.setTextColor(SSD1306_WHITE); // normal text
display_R.setTextSize(2);
uint8_t start_col=0;
uint8_t start_row=0;
display_R.setCursor(0,16);
// display_R.print("LAT = ");
display_R.print(gps.location.lat(), 6);
display_R.print("\n");
// display_R.setCursor(3,11+15);
// display_R.print("LONG = ");
display_R.print(gps.location.lng(), 6);
display_R.print("\n");
// display_R.setCursor(3,22+15);
// display_R.print("ALT = ");
display_R.print(gps.altitude.meters());
display_R.print("m\n");
display_R.print(gpsState.dist,1);
// Serial.println(wd(int year, int month, int day));
nextSerialTaskTs = millis() + TASK_SERIAL_RATE;
}
}
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("GPS", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("GPS");
}
void gps_magnetometer_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("GPS/MAGNETOMETER", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("GPS/MAGNETOMETER");
display_R.setTextSize(1);
display_R.setCursor(0, 16);
display_R.print(read_gps_magnetometer());
}
// ------------------------------------------------- //
void multimeter_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("MULTIMETER", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("MULTIMETER");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
// display_R.setCursor(1,17);
display_R.print(read_current_sensor());
}
void battery_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("BATTERY", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("BATTERY");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
// display_R.setCursor(1,17);
display_R.print(read_battery_sensor_formatted());
}
void wind_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("WIND SPEED", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("WIND SPEED");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
int wind_rv_val=analogRead(wind_rv_pin);
// display_R.setCursor(1,17);
display_R.print(wind_rv_val);
}
void noise_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("NOISE", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("NOISE");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
int noise_val=analogRead(noise_pin);
// display_R.setCursor(1,17);
display_R.print(noise_val);
}
void vis_ir_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("VIS/IR", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("VIS/IR");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
display_R.print(read_vis_ir());
}
void uv_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("UV", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("UV");
display_R.setTextSize(1);
display_R.setCursor(0, 16);
String uv_str=read_uv();
display_R.print(uv_str);
}
void spectrometer_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("SPECTROMETER", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("SPECTROMETER");
display_R.setTextSize(1);
display_R.setCursor(0, 16);
display_R.print(read_spectrometer());
}
void temp_humid_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("TEMP/HUMID", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("TEMP/HUMID");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
display_R.print(read_temp_humid());
}
void pressure_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("PRESSURE", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("PRESSURE");
display_R.setTextSize(1);
display_R.setCursor(0, 16);
display_R.print(read_pressure());
}
void tvoc_eco2_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("TVOC/CO2", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("TVOC/CO2");
display_R.setTextSize(1);
display_R.setCursor(0, 16);
display_R.print(read_tvoc_eco2());
}
void pm25_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("PM25", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("PM25");
display_R.setTextSize(1);
display_R.setCursor(0, 16);
display_R.print(read_pm25());
}
void thermal_cam_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("THERMAL CAM", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("THERMAL CAM");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
display_R.print(read_thermal_cam_stats());
}
void radiation_screen(){
display_R.setTextSize(1);
display_R.print(" ");
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("RADIATION", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("RADIATION");
uint16_t CPM=0;
float running_average=0.0;
String cpm_str="";
String avg_str="";
CPM=geiger.getCPM();
if (CPM>0){
geiger.pause();
if (i==array_size)
i=0;
running_average=0.0;
//Pause the count, turn off the external interrupt trigger, the CPM and radiation intensity values remain in the state before the pause
//geiger.pause();
//Get the current CPM, if it has been paused, the CPM is the last value before the pause
//Predict CPM by falling edge pulse within 3 seconds, the error is ±3CPM
vals[i]=CPM;
// Serial.print(i);
// Serial.print(": ");
for (int k=0;k<array_size;k++){
// if (k==i)
// Serial.print("*");
running_average+=vals[k];
// Serial.print(vals[k]);
// Serial.print (" ");
}
running_average/=array_size;
cpm_str=String(CPM);
avg_str=String(running_average);
i++;
geiger.start();
delay(3000);
}
else
{
cpm_str="XX";
avg_str=String("XX");
}
display_R.setTextSize(2);
display_R.setCursor(0, 16);
String geiger_output=String("CPM: "+String(CPM)+"\n"+"AVG: "+String(running_average));
display_R.print(geiger_output);
// display_R.setCursor(50,50);
// display_R.setTextSize(1);
// display_R.print("waiting");
}
// -------------------- IMU ------------------------ //
void imu_orientation_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("IMU/ORIENTATION", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("IMU/ORIENTATION");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
display_R.print(read_orientation());
}
void imu_lin_acc_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("IMU/LINEAR ACC", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("IMU/LINEAR ACC");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
display_R.print(read_lin_acc());
}
void imu_magnetometer_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("IMU/MAGNETOMETER", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("IMU/MAGNETOMETER");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
display_R.print(read_magnetometer());
}
void imu_accelerometer_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("IMU/ACCELEROMETER", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("IMU/ACCELEROMETER");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
display_R.print(read_accelerometer());
}
void imu_gravity_screen(){
display_R.setTextSize(1);
int16_t x1, y1;
uint16_t w, h;
display_R.getTextBounds("IMU/GRAVITY", 0, 0, &x1, &y1, &w, &h);
display_R.setCursor(display_L.width()/2-w/2, 4);
display_R.print("IMU/GRAVITY");
display_R.setTextSize(2);
display_R.setCursor(0, 16);
display_R.print(read_gravity());
}