-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpg 2
More file actions
126 lines (82 loc) · 2.06 KB
/
pg 2
File metadata and controls
126 lines (82 loc) · 2.06 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
//copyright 2020 Alexander I Rusich
#pragma once
#include <SparkFun_GridEYE_Arduino_Library.h>
#include "oled.h"
class CGridEye{
private:
#define HOT 40
#define COLD 20
#define TLIMIT -400.0
// This table can be of type int because we map the pixel
// temperature to 0-3. Temperatures are reported by the
// library as doubles
long last=0;
int pixelTable[64];
double temperature=0;
double vavg=0.0;
String pixelStr;
GridEYE grideye;
COLED Display;
public:
CGridEye(){}
void setup() {
// Start your preferred I2C object
// Library assumes "Wire" for I2C but you can pass something else with begin() if you like
grideye.begin(0X69);
Display.setup();
}
void loop() {
bool flag=false;
Display.Clear();
if (millis()>last+20000){
last=millis();
// loop through all 64 pixels on the device and map each double value to a number
// between 0 and 3 using the HOT and COLD values we set at the top of the sketch
temperature=grideye.getDeviceTemperature();
Serial.print("Sensor Temperature: ");
Serial.println(temperature);
double vx=0.0;
double vy=0.0;
double vtot=0.0;
double vmin,vmax;
for(unsigned char i = 0; i < 64; i++){
double val=grideye.getPixelTemperature(i);
if (val<TLIMIT) val=grideye.getPixelTemperatureHot(i);
if(flag){
Display.FlashPrint(val);
}
if (i==0){
vmin=val;
vmax=val;
}
if(val<vmin) vmin=val;
if(val>vmax) vmax=val;
vtot+=val;
}
vavg=vtot/64.0;
Display.Print(vmin,0,0);
Display.Print(vmax,35,0);
Display.Print(vtot/64.0,0,40);
Display.Show();
}
for(unsigned char i = 0; i < 64; i++){
double y=1+i/8;
double x=1+i%8;
double val=grideye.getPixelTemperature(i);
if (val<TLIMIT) val=grideye.getPixelTemperatureHot(i);
/*
if (vavg>0){
if(val>vavg+3.0) Display.Pt((int) x-1,(int) y-1);
}
else{
if(val>temperature) Display.Pt((int) x-1,(int) y-1);
}
*/
if(val>vavg+5.0) Display.Pt((int) x-1,(int) y-1);
Serial.print(val);
Serial.print(" ");
if(i%8==7) Serial.println();
}
delay(10);
}
};