diff --git a/src/flabel.cpp b/src/flabel.cpp index b896028..4729621 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -12,6 +12,10 @@ FLabel::FLabel(QWidget *parent) : QLabel(parent){ } + + + + /** * @brief Handles the visual representation of a QString value * @param newValue The new value, that will be displayed @@ -97,3 +101,5 @@ void FLabel::setVisual(QTime newValue, QTime oldValue=QTime(0,0,0,0)){ this->setText(newValue.toString("mm:ss.zzz")); } + + diff --git a/src/main.cpp b/src/main.cpp index ef12fce..b0b5963 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,7 +8,7 @@ #ifdef __LART_T14__ #include "src/tfortwindow.h" #endif - +#include "pilot.h" #ifdef __LART_T24__ #ifdef __LART_DEBUG__ #include "voidsterdebugwindow.h" @@ -40,20 +40,23 @@ int main(int argc, char *argv[]){ #ifdef __LART_T24__ #ifdef __LART_DEBUG__ - - VoidsterdebugWindow debugWindow; - debugWindow.show(); + // VoidsterdebugWindow debugWindow; + // debugWindow.show(); + + PilotWindow pl; + pl.show(); //VoidsterdebugWindow2 debugWindow2; //debugWindow2.show(); - MainWindow w; - w.show(); + //MainWindow w; + //w.show(); #else MainWindow w; w.show(); + #endif #endif #ifdef __LART_T14__ diff --git a/src/pilot.cpp b/src/pilot.cpp index 5861cba..c368d21 100644 --- a/src/pilot.cpp +++ b/src/pilot.cpp @@ -9,15 +9,17 @@ **/ #include "pilot.h" -#include "./ui_voidsterdebugwindow.h" +#include "./ui_pilot.h" #include "./store.h" #include #include #include "flabel.h" #include "QLCDNumber" +#include "qprogressbar.h" static store* store_ref; +#include "voidsterdebugwindow.h" /** @@ -26,11 +28,14 @@ static store* store_ref; **/ PilotWindow::PilotWindow(QWidget *parent, QString serialDev) : QMainWindow(parent) - , ui(new Ui::~PilotWindow){ + , ui(new Ui::pilot) // This correctly matches the class name in the .ui file +{ + ui->setupUi(this); + setWindowTitle("Pilotamos"); + store_ref = new store(serialDev); - ui->setupUi(this); //store_ref->setParent(this); //store_ref->requestSlotAttachment(); @@ -41,10 +46,55 @@ PilotWindow::PilotWindow(QWidget *parent, QString serialDev) **/ - #ifdef __LART_T24__ - QLCDNumber* SPEED_DISPLAY = this->findChild("SPEED_DISPLAY"); - connect(store_ref, &store::rpmChanged, SPEED_DISPLAY, (void (QLCDNumber::*)(short, short))&QLCDNumber::setAveragedVisualChangeSec); + QLCDNumber* SPEED_DISPLAY = this->findChild("SPEED_DISPLAY"); + QLCDNumber* INVERTER_TEMP_DISPLAY = this->findChild("INVERTER_TEMP_DISPLAY"); + QLCDNumber* MOTOR_TEMP_DISPLAY = this->findChild("MOTOR_TEMP_DISPLAY"); + QLCDNumber* ACUMULATOR_TEMP_DISPLAY = this->findChild("ACUMULATOR_TEMP_DISPLAY"); + + + QProgressBar* HV_SOC_BAR = this->findChild("HV_SOC_BAR"); + QProgressBar* LV_SOC_BAR = this->findChild("LV_SOC_BAR"); + QProgressBar* POWER_SOC_BAR = this->findChild("POWER_SOC_BAR"); + QProgressBar* CONSUMED_POWER_BAR = this->findChild("CONSUMED_POWER_BAR"); + + + + + + connect(store_ref, &store::vehicleSpeedChanged, [SPEED_DISPLAY](int m_vehicleVelocity) { + SPEED_DISPLAY->display(m_vehicleVelocity);}); + + + //connect(store_ref, &store::rpmChanged,SPEED_DISPLAY, (void (QLCDNumber::*)(short, short))&QLCDNumber::show; + connect(store_ref, &store::vehicleSpeedChanged, INVERTER_TEMP_DISPLAY, QOverload::of(&QLCDNumber::display)); + INVERTER_TEMP_DISPLAY->show(); + + connect(store_ref, &store::vehicleSpeedChanged, MOTOR_TEMP_DISPLAY, QOverload::of(&QLCDNumber::display)); + MOTOR_TEMP_DISPLAY->show(); + + connect(store_ref, &store::vehicleSpeedChanged, ACUMULATOR_TEMP_DISPLAY, QOverload::of(&QLCDNumber::display)); + INVERTER_TEMP_DISPLAY->show(); + + + + + + connect(store_ref,&store::socChanged,[HV_SOC_BAR](int soc){ + HV_SOC_BAR->setValue(soc); + }); + + connect(store_ref,&store::socChanged,[LV_SOC_BAR](int soc){ + LV_SOC_BAR->setValue(soc); + }); + + connect(store_ref,&store::socChanged,[POWER_SOC_BAR](int soc){ + POWER_SOC_BAR->setValue(soc); + }); + + connect(store_ref,&store::socChanged,[CONSUMED_POWER_BAR](int soc){ + CONSUMED_POWER_BAR->setValue(soc); + }); } @@ -66,3 +116,5 @@ PilotWindow::~PilotWindow(){ store_ref->~store(); delete ui; } + + diff --git a/src/pilot.h b/src/pilot.h index b698ded..1d3c4ca 100644 --- a/src/pilot.h +++ b/src/pilot.h @@ -8,7 +8,7 @@ QT_BEGIN_NAMESPACE -namespace Ui { class PilotWindow; } +namespace Ui { class pilot; } QT_END_NAMESPACE class PilotWindow : public QMainWindow @@ -19,10 +19,11 @@ class PilotWindow : public QMainWindow PilotWindow(QWidget *parent = nullptr, QString serialDev=nullptr); store* getStore(); ~PilotWindow(); + void switch_screen(int menu); private: - Ui::PilotWindow *ui; + Ui::pilot *ui; }; diff --git a/src/pilot.ui b/src/pilot.ui index 1c6cc27..48f6c36 100644 --- a/src/pilot.ui +++ b/src/pilot.ui @@ -1,7 +1,7 @@ - Form - + pilot + 0 @@ -16,22 +16,46 @@ - 170 - 260 - 211 - 171 + 410 + 110 + 191 + 91 + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 5 + + + QLCDNumber::Flat + - 390 - 290 - 221 - 161 + 600 + 100 + 161 + 141 + + + Ubuntu + 15 + 50 + false + false + + Km/h @@ -39,21 +63,27 @@ - 80 - 20 + 30 + 30 118 23 + + Qt::LeftToRight + 24 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + - 240 - 20 + 190 + 30 118 23 @@ -65,8 +95,8 @@ - 110 - 0 + 60 + 10 67 17 @@ -78,8 +108,8 @@ - 270 - 0 + 220 + 10 67 17 @@ -91,8 +121,8 @@ - 410 - 20 + 360 + 30 118 23 @@ -100,12 +130,15 @@ 10 + + %p KW + - 420 - 0 + 370 + 10 91 17 @@ -114,19 +147,273 @@ MAX POWER - + + + + 120 + 120 + 171 + 71 + + + + QFrame::NoFrame + + + 5 + + + 0 + + + - 40 + 10 130 - 201 - 91 + 191 + 51 + + + 20 + + + + INVERTER + + + Qt::AutoText + + + false + + + + + + 460 + 260 + 181 + 61 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 5 + 0 + + + + 410 + 270 + 151 + 41 + + + + + 20 + + + + MOTOR + + + Qt::AutoText + + + false + + + + + + 120 + 250 + 181 + 61 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 5 + + + 0 + + + + + + 10 + 270 + 271 + 41 + + + + + 20 + + + + ACUMULATOR + + + Qt::AutoText + + + false + + + + + + 310 + 100 + 161 + 141 + + + + + Ubuntu + 15 + 50 + false + false + + + + °C + + + + + + 290 + 220 + 161 + 141 + + + + + Ubuntu + 15 + 50 + false + false + + + + °C + + + + + + 640 + 230 + 161 + 141 + + + + + Ubuntu + 15 + 50 + false + false + + + + °C + + + + + + 410 + 140 + 191 + 51 + + + + + 20 + + + + SPEED + + + Qt::AutoText + + + false + + + + + + 520 + 10 + 141 + 17 + + + + CONSUMED POWER + + + + + + 530 + 30 + 118 + 23 + + + + 10 + + + %p KW + + + + + + 10 + 350 + 91 + 17 + + + + LAPCOUNT : + + diff --git a/src/references/pilot.h b/src/references/pilot.h index 3c742d8..c504c81 100644 --- a/src/references/pilot.h +++ b/src/references/pilot.h @@ -1,4 +1,29 @@ #ifndef PILOT_H #define PILOT_H + + +#include +#include "store.h" + + +QT_BEGIN_NAMESPACE +namespace Ui { class VoidsterdebugWindow; } +QT_END_NAMESPACE + +class VoidsterdebugWindow : public QMainWindow +{ + Q_OBJECT + +public: + VoidsterdebugWindow(QWidget *parent = nullptr, QString serialDev=nullptr); + store* getStore(); + ~VoidsterdebugWindow(); + +private: + + Ui::VoidsterdebugWindow *ui; +}; + + #endif // PILOT_H diff --git a/src/store.cpp b/src/store.cpp index 69a433c..f4c3972 100644 --- a/src/store.cpp +++ b/src/store.cpp @@ -421,6 +421,38 @@ void store::setRpm(int rpm){ this->scribeError(__LART_STORE_SETRPM_ERROR__, store::error_severity::MINOR); } } + + + + +/** +* @brief getter for the menu variable +* @return The menu variable +**/ +int store::getMenu() const{ + return this->m_menu; +} + + + +/** +* @brief setter for the menu variable +* @param menu The new value for the menu variable +**/ +void store::setMenu(int menu){ + if(menu>=0){ + if(menu !=this->m_menu){ + int oldMenu = this->m_menu; + this->m_menu=menu; + emit menuChanged(this->m_menu, oldMenu); + } + }else{ + this->scribeError(__LART_STORE_SETRPM_ERROR__, store::error_severity::MINOR); + } +} + + + /** * @brief getter for the engine temperature variable * @return The engine temperature variable @@ -470,6 +502,7 @@ void store::setVehicleSpeed(int vehicleVelocity){ int oldVehicleVelocity = this->m_vehicleVelocity; this->m_vehicleVelocity=vehicleVelocity; emit vehicleSpeedChanged(this->m_vehicleVelocity, oldVehicleVelocity); + qDebug() << "Emitindo vehicleSpeedChanged com velocidade:" << m_vehicleVelocity; } diff --git a/src/store.h b/src/store.h index 7071d86..2fd0213 100644 --- a/src/store.h +++ b/src/store.h @@ -109,12 +109,14 @@ class store: public QObject{ //getters and setters QSerialPort::BaudRate getBaudRate() const; //getters wire variables - int getRpm() const; + int getRpm() const; + int getMenu() const; int getEngineTemperature() const; float getBatteryVoltage() const; int getVehicleSpeed() const; //setters wire variables void setRpm(int rpm); + void setMenu(int menu); void setEngineTemperature(int engineTemperature); void setBatteryVoltage(float batteryVoltage); void setVehicleSpeed(int vehicleVelocity); @@ -167,7 +169,8 @@ class store: public QObject{ int closeSerial(); signals: - void rpmChanged(int newRpm, int oldRpm); + void rpmChanged(int newRpm, int oldRpm); + void menuChanged(int newMenu, int oldMenu); void engineTemperatureChanged(int newEngineTemperature, int oldEngineTemperature); void batteryVoltageChanged(float newBatteryVoltage, float oldBatteryVoltage); void vehicleSpeedChanged(int newVehicleSpeed, int oldVehicleSpeed); @@ -200,6 +203,7 @@ class store: public QObject{ int m_engineTemperature=0; float m_batteryVoltage=0; int m_vehicleVelocity=0; + int m_menu = 0; #ifdef __LART_T14__ int m_gearShift=0; float m_oilPressure=0;