-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.cpp
75 lines (60 loc) · 1.9 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
68
69
70
71
72
73
74
/****************************************************************
* mainwindow.cpp
* by zapmaker
*
* 15 Nov 2012
* GPL License (see LICENSE file)
* Software is provided AS-IS
****************************************************************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->lcdPwm->setDigitCount(4);
ui->lcdSpeed->setDigitCount(4);
ui->lcdTimeCount->setDigitCount(8);
ui->lcdTimeDiffWheelTurn->setDigitCount(4);
ui->lcdWheelRotationCount->setDigitCount(4);
ui->lcdGyroX->setDigitCount(4);
ui->lcdGyroY->setDigitCount(4);
ui->lcdGyroZ->setDigitCount(4);
connect(&port, SIGNAL(setTime(QString)), this, SLOT(setTime(QString)));
connect(&port, SIGNAL(setGyro(QString, QString, QString)), this, SLOT(setGyro(QString, QString, QString)));
connect(&port, SIGNAL(setMotor(QString)), this, SLOT(setMotor(QString)));
connect(&port, SIGNAL(setSpeed(QString, QString, QString)), this, SLOT(setSpeed(QString, QString, QString)));
}
MainWindow::~MainWindow()
{
port.CloseComport();
delete ui;
}
void MainWindow::on_btnOne_clicked()
{
if (port.isPortOpen())
return;
port.OpenComport("COM8", "115200");
info("Port state:%d\n", port.isPortOpen());
}
void MainWindow::setTime(QString currTime)
{
ui->lcdTimeCount->display(currTime);
}
void MainWindow::setGyro(QString x, QString y, QString z)
{
ui->lcdGyroX->display(x);
ui->lcdGyroY->display(y);
ui->lcdGyroZ->display(z);
}
void MainWindow::setMotor(QString pwmOut)
{
ui->lcdPwm->display(pwmOut);
}
void MainWindow::setSpeed(QString rotationCount, QString speedOfTrain, QString timeDeltaWheelTurn)
{
ui->lcdWheelRotationCount->display(rotationCount);
ui->lcdSpeed->display(speedOfTrain);
ui->lcdTimeDiffWheelTurn->display(timeDeltaWheelTurn);
}