29 changed files with 866 additions and 109 deletions
@ -0,0 +1,180 @@
@@ -0,0 +1,180 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
|
||||
This file is part of the QGROUNDCONTROL project |
||||
|
||||
QGROUNDCONTROL is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
QGROUNDCONTROL is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Implementation of QGCRemoteControlView |
||||
* @author Lorenz Meier <mail@qgroundcontrol.org> |
||||
*/ |
||||
|
||||
#include <QGridLayout> |
||||
#include <QVBoxLayout> |
||||
#include <QHBoxLayout> |
||||
#include <QPushButton> |
||||
#include <QLabel> |
||||
#include <QProgressBar> |
||||
#include "QGCRemoteControlView.h" |
||||
#include "ui_QGCRemoteControlView.h" |
||||
#include "UASManager.h" |
||||
|
||||
QGCRemoteControlView::QGCRemoteControlView(QWidget *parent) : |
||||
QWidget(parent), |
||||
uasId(-1), |
||||
rssi(0.0f), |
||||
updated(false), |
||||
channelLayout(new QVBoxLayout()), |
||||
ui(new Ui::QGCRemoteControlView) |
||||
{ |
||||
//ui->setupUi(this);
|
||||
QGridLayout* layout = new QGridLayout(this); |
||||
layout->addLayout(channelLayout, 1, 0, 1, 2); |
||||
// Name label
|
||||
nameLabel = new QLabel(this); |
||||
nameLabel->setText("No MAV selected yet.."); |
||||
layout->addWidget(nameLabel, 0, 0, 1, 2); |
||||
// Add spacer left of button
|
||||
layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 2, 0); |
||||
// Set stretch to maximize spacer, not button
|
||||
layout->setColumnStretch(0, 100); |
||||
layout->setColumnStretch(1, 1); |
||||
// Calibrate button
|
||||
QPushButton* calibrateButton = new QPushButton(this); |
||||
calibrateButton->setText(tr("Calibrate")); |
||||
// Connect to calibration slot
|
||||
connect(calibrateButton, SIGNAL(clicked()), this, SLOT(calibrate())); |
||||
// Add button
|
||||
layout->addWidget(calibrateButton, 2, 1); |
||||
setVisible(false); |
||||
|
||||
connect(UASManager::instance(), SIGNAL(activeUASSet(int)), this, SLOT(setUASId(int))); |
||||
} |
||||
|
||||
QGCRemoteControlView::~QGCRemoteControlView() |
||||
{ |
||||
delete ui; |
||||
delete channelLayout; |
||||
} |
||||
|
||||
void QGCRemoteControlView::calibrate() |
||||
{ |
||||
// Run auto-calibration
|
||||
} |
||||
|
||||
void QGCRemoteControlView::setUASId(int id) |
||||
{ |
||||
if (uasId != -1) |
||||
{ |
||||
UASInterface* uas = UASManager::instance()->getUASForId(id); |
||||
if (uas) |
||||
{ |
||||
// The UAS exists, disconnect any existing connections
|
||||
disconnect(uas, SIGNAL(remoteControlChannelChanged(int,float,float)), this, SLOT(setChannel(int,float,float))); |
||||
} |
||||
} |
||||
|
||||
// Connect the new UAS
|
||||
UASInterface* newUAS = UASManager::instance()->getUASForId(id); |
||||
if (newUAS) |
||||
{ |
||||
// New UAS exists, connect
|
||||
nameLabel->setText(QString("RC Input of %1").arg(newUAS->getUASName())); |
||||
connect(newUAS, SIGNAL(remoteControlChannelChanged(int,float,float)), this, SLOT(setChannel(int,float,float))); |
||||
} |
||||
} |
||||
|
||||
void QGCRemoteControlView::setChannel(int channelId, float raw, float normalized) |
||||
{ |
||||
if (this->raw.size() <= channelId) |
||||
{ |
||||
// This is a new channel, append it
|
||||
this->raw.append(raw); |
||||
this->normalized.append(normalized); |
||||
appendChannelWidget(channelId); |
||||
} |
||||
else |
||||
{ |
||||
// This is an existing channel, update it
|
||||
this->raw[channelId] = raw; |
||||
this->normalized[channelId] = normalized; |
||||
} |
||||
updated = true; |
||||
|
||||
// FIXME Will be timer based in the future
|
||||
redraw(); |
||||
} |
||||
|
||||
void QGCRemoteControlView::setRemoteRSSI(float rssiNormalized) |
||||
{ |
||||
rssi = rssiNormalized; |
||||
updated = true; |
||||
} |
||||
|
||||
void QGCRemoteControlView::appendChannelWidget(int channelId) |
||||
{ |
||||
// Create new layout
|
||||
QHBoxLayout* layout = new QHBoxLayout(this); |
||||
// Add content
|
||||
layout->addWidget(new QLabel(QString("Channel %1").arg(channelId + 1), this)); |
||||
QLabel* raw = new QLabel(this); |
||||
// Append raw label
|
||||
rawLabels.append(raw); |
||||
layout->addWidget(raw); |
||||
// Append progress bar
|
||||
QProgressBar* normalized = new QProgressBar(this); |
||||
normalized->setMinimum(0); |
||||
normalized->setMaximum(100); |
||||
progressBars.append(normalized); |
||||
layout->addWidget(normalized); |
||||
channelLayout->addLayout(layout); |
||||
} |
||||
|
||||
void QGCRemoteControlView::redraw() |
||||
{ |
||||
if(isVisible() && updated) |
||||
{ |
||||
// Update raw values
|
||||
for(int i = 0; i < rawLabels.count(); i++) |
||||
{ |
||||
rawLabels.at(i)->setText(QString("%1 us").arg(raw.at(i))); |
||||
} |
||||
|
||||
// Update percent bars
|
||||
for(int i = 0; i < progressBars.count(); i++) |
||||
{ |
||||
progressBars.at(i)->setValue(normalized.at(i)*100.0f); |
||||
} |
||||
updated = false; |
||||
} |
||||
} |
||||
|
||||
void QGCRemoteControlView::changeEvent(QEvent *e) |
||||
{ |
||||
QWidget::changeEvent(e); |
||||
switch (e->type()) { |
||||
case QEvent::LanguageChange: |
||||
ui->retranslateUi(this); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
@ -0,0 +1,76 @@
@@ -0,0 +1,76 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
|
||||
This file is part of the QGROUNDCONTROL project |
||||
|
||||
QGROUNDCONTROL is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
QGROUNDCONTROL is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Declaration of QGCRemoteControlView |
||||
* @author Lorenz Meier <mail@qgroundcontrol.org> |
||||
*/ |
||||
|
||||
#ifndef QGCREMOTECONTROLVIEW_H |
||||
#define QGCREMOTECONTROLVIEW_H |
||||
|
||||
#include <QWidget> |
||||
#include <QVector> |
||||
|
||||
namespace Ui { |
||||
class QGCRemoteControlView; |
||||
} |
||||
|
||||
class QVBoxLayout; |
||||
class QLabel; |
||||
class QProgressBar; |
||||
|
||||
class QGCRemoteControlView : public QWidget { |
||||
Q_OBJECT |
||||
public: |
||||
QGCRemoteControlView(QWidget *parent = 0); |
||||
~QGCRemoteControlView(); |
||||
|
||||
public slots: |
||||
void setUASId(int id); |
||||
void setChannel(int channelId, float raw, float normalized); |
||||
void setRemoteRSSI(float rssiNormalized); |
||||
void calibrate(); |
||||
void redraw(); |
||||
|
||||
protected slots: |
||||
void appendChannelWidget(int channelId); |
||||
|
||||
protected: |
||||
void changeEvent(QEvent *e); |
||||
int uasId; |
||||
float rssi; |
||||
bool updated; |
||||
QVBoxLayout* channelLayout; |
||||
QVector<int> raw; |
||||
QVector<float> normalized; |
||||
QVector<QLabel*> rawLabels; |
||||
QVector<QProgressBar*> progressBars; |
||||
QLabel* nameLabel; |
||||
|
||||
private: |
||||
Ui::QGCRemoteControlView *ui; |
||||
}; |
||||
|
||||
#endif // QGCREMOTECONTROLVIEW_H
|
@ -0,0 +1,279 @@
@@ -0,0 +1,279 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>QGCRemoteControlView</class> |
||||
<widget class="QWidget" name="QGCRemoteControlView"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>400</width> |
||||
<height>300</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Form</string> |
||||
</property> |
||||
<widget class="QPushButton" name="pushButton"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>300</x> |
||||
<y>260</y> |
||||
<width>93</width> |
||||
<height>27</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Calibrate</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>10</x> |
||||
<y>270</y> |
||||
<width>171</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Remote Control detected</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label_2"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>10</x> |
||||
<y>10</y> |
||||
<width>71</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Channel 1</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label_3"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>10</x> |
||||
<y>30</y> |
||||
<width>71</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Channel 2</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label_4"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>10</x> |
||||
<y>50</y> |
||||
<width>71</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Channel 3</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label_5"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>10</x> |
||||
<y>70</y> |
||||
<width>71</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Channel 4</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label_6"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>10</x> |
||||
<y>90</y> |
||||
<width>71</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Channel 5</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label_7"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>10</x> |
||||
<y>110</y> |
||||
<width>71</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Channel 6</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label_8"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>10</x> |
||||
<y>130</y> |
||||
<width>71</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Channel 7</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label_9"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>10</x> |
||||
<y>150</y> |
||||
<width>71</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Channel 8</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label_10"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>10</x> |
||||
<y>170</y> |
||||
<width>62</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>RSSI</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QProgressBar" name="chan1ProgressBar"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>200</x> |
||||
<y>10</y> |
||||
<width>118</width> |
||||
<height>16</height> |
||||
</rect> |
||||
</property> |
||||
<property name="value"> |
||||
<number>24</number> |
||||
</property> |
||||
</widget> |
||||
<widget class="QProgressBar" name="chan2ProgressBar"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>200</x> |
||||
<y>30</y> |
||||
<width>118</width> |
||||
<height>16</height> |
||||
</rect> |
||||
</property> |
||||
<property name="value"> |
||||
<number>24</number> |
||||
</property> |
||||
</widget> |
||||
<widget class="QProgressBar" name="chan3ProgressBar"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>200</x> |
||||
<y>50</y> |
||||
<width>118</width> |
||||
<height>16</height> |
||||
</rect> |
||||
</property> |
||||
<property name="value"> |
||||
<number>24</number> |
||||
</property> |
||||
</widget> |
||||
<widget class="QProgressBar" name="chan4ProgressBar"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>200</x> |
||||
<y>70</y> |
||||
<width>118</width> |
||||
<height>16</height> |
||||
</rect> |
||||
</property> |
||||
<property name="value"> |
||||
<number>24</number> |
||||
</property> |
||||
</widget> |
||||
<widget class="QProgressBar" name="chan5ProgressBar"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>200</x> |
||||
<y>90</y> |
||||
<width>118</width> |
||||
<height>16</height> |
||||
</rect> |
||||
</property> |
||||
<property name="value"> |
||||
<number>24</number> |
||||
</property> |
||||
</widget> |
||||
<widget class="QProgressBar" name="chan6ProgressBar"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>200</x> |
||||
<y>110</y> |
||||
<width>118</width> |
||||
<height>16</height> |
||||
</rect> |
||||
</property> |
||||
<property name="value"> |
||||
<number>24</number> |
||||
</property> |
||||
</widget> |
||||
<widget class="QProgressBar" name="chan7ProgressBar"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>200</x> |
||||
<y>130</y> |
||||
<width>118</width> |
||||
<height>16</height> |
||||
</rect> |
||||
</property> |
||||
<property name="value"> |
||||
<number>24</number> |
||||
</property> |
||||
</widget> |
||||
<widget class="QProgressBar" name="chan8ProgressBar"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>200</x> |
||||
<y>150</y> |
||||
<width>118</width> |
||||
<height>16</height> |
||||
</rect> |
||||
</property> |
||||
<property name="value"> |
||||
<number>24</number> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="label_11"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>90</x> |
||||
<y>10</y> |
||||
<width>41</width> |
||||
<height>17</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text"> |
||||
<string>1120</string> |
||||
</property> |
||||
</widget> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
Loading…
Reference in new issue