diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/include/MainWindow.h b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/include/MainWindow.h index 9e222738453c21dd4990157b9e7abd7fc6d00a38..6c39e0b0dd1d9b19d5c0f6a571699a51aa9713c5 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/include/MainWindow.h +++ b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/include/MainWindow.h @@ -40,6 +40,11 @@ #define STATE_FLYING 3 #define STATE_LAND 4 +// battery states + +#define BATTERY_STATE_NORMAL 0 +#define BATTERY_STATE_LOW 1 + #define PI 3.141592653589 diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.cpp index 5c879f982036bc1b66f1ada2b7394ece84caa85d..76b3e7073c2d81fd73e994c85cd03b1e9fdba921 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.cpp @@ -91,6 +91,7 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) : disableGUI(); highlightSafeControllerTab(); + ui->label_battery->setStyleSheet("QLabel { color : red; }"); } @@ -101,12 +102,12 @@ MainWindow::~MainWindow() void MainWindow::disableGUI() { - ui->groupBox_general->setEnabled(false); + // ui->groupBox_general->setEnabled(false); } void MainWindow::enableGUI() { - ui->groupBox_general->setEnabled(true); + // ui->groupBox_general->setEnabled(true); } void MainWindow::highlightSafeControllerTab() @@ -186,7 +187,22 @@ void MainWindow::flyingStateChangedCallback(const std_msgs::Int32& msg) void MainWindow::batteryStateChangedCallback(const std_msgs::Int32& msg) { - // switch case with unabling buttons motors off, take off, etc... when battery is shit + // switch case with unabling buttons motors off, take off, etc... when battery is low + QString qstr = ""; + switch(msg.data) + { + case BATTERY_STATE_LOW: + qstr.append("Low Battery!"); + ui->groupBox_4->setEnabled(false); + ui->label_battery->setText(qstr); + break; + case BATTERY_STATE_NORMAL: + ui->groupBox_4->setEnabled(true); + ui->label_battery->clear(); + break; + default: + break; + } } diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.ui b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.ui index f26c868b7fca783846797c9267fdefd0143dab39..454375c1b7d7e0da2046955a9a1a87a8ae8a7ffc 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.ui +++ b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>1027</width> - <height>585</height> + <width>1056</width> + <height>670</height> </rect> </property> <property name="sizePolicy"> @@ -1107,6 +1107,19 @@ </property> </widget> </item> + <item> + <widget class="QLabel" name="label_battery"> + <property name="font"> + <font> + <pointsize>9</pointsize> + <italic>true</italic> + </font> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> </layout> </widget> </item> @@ -1214,7 +1227,7 @@ <rect> <x>0</x> <y>0</y> - <width>1027</width> + <width>1056</width> <height>25</height> </rect> </property>