-
Notifications
You must be signed in to change notification settings - Fork 4
/
thermocam.ino
65 lines (51 loc) · 1.46 KB
/
thermocam.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
#include "infobar.h"
#include "mlxcamera.h"
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI();
MLXCamera camera(tft);
InfoBar infoBar = InfoBar(tft);
const uint32_t InfoBarHeight = 10;
const uint32_t MaxFrameTimeInMillis = 33;
InterpolationType interpolationType = InterpolationType::eLinear;
bool fixedTemperatureRange = true;
void setup() {
tft.init();
tft.setRotation(3);
tft.fillScreen(TFT_BLACK);
Serial.begin(115200);
while(!Serial);
if (!camera.init())
{
tft.setCursor(75, tft.height() / 2);
tft.print("No camera detected!");
vTaskDelete(NULL); // remove loop task
}
camera.drawLegendGraph();
}
void loop() {
const long start = millis();
camera.readImage();
const long processingTime = millis() - start;
uint16_t dummyX = 0, dummyY = 0;
if (tft.getTouch(&dummyX, &dummyY))
{
if (dummyX > 80)
interpolationType++;
else
{
fixedTemperatureRange = !fixedTemperatureRange;
if (fixedTemperatureRange)
camera.setFixedTemperatureRange();
else
camera.setDynamicTemperatureRange();
}
}
tft.setCursor(0, InfoBarHeight);
camera.drawImage(interpolationType);
camera.drawLegendText();
camera.drawCenterMeasurement();
const long frameTime = millis() - start;
infoBar.update(start, processingTime, frameTime);
if (frameTime < MaxFrameTimeInMillis)
delay(MaxFrameTimeInMillis - frameTime);
}