Commit 026bbb41 authored by roangel's avatar roangel
Browse files

added battery threshold, now we disable the buttons in GUI when battery low

parent 3eec11e2
......@@ -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
......
......@@ -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;
}
}
......
......@@ -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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment