forked from TradeCrafter/lepton3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
64 lines (47 loc) · 1.75 KB
/
main.cpp
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
#include <QApplication>
#include <QThread>
#include <QMutex>
#include <QMessageBox>
#include <QColor>
#include <QLabel>
#include <QtDebug>
#include <QString>
#include <QPushButton>
#include "LeptonThread.h"
#include "MyLabel.h"
int main( int argc, char **argv )
{
int WindowWidth = 340*2;
int WindowHeight = 290*2;
int ImageWidth = 320*2;
int ImageHeight = 240*2;
//create the app
QApplication a( argc, argv );
QWidget *myWidget = new QWidget;
myWidget->setGeometry(400, 300, WindowWidth, WindowHeight);
//create an image placeholder for myLabel
//fill the top left corner with red, just bcuz
QImage myImage;
myImage = QImage(ImageWidth, ImageHeight, QImage::Format_RGB888);
//create a label, and set it's image to the placeholder
MyLabel myLabel(myWidget);
myLabel.setGeometry(10, 10, ImageWidth, ImageHeight);
myLabel.setPixmap(QPixmap::fromImage(myImage));
//create a FFC button
QPushButton *button1 = new QPushButton("Calibrar", myWidget);
button1->setGeometry(ImageWidth/2-100, WindowHeight-60, 100, 30);
//create a Snapshot button
QPushButton *button2 = new QPushButton("Tirar foto", myWidget);
button2->setGeometry(ImageWidth/2+50, WindowHeight-60, 100, 30);
//create a thread to gather SPI data
//when the thread emits updateImage, the label should update its image accordingly
LeptonThread *thread = new LeptonThread();
QObject::connect(thread, SIGNAL(updateImage(QImage)), &myLabel, SLOT(setImage(QImage)));
//connect ffc button to the thread's ffc action
QObject::connect(button1, SIGNAL(clicked()), thread, SLOT(performFFC()));
//connect snapshot button to the thread's snapshot action
QObject::connect(button2, SIGNAL(clicked()), thread, SLOT(snapshot()));
thread->start();
myWidget->showFullScreen();
return a.exec();
}