2017-10-15 10:30:15 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
|
|
#include "blinkthread.h"
|
|
|
|
#include "distancethread.h"
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
QMainWindow(parent),
|
|
|
|
ui(new Ui::MainWindow)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
ui->progressBar->setRange(0, 300);
|
|
|
|
ui->progressBar->setFormat("%v cm");
|
|
|
|
ui->progressBar->setValue(0);
|
|
|
|
|
2017-10-16 13:23:54 +00:00
|
|
|
BlinkThread *blinkThread = new BlinkThread(15);
|
2017-10-15 10:30:15 +00:00
|
|
|
connect(blinkThread, &BlinkThread::ledOn, this, &MainWindow::ledOn);
|
|
|
|
connect(blinkThread, &BlinkThread::ledOff, this, &MainWindow::ledOff);
|
|
|
|
blinkThread->start();
|
|
|
|
|
|
|
|
DistanceThread *distanceThread = new DistanceThread();
|
|
|
|
connect(distanceThread, &DistanceThread::distanceUpdated, this, &MainWindow::distanceUpdated);
|
|
|
|
distanceThread->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ledOn()
|
|
|
|
{
|
|
|
|
ui->label->setText("On");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ledOff()
|
|
|
|
{
|
|
|
|
ui->label->setText("Off");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::distanceUpdated(double distMeters)
|
|
|
|
{
|
|
|
|
ui->progressBar->setValue(distMeters / 100);
|
|
|
|
}
|