-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
67 lines (51 loc) · 1.96 KB
/
mainwindow.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
64
65
66
67
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QSerialPortInfo"
#include "Communication/SerialInterface.h"
#include "View/BaseSensorView.h"
#include "Sensors/DSDTechSHT20/TempHumSHT20Sensor.h"
SerialInterface* comPort;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//BaseSensor* baseSensor = new BaseSensor(this);
//auto sensorData = baseSensor->getSensorsDataList()[0];
//ui->lcdNumberTemp->display(sensorData.getValue());
comPort = new SerialInterface(COM_PORT_NAME, 115200);
//comPort->connect();
/*QByteArray bytes = QByteArray();
bytes.append(5, 'A');
comPort->send(bytes);*/
TempHumSHT20Sensor* sensor = new TempHumSHT20Sensor(comPort, "Temperature and humididty sensor");
BaseSensorView* sensorView = new BaseSensorView(sensor);
ui->vboxSensors->setSpacing(0);
ui->vboxSensors->setMargin(0);
ui->vboxSensors->addLayout(sensorView);
// TEST
/*QLabel* pLabelDesc = new QLabel();
this->ui->verticalLayout->setSpacing(0);
this->ui->verticalLayout->setContentsMargins(0, 0, 0, 0);
this->ui->verticalLayout->setAlignment(Qt::AlignTop);
pLabelDesc->setText(QString("Test1"));
pLabelDesc->setContentsMargins(-1, -1, -1, 0);
pLabelDesc->setFrameShape(QFrame::NoFrame);
pLabelDesc->setLineWidth(0);
pLabelDesc->setFixedHeight(20);
pLabelDesc->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
this->ui->verticalLayout->addWidget(pLabelDesc);
pLabelDesc = new QLabel();
pLabelDesc->setText(QString("Test2"));
pLabelDesc->setContentsMargins(-1, -1, -1, 0);
pLabelDesc->setFrameShape(QFrame::NoFrame);
pLabelDesc->setLineWidth(0);
pLabelDesc->setFixedHeight(20);
pLabelDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
this->ui->verticalLayout->addWidget(pLabelDesc);*/
}
MainWindow::~MainWindow()
{
comPort->disconnect();
delete ui;
}