|
|
@ -11,6 +11,7 @@ |
|
|
|
#include <QTime>
|
|
|
|
#include <QLocale>
|
|
|
|
|
|
|
|
#include "mqttclient.h"
|
|
|
|
#include "zoneitem.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
@ -20,16 +21,27 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
|
{ |
|
|
|
Settings *s = Settings::getInstance(); |
|
|
|
|
|
|
|
mqttclient = new MQTTSubcriber(QHostAddress("192.168.1.2"), 1883); |
|
|
|
|
|
|
|
for (int i = 0; i < NB_ZONES; i++) { |
|
|
|
m_zones[i] = new ZoneItem(s->m_rooms_names[i], this); |
|
|
|
} |
|
|
|
|
|
|
|
connect(mqttclient, SIGNAL(new_temperature(unsigned, double)), |
|
|
|
this, SLOT(temperature_slot(unsigned, double))); |
|
|
|
connect(mqttclient, SIGNAL(new_hygro(unsigned, double)), |
|
|
|
this, SLOT(hygro_slot(unsigned, double))); |
|
|
|
|
|
|
|
/*
|
|
|
|
* Sensors-related layout |
|
|
|
*/ |
|
|
|
QGridLayout *mainLayout = new QGridLayout; |
|
|
|
|
|
|
|
mainLayout->addWidget(new ZoneItem(s->m_rooms_names[0], this), 0, 0); |
|
|
|
mainLayout->addWidget(new ZoneItem(s->m_rooms_names[1], this), 0, 1); |
|
|
|
mainLayout->addWidget(m_zones[0], 0, 0); |
|
|
|
mainLayout->addWidget(m_zones[1], 0, 1); |
|
|
|
mainLayout->addWidget(new QPushButton(tr("Menu")), 0, 2); |
|
|
|
mainLayout->addWidget(new ZoneItem(s->m_rooms_names[2], this), 1, 0); |
|
|
|
mainLayout->addWidget(new ZoneItem(s->m_rooms_names[3], this), 1, 1); |
|
|
|
mainLayout->addWidget(m_zones[2], 1, 0); |
|
|
|
mainLayout->addWidget(m_zones[3], 1, 1); |
|
|
|
mainLayout->addWidget(new QPushButton(tr("Auto")), 1, 2); |
|
|
|
|
|
|
|
QWidget *mainWidget = new QWidget; |
|
|
@ -42,10 +54,28 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
|
|
|
|
|
setWindowTitle(tr("Sorico's thermostat")); |
|
|
|
m_backLoop.start(); |
|
|
|
|
|
|
|
mqttclient->connectToHost(); |
|
|
|
} |
|
|
|
|
|
|
|
MainWindow::~MainWindow() |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::temperature_slot(unsigned idx, double val) |
|
|
|
{ |
|
|
|
qDebug() << "temperature idx:" << idx << " val: " << val << endl; |
|
|
|
if (idx < NB_ZONES) { |
|
|
|
m_zones[idx]->set_temperature_value(val); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::hygro_slot(unsigned idx, double val) |
|
|
|
{ |
|
|
|
qDebug() << "hygro idx:" << idx << " val: " << val << endl; |
|
|
|
if (idx < NB_ZONES) { |
|
|
|
m_zones[idx]->set_hygro_value(val); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ |