32 : QObject(parent),
m_ui(ui) {
34 if (!
m_ui->speedLabel || !
m_ui->rpmLabel || !
m_ui->directionLabel ||
35 !
m_ui->timeLabel || !
m_ui->wifiLabel || !
m_ui->temperatureLabel ||
36 !
m_ui->batteryLabel) {
37 qDebug() <<
"Error: Labels not initialized in the UI form!";
42 m_ui->speedLabel->setText(
"0");
43 m_ui->rpmLabel->setText(
"0.00");
44 m_ui->directionLabel->setText(
"D");
45 m_ui->timeLabel->setText(
"--:--:--");
46 m_ui->wifiLabel->setText(
"đļ Disconnected");
47 m_ui->temperatureLabel->setText(
"đĄī¸ N/A");
48 m_ui->batteryLabel->setText(
"--% đ");
49 m_ui->speedMetricsLabel->setText(
"KM/H");
50 m_ui->leftBlinkerLabel->setVisible(
false);
51 m_ui->rightBlinkerLabel->setVisible(
false);
52 m_ui->lowBatteryLabel->setVisible(
false);
55 connect(
m_ui->toggleDrivingModeButton, &QPushButton::clicked,
this,
57 connect(
m_ui->toggleMetricsButton, &QPushButton::clicked,
this,
69 m_ui->speedLabel->setText(QString::number(
static_cast<int>(speed)));
70 m_ui->rpmLabel->setText(
71 QString::number(
static_cast<double>(rpm) / 1000,
'f', 2));
83 QString directionText;
97 m_ui->directionLabel->setText(directionText);
98 if (steeringAngle > 0) {
99 m_ui->leftBlinkerLabel->setVisible(
false);
100 m_ui->rightBlinkerLabel->setVisible(
true);
101 }
else if (steeringAngle < 0) {
102 m_ui->rightBlinkerLabel->setVisible(
false);
103 m_ui->leftBlinkerLabel->setVisible(
true);
105 m_ui->leftBlinkerLabel->setVisible(
false);
106 m_ui->rightBlinkerLabel->setVisible(
false);
119 const QString ¤tTime,
120 const QString ¤tDay) {
121 m_ui->dateLabel->setText(currentDate);
122 m_ui->timeLabel->setText(currentTime);
123 m_ui->weekDayLabel->setText(currentDay);
134 const QString &wifiName) {
135 QString wifiDisplay = status;
136 if (!wifiName.isEmpty()) {
137 wifiDisplay +=
" (" + wifiName +
")";
139 m_ui->wifiLabel->setText(
"đļ " + wifiName);
149 m_ui->temperatureLabel->setText(
"đĄī¸ " + temperature);
159 if (batteryPercentage < 20.0) {
160 m_ui->lowBatteryLabel->setVisible(
true);
162 m_ui->batteryLabel->setText(QString::number(batteryPercentage,
'f', 1) +
163 "% " + (batteryPercentage > 20.0 ?
"đ" :
"đĒĢ"));
173 m_ui->mileageLabel->setText(QString::number(
static_cast<int>(mileage)) +
184 m_ui->ipAddressLabel->setText(
"IP " + ipAddress);
200 modeText =
"automatic";
203 m_ui->drivingModeLabel->setText(
"Mode: " + modeText);
222 m_ui->clusterThemeLabel->setText(
"Theme: " + themeText);
233 switch (newMetrics) {
235 metricsText =
"km/h";
241 m_ui->clusterMetricsLabel->setText(
"Metrics: " + metricsText);
242 m_ui->speedMetricsLabel->setText(metricsText.toUpper());
Definition of the DisplayManager class.
DrivingMode
Enum class for the driving mode.
CarDirection
Enum class for the car direction.
ClusterTheme
Enum class for the cluster theme.
ClusterMetrics
Enum class for the cluster metrics.
void updateTemperature(const QString &temperature)
Updates the temperature on the display.
void updateDrivingMode(DrivingMode newMode)
Updates the driving mode on the display.
void updateClusterTheme(ClusterTheme newTheme)
Updates the cluster theme on the display.
void updateIpAddress(const QString &ipAddress)
Updates the IP address on the display.
void clusterMetricsToggled()
Signal emitted when the cluster metrics are toggled.
void drivingModeToggled()
Signal emitted when the driving mode is toggled.
Ui::CarManager * m_ui
Pointer to the UI object.
void updateSystemTime(const QString ¤tDate, const QString ¤tTime, const QString ¤tDay)
Updates the system time on the display.
void updateBatteryPercentage(float batteryPercentage)
Updates the battery percentage on the display.
void updateCanBusData(float speed, int rpm)
Updates the CAN bus data on the display.
void updateClusterMetrics(ClusterMetrics newMetrics)
Updates the cluster metrics on the display.
void updateEngineData(CarDirection direction, int steeringAngle)
Updates the engine data on the display.
DisplayManager(Ui::CarManager *ui, QObject *parent=nullptr)
Construct a new DisplayManager object.
void updateMileage(double mileage)
Updates the mileage on the display.
void updateWifiStatus(const QString &status, const QString &wifiName)
Updates the WiFi status on the display.