forked from UCR-Solar-Car/DriverInterface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tirepressure.cpp
102 lines (94 loc) · 3.18 KB
/
tirepressure.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
#include "tirepressure.h"
#include "scaler.h"
TirePressure::TirePressure(){}
void TirePressure::setup(Ui::MainWindow *ui, int height, int width) {
this->ui = ui;
front_left_pressure = 35;
front_right_pressure = 35;
back_left_pressure = 35;
back_right_pressure = 35;
pressure_threshold = 30;
low_pressure_icon = QPixmap(":/icons/lowpressure.png");
normal_pressure_icon = QPixmap(":/icons/normalpressure.png");
if(front_left_pressure >= pressure_threshold){
ui->front_left->setPixmap(normal_pressure_icon);
}
else{
this->ui->front_left->setPixmap(low_pressure_icon);
}
if(front_right_pressure >= pressure_threshold){
ui->front_right->setPixmap(normal_pressure_icon);
}
else{
this->ui->front_right->setPixmap(low_pressure_icon);
}
if(back_left_pressure >= pressure_threshold){
ui->back_left->setPixmap(normal_pressure_icon);
}
else{
this->ui->back_left->setPixmap(low_pressure_icon);
}
if(back_right_pressure >= pressure_threshold){
ui->back_right->setPixmap(normal_pressure_icon);
}
else{
this->ui->back_right->setPixmap(low_pressure_icon);
}
ui->back_left->resize(100, 100);
ui->back_right->resize(100, 100);
ui->front_left->resize(100, 100);
ui->front_right->resize(100, 100);
ui->front_left->move(width * 65 / 100, height * 35 / 100);
ui->back_left->move(ui->front_left->x(),
ui->front_left->y() + height * 20 / 100);
ui->back_right->move(ui->back_left->x() + width * 20 / 100,
ui->back_left->y());
ui->front_right->move(ui->front_left->x() + width * 20 / 100,
ui->front_left->y());
}
void TirePressure::increasePressure(tires tire) {
if (tire == FRONT_LEFT) {
front_left_pressure++;
if(front_left_pressure > pressure_threshold){
this->ui->front_left->setPixmap(normal_pressure_icon);
}
} else if (tire == FRONT_RIGHT) {
front_right_pressure++;
if(front_right_pressure > pressure_threshold){
this->ui->front_right->setPixmap(normal_pressure_icon);
}
} else if (tire == BACK_LEFT) {
back_left_pressure++;
if(back_left_pressure > pressure_threshold){
this->ui->back_left->setPixmap(normal_pressure_icon);
}
} else if (tire == BACK_RIGHT) {
back_right_pressure++;
if(back_right_pressure > pressure_threshold){
this->ui->back_right->setPixmap(normal_pressure_icon);
}
}
}
void TirePressure::decreasePressure(tires tire) {
if (tire == FRONT_LEFT) {
front_left_pressure--;
if(front_left_pressure <= pressure_threshold){
this->ui->front_left->setPixmap(low_pressure_icon);
}
} else if (tire == FRONT_RIGHT) {
front_right_pressure--;
if(front_right_pressure <= pressure_threshold){
this->ui->front_right->setPixmap(low_pressure_icon);
}
} else if (tire == BACK_LEFT) {
back_left_pressure--;
if(back_left_pressure <= pressure_threshold){
this->ui->back_left->setPixmap(low_pressure_icon);
}
} else if (tire == BACK_RIGHT) {
back_right_pressure--;
if(back_right_pressure <= pressure_threshold){
this->ui->back_right->setPixmap(low_pressure_icon);
}
}
}