1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

Updated servo input level bars. Disable some buttons if no telemetry link with OP/CC.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2908 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2011-02-27 19:20:43 +00:00 committed by pip
parent d9ad0e9a8f
commit 4e89c1f245
4 changed files with 157 additions and 67 deletions

View File

@ -24,8 +24,11 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "configservowidget.h"
#include "uavtalk/telemetrymanager.h"
#include <QDebug>
#include <QStringList>
#include <QtGui/QWidget>
@ -33,14 +36,15 @@
#include <QtGui/QVBoxLayout>
#include <QtGui/QPushButton>
ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
{
m_config = new Ui_SettingsWidget();
m_config->setupUi(this);
// First of all, put all the channel widgets into lists, so that we can
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
// First of all, put all the channel widgets into lists, so that we can
// manipulate those:
// NOTE: for historical reasons, we have objects below called ch0 to ch7, but the convention for OP is Channel 1 to Channel 8.
@ -117,8 +121,6 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
<< m_config->widgetBarCH7;
// Now connect the widget to the ManualControlCommand / Channel UAVObject
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ManualControlCommand")));
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateChannels(UAVObject*)));
@ -225,17 +227,29 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
connect(m_config->saveArmToRAM, SIGNAL(clicked()), this, SLOT(sendRCInputUpdate()));
connect(m_config->getArmCurrent, SIGNAL(clicked()), this, SLOT(requestRCInputUpdate()));
connect(m_config->saveRCOutputToSD, SIGNAL(clicked()), this, SLOT(saveRCOutputObject()));
connect(m_config->saveRCOutputToRAM, SIGNAL(clicked()), this, SLOT(sendRCOutputUpdate()));
connect(m_config->getRCOutputCurrent, SIGNAL(clicked()), this, SLOT(requestRCOutputUpdate()));
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestRCInputUpdate()));
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestRCOutputUpdate()));
firstUpdate = true;
enableControls(false);
// Listen to telemetry connection events
if (pm)
{
TelemetryManager *tm = pm->getObject<TelemetryManager>();
if (tm)
{
connect(tm, SIGNAL(myStart()), this, SLOT(onTelemetryStart()));
connect(tm, SIGNAL(myStop()), this, SLOT(onTelemetryStop()));
connect(tm, SIGNAL(connected()), this, SLOT(onTelemetryConnect()));
connect(tm, SIGNAL(disconnected()), this, SLOT(onTelemetryDisconnect()));
}
}
}
ConfigServoWidget::~ConfigServoWidget()
@ -243,6 +257,46 @@ ConfigServoWidget::~ConfigServoWidget()
// Do nothing
}
// ************************************
void ConfigServoWidget::onTelemetryStart()
{
}
void ConfigServoWidget::onTelemetryStop()
{
}
void ConfigServoWidget::onTelemetryConnect()
{
enableControls(true);
}
void ConfigServoWidget::onTelemetryDisconnect()
{
enableControls(false);
}
// ************************************
void ConfigServoWidget::enableControls(bool enable)
{
m_config->getRCInputCurrent->setEnabled(enable);
m_config->saveRCInputToRAM->setEnabled(enable);
m_config->saveRCInputToSD->setEnabled(enable);
m_config->saveFmsToSD->setEnabled(enable);
m_config->saveFmsToRAM->setEnabled(enable);
m_config->getFmsCurrent->setEnabled(enable);
m_config->saveArmToSD->setEnabled(enable);
m_config->saveArmToRAM->setEnabled(enable);
m_config->getArmCurrent->setEnabled(enable);
m_config->saveRCOutputToSD->setEnabled(enable);
m_config->saveRCOutputToRAM->setEnabled(enable);
m_config->getRCOutputCurrent->setEnabled(enable);
}
/**
Sends the channel value to the UAV to move the servo.

View File

@ -46,6 +46,12 @@ public:
ConfigServoWidget(QWidget *parent = 0);
~ConfigServoWidget();
public slots:
void onTelemetryStart();
void onTelemetryStop();
void onTelemetryConnect();
void onTelemetryDisconnect();
private:
Ui_SettingsWidget *m_config;
@ -72,6 +78,8 @@ private:
bool firstUpdate;
void enableControls(bool enable);
private slots:
void updateChannels(UAVObject* obj);
void requestRCInputUpdate();

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>720</width>
<height>480</height>
<width>617</width>
<height>395</height>
</rect>
</property>
<property name="windowTitle">
@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -26,7 +26,7 @@
<widget class="QLabel" name="ch0Max">
<property name="geometry">
<rect>
<x>20</x>
<x>30</x>
<y>10</y>
<width>31</width>
<height>17</height>
@ -53,7 +53,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch0Cur">
<property name="geometry">
<rect>
<x>20</x>
<x>30</x>
<y>160</y>
<width>31</width>
<height>17</height>
@ -79,7 +79,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch1Min">
<property name="geometry">
<rect>
<x>90</x>
<x>100</x>
<y>130</y>
<width>31</width>
<height>17</height>
@ -106,7 +106,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch6Min">
<property name="geometry">
<rect>
<x>440</x>
<x>450</x>
<y>130</y>
<width>31</width>
<height>17</height>
@ -133,7 +133,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch7Cur">
<property name="geometry">
<rect>
<x>510</x>
<x>520</x>
<y>160</y>
<width>31</width>
<height>17</height>
@ -159,7 +159,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch4Max">
<property name="geometry">
<rect>
<x>300</x>
<x>310</x>
<y>10</y>
<width>31</width>
<height>17</height>
@ -186,7 +186,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch7Min">
<property name="geometry">
<rect>
<x>510</x>
<x>520</x>
<y>130</y>
<width>31</width>
<height>17</height>
@ -213,8 +213,8 @@ p, li { white-space: pre-wrap; }
<widget class="QPushButton" name="getRCInputCurrent">
<property name="geometry">
<rect>
<x>270</x>
<y>310</y>
<x>250</x>
<y>240</y>
<width>93</width>
<height>27</height>
</rect>
@ -229,7 +229,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch2Min">
<property name="geometry">
<rect>
<x>160</x>
<x>170</x>
<y>130</y>
<width>31</width>
<height>17</height>
@ -256,7 +256,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch6Max">
<property name="geometry">
<rect>
<x>440</x>
<x>450</x>
<y>10</y>
<width>31</width>
<height>17</height>
@ -283,7 +283,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch5Max">
<property name="geometry">
<rect>
<x>370</x>
<x>380</x>
<y>10</y>
<width>31</width>
<height>17</height>
@ -310,7 +310,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch3Max">
<property name="geometry">
<rect>
<x>230</x>
<x>240</x>
<y>10</y>
<width>31</width>
<height>17</height>
@ -337,8 +337,8 @@ p, li { white-space: pre-wrap; }
<widget class="QPushButton" name="saveRCInputToSD">
<property name="geometry">
<rect>
<x>490</x>
<y>310</y>
<x>470</x>
<y>240</y>
<width>93</width>
<height>27</height>
</rect>
@ -354,7 +354,7 @@ Applies and Saves all settings to SD</string>
<widget class="QLabel" name="ch4Cur">
<property name="geometry">
<rect>
<x>300</x>
<x>310</x>
<y>160</y>
<width>31</width>
<height>17</height>
@ -380,7 +380,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch4Min">
<property name="geometry">
<rect>
<x>300</x>
<x>310</x>
<y>130</y>
<width>31</width>
<height>17</height>
@ -407,8 +407,8 @@ p, li { white-space: pre-wrap; }
<widget class="QPushButton" name="saveRCInputToRAM">
<property name="geometry">
<rect>
<x>380</x>
<y>310</y>
<x>360</x>
<y>240</y>
<width>93</width>
<height>27</height>
</rect>
@ -426,7 +426,7 @@ Be sure to set the Neutral position on all sliders before sending!</string>
<rect>
<x>10</x>
<y>180</y>
<width>61</width>
<width>68</width>
<height>21</height>
</rect>
</property>
@ -449,7 +449,7 @@ Be sure to set the Neutral position on all sliders before sending!</string>
<widget class="QLabel" name="ch3Min">
<property name="geometry">
<rect>
<x>230</x>
<x>240</x>
<y>130</y>
<width>31</width>
<height>17</height>
@ -476,7 +476,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch7Max">
<property name="geometry">
<rect>
<x>510</x>
<x>520</x>
<y>10</y>
<width>31</width>
<height>17</height>
@ -503,7 +503,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch2Cur">
<property name="geometry">
<rect>
<x>160</x>
<x>170</x>
<y>160</y>
<width>31</width>
<height>17</height>
@ -529,7 +529,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch5Cur">
<property name="geometry">
<rect>
<x>370</x>
<x>380</x>
<y>160</y>
<width>31</width>
<height>17</height>
@ -555,7 +555,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch5Min">
<property name="geometry">
<rect>
<x>370</x>
<x>380</x>
<y>130</y>
<width>31</width>
<height>17</height>
@ -582,7 +582,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch1Cur">
<property name="geometry">
<rect>
<x>90</x>
<x>100</x>
<y>160</y>
<width>31</width>
<height>17</height>
@ -608,7 +608,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch6Cur">
<property name="geometry">
<rect>
<x>440</x>
<x>450</x>
<y>160</y>
<width>31</width>
<height>17</height>
@ -634,7 +634,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch3Cur">
<property name="geometry">
<rect>
<x>230</x>
<x>240</x>
<y>160</y>
<width>31</width>
<height>17</height>
@ -660,7 +660,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch2Max">
<property name="geometry">
<rect>
<x>160</x>
<x>170</x>
<y>10</y>
<width>31</width>
<height>17</height>
@ -687,7 +687,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch1Max">
<property name="geometry">
<rect>
<x>90</x>
<x>100</x>
<y>10</y>
<width>31</width>
<height>17</height>
@ -714,7 +714,7 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="ch0Min">
<property name="geometry">
<rect>
<x>20</x>
<x>30</x>
<y>130</y>
<width>31</width>
<height>17</height>
@ -743,7 +743,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>80</x>
<y>180</y>
<width>61</width>
<width>68</width>
<height>21</height>
</rect>
</property>
@ -759,7 +759,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>150</x>
<y>180</y>
<width>61</width>
<width>68</width>
<height>21</height>
</rect>
</property>
@ -775,7 +775,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>220</x>
<y>180</y>
<width>61</width>
<width>68</width>
<height>21</height>
</rect>
</property>
@ -791,7 +791,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>290</x>
<y>180</y>
<width>61</width>
<width>68</width>
<height>21</height>
</rect>
</property>
@ -807,7 +807,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>360</x>
<y>180</y>
<width>61</width>
<width>68</width>
<height>21</height>
</rect>
</property>
@ -823,7 +823,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>430</x>
<y>180</y>
<width>61</width>
<width>68</width>
<height>21</height>
</rect>
</property>
@ -839,7 +839,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>500</x>
<y>180</y>
<width>61</width>
<width>68</width>
<height>21</height>
</rect>
</property>
@ -854,7 +854,7 @@ p, li { white-space: pre-wrap; }
<property name="geometry">
<rect>
<x>20</x>
<y>250</y>
<y>240</y>
<width>131</width>
<height>22</height>
</rect>
@ -873,12 +873,19 @@ Neutral should be put at the bottom of the slider for the throttle.</string>
<widget class="QLabel" name="RCInputConnected">
<property name="geometry">
<rect>
<x>320</x>
<x>250</x>
<y>210</y>
<width>181</width>
<width>311</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>Indicates whether OpenPilot is getting a signal from the RC receiver.</string>
</property>
@ -907,13 +914,16 @@ Neutral should be put at the bottom of the slider for the throttle.</string>
<rect>
<x>10</x>
<y>210</y>
<width>131</width>
<width>111</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>RC Receiver Type:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_20">
<property name="geometry">
@ -938,7 +948,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>10</x>
<y>30</y>
<width>44</width>
<width>68</width>
<height>100</height>
</rect>
</property>
@ -969,7 +979,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>80</x>
<y>30</y>
<width>44</width>
<width>68</width>
<height>100</height>
</rect>
</property>
@ -1000,7 +1010,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>150</x>
<y>30</y>
<width>44</width>
<width>68</width>
<height>100</height>
</rect>
</property>
@ -1031,7 +1041,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>220</x>
<y>30</y>
<width>44</width>
<width>68</width>
<height>100</height>
</rect>
</property>
@ -1062,7 +1072,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>290</x>
<y>30</y>
<width>44</width>
<width>68</width>
<height>100</height>
</rect>
</property>
@ -1093,7 +1103,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>360</x>
<y>30</y>
<width>44</width>
<width>68</width>
<height>100</height>
</rect>
</property>
@ -1124,7 +1134,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>430</x>
<y>30</y>
<width>44</width>
<width>68</width>
<height>100</height>
</rect>
</property>
@ -1155,7 +1165,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>500</x>
<y>30</y>
<width>44</width>
<width>68</width>
<height>100</height>
</rect>
</property>

View File

@ -91,13 +91,14 @@ void WidgetBar::paintEvent(QPaintEvent * /* event */)
float level = (float)(m_value - m_minimum) / range; // 0 to +1
int length = 0;
QRect rect;
switch (m_orientation)
{
case Qt::Horizontal:
{
int length = (int)((height() - 5) * level + 0.5f);
length = (int)((width() - 5) * level + 0.5f);
rect.setLeft(2);
rect.setTop(2);
rect.setWidth(length);
@ -107,7 +108,7 @@ void WidgetBar::paintEvent(QPaintEvent * /* event */)
case Qt::Vertical:
{
int length = (int)((height() - 5) * level + 0.5f);
length = (int)((height() - 5) * level + 0.5f);
rect.setLeft(2);
rect.setTop(height() - 3 - length);
rect.setWidth(width() - 5);
@ -117,14 +118,31 @@ void WidgetBar::paintEvent(QPaintEvent * /* event */)
}
// background
painter.setPen(QColor(160, 160, 160));
painter.setBrush(QColor(255, 255, 255));
// painter.setPen(QColor(160, 160, 160));
// painter.setBrush(QColor(255, 255, 255));
painter.setPen(QColor(80, 80, 80));
painter.setBrush(QColor(160, 160, 160));
painter.drawRect(QRect(0, 0, width() - 1, height() - 1));
if ((m_maximum - m_minimum) > 0)
{
painter.setPen(QColor(128, 128, 255));
painter.setBrush(QColor(128, 128, 255));
painter.drawRoundRect(rect, 3, 3);
// solid bar
// painter.setPen(QColor(128, 128, 255));
// painter.setBrush(QColor(128, 128, 255));
// painter.drawRoundRect(rect, 3, 3);
// colourful bar
for (int i = 0; i < length; i++)
{
if (!(i & 1))
painter.setPen(QColor(0, 0, 0)); // black
else
// painter.setPen(QColor(0, 255, 0)); // green
painter.setPen(QColor(128, 128, 255)); // blue
if (m_orientation == Qt::Vertical)
painter.drawLine(rect.left(), rect.bottom() + 1 - i, rect.right() + 1, rect.bottom() + 1 - i); // vertical bar
else
painter.drawLine(rect.top(), rect.left() + i, rect.bottom(), rect.left() + i); // horizontal bar
}
}
}