-
Notifications
You must be signed in to change notification settings - Fork 1
/
thrustbar.cpp
executable file
·194 lines (176 loc) · 4.9 KB
/
thrustbar.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/////////////////////////////////////////////////////////////////////////////////
// thrustbar.cpp - Multicopter Simulator - Thrust Indicator
// Roy Cole
// This is the class declaration for the thrust indicator. The purpose of this widget
// is to show in a graphical format exactly how much thrust each engine is producing
/////////////////////////////////////////////////////////////////////////////////
#include <QtGui>
#include <cmath>
#include <time.h>
#include "thrustbar.h"
#include "ui_thrustbar.h"
ThrustBar::ThrustBar(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
connect(timer,SIGNAL(timeout()),this,SLOT(updateBarGraph()));
timer->start(10);
//updateBarGraph();
eng1 =0;
eng2 =0;
eng3 =0;
eng4 =0;
eng5 =0;
eng6 =0;
eng7 =0;
eng8 =0;
setWindowTitle(tr("Thrust Graphs"));
}
ThrustBar::~ThrustBar()
{
delete ui;
}
void ThrustBar::updateBarGraph()
{
//ui->progressBar->setValue(eng1);
//ui->progressBar_2->setValue(eng2);
//ui->progressBar_3->setValue(eng3);
//ui->progressBar_4->setValue(eng4);
ui->progBarENG1->setValue(eng1);
ui->progBarENG2->setValue(eng2);
ui->progBarENG3->setValue(eng3);
ui->progBarENG4->setValue(eng4);
ui->progBarENG5->setValue(eng5);
ui->progBarENG6->setValue(eng6);
ui->progBarENG7->setValue(eng7);
ui->progBarENG8->setValue(eng8);
}
void ThrustBar::updateThrust(int e1, int e2, int e3, int e4, int e5, int e6, int e7, int e8, int m_numMotors)
{
eng1 = e1;
eng2 = e2;
eng3 = e3;
eng4 = e4;
eng5 = e5;
eng6 = e6;
eng7 = e7;
eng8 = e8;
numMotors = m_numMotors;
if(numMotors == 3)
{
ui->progBarENG1->show();
ui->progBarENG2->show();
ui->progBarENG3->show();
ui->progBarENG4->hide();
ui->progBarENG5->hide();
ui->progBarENG6->hide();
ui->progBarENG7->hide();
ui->progBarENG8->hide();
ui->label_1->show();
ui->label_2->show();
ui->label_3->show();
ui->label_4->hide();
ui->label_5->hide();
ui->label_6->hide();
ui->label_7->hide();
ui->label_8->hide();
}
else if(numMotors == 4)
{
ui->progBarENG1->show();
ui->progBarENG2->show();
ui->progBarENG3->show();
ui->progBarENG4->show();
ui->progBarENG5->hide();
ui->progBarENG6->hide();
ui->progBarENG7->hide();
ui->progBarENG8->hide();
ui->label_1->show();
ui->label_2->show();
ui->label_3->show();
ui->label_4->show();
ui->label_5->hide();
ui->label_6->hide();
ui->label_7->hide();
ui->label_8->hide();
}
else if(numMotors == 5)
{
ui->progBarENG1->show();
ui->progBarENG2->show();
ui->progBarENG3->show();
ui->progBarENG4->show();
ui->progBarENG5->show();
ui->progBarENG6->hide();
ui->progBarENG7->hide();
ui->progBarENG8->hide();
ui->label_1->show();
ui->label_2->show();
ui->label_3->show();
ui->label_4->show();
ui->label_5->show();
ui->label_6->hide();
ui->label_7->hide();
ui->label_8->hide();
}
else if(numMotors == 6)
{
ui->progBarENG1->show();
ui->progBarENG2->show();
ui->progBarENG3->show();
ui->progBarENG4->show();
ui->progBarENG5->show();
ui->progBarENG6->show();
ui->progBarENG7->hide();
ui->progBarENG8->hide();
ui->label_1->show();
ui->label_2->show();
ui->label_3->show();
ui->label_4->show();
ui->label_5->show();
ui->label_6->show();
ui->label_7->hide();
ui->label_8->hide();
}
else if(numMotors == 7)
{
ui->progBarENG1->show();
ui->progBarENG2->show();
ui->progBarENG3->show();
ui->progBarENG4->show();
ui->progBarENG5->show();
ui->progBarENG6->show();
ui->progBarENG7->show();
ui->progBarENG8->hide();
ui->label_1->show();
ui->label_2->show();
ui->label_3->show();
ui->label_4->show();
ui->label_5->show();
ui->label_6->show();
ui->label_7->show();
ui->label_8->hide();
}
else if(numMotors == 8)
{
ui->progBarENG1->show();
ui->progBarENG2->show();
ui->progBarENG3->show();
ui->progBarENG4->show();
ui->progBarENG5->show();
ui->progBarENG6->show();
ui->progBarENG7->show();
ui->progBarENG8->show();
ui->label_1->show();
ui->label_2->show();
ui->label_3->show();
ui->label_4->show();
ui->label_5->show();
ui->label_6->show();
ui->label_7->show();
ui->label_8->show();
}
}