From 585cc5b34afc5b88cf3a472259be8f9e9c2bc709 Mon Sep 17 00:00:00 2001 From: LM Date: Mon, 10 Oct 2011 12:40:48 +0200 Subject: [PATCH] Cleaned up debug vects, fixed a few bugs in radio control widget --- src/uas/UAS.cc | 2 ++ src/ui/MAVLinkDecoder.cc | 2 ++ src/ui/QGCRemoteControlView.cc | 27 +++++++++++++++++---------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 8babe6e63..380ff1e3e 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -890,10 +890,12 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) case MAVLINK_MSG_ID_SCALED_PRESSURE: case MAVLINK_MSG_ID_SERVO_OUTPUT_RAW: case MAVLINK_MSG_ID_OPTICAL_FLOW: + break; case MAVLINK_MSG_ID_DEBUG_VECT: { mavlink_debug_vect_t debug; mavlink_msg_debug_vect_decode(&message, &debug); + debug.name[MAVLINK_MSG_DEBUG_VECT_FIELD_NAME_LEN-1] = '\0'; QString name(debug.name); quint64 time = getUnixTime(debug.time_usec); emit valueChanged(uasId, name+".x", "raw", debug.x, time); diff --git a/src/ui/MAVLinkDecoder.cc b/src/ui/MAVLinkDecoder.cc index 18de09e7b..538c3e226 100644 --- a/src/ui/MAVLinkDecoder.cc +++ b/src/ui/MAVLinkDecoder.cc @@ -20,6 +20,8 @@ MAVLinkDecoder::MAVLinkDecoder(MAVLinkProtocol* protocol, QObject *parent) : messageFilter.insert(MAVLINK_MSG_ID_MISSION_ITEM, false); messageFilter.insert(MAVLINK_MSG_ID_MISSION_COUNT, false); messageFilter.insert(MAVLINK_MSG_ID_MISSION_ACK, false); + messageFilter.insert(MAVLINK_MSG_ID_NAMED_VALUE_FLOAT, false); + messageFilter.insert(MAVLINK_MSG_ID_NAMED_VALUE_INT, false); textMessageFilter.insert(MAVLINK_MSG_ID_DEBUG, false); textMessageFilter.insert(MAVLINK_MSG_ID_DEBUG_VECT, false); diff --git a/src/ui/QGCRemoteControlView.cc b/src/ui/QGCRemoteControlView.cc index e16c3cc21..f694ec5f0 100644 --- a/src/ui/QGCRemoteControlView.cc +++ b/src/ui/QGCRemoteControlView.cc @@ -77,21 +77,26 @@ QGCRemoteControlView::~QGCRemoteControlView() void QGCRemoteControlView::setUASId(int id) { - // Clear channel count - raw.clear(); - normalized.clear(); - - if (uasId != -1) { - UASInterface* uas = UASManager::instance()->getUASForId(id); - if (uas) { + if (uasId != -1) + { + UASInterface* uas = UASManager::instance()->getUASForId(uasId); + if (uas) + { // The UAS exists, disconnect any existing connections disconnect(uas, SIGNAL(remoteControlChannelRawChanged(int,float,float)), this, SLOT(setChannel(int,float,float))); disconnect(uas, SIGNAL(remoteControlRSSIChanged(float)), this, SLOT(setRemoteRSSI(float))); disconnect(uas, SIGNAL(radioCalibrationRawReceived(const QPointer&)), calibrationWindow, SLOT(receive(const QPointer&))); disconnect(uas, SIGNAL(remoteControlChannelRawChanged(int,float)), calibrationWindow, SLOT(setChannel(int,float))); + disconnect(uas, SIGNAL(remoteControlChannelScaledChanged(int,float)), this, SLOT(setChannelScaled(int,float))); } } + // Clear channel count + raw.clear(); + raw.resize(0); + normalized.clear(); + normalized.resize(0); + foreach (QLabel* label, rawLabels) { label->deleteLater(); @@ -103,11 +108,14 @@ void QGCRemoteControlView::setUASId(int id) } rawLabels.clear(); + rawLabels.resize(0); progressBars.clear(); + progressBars.resize(0); // Connect the new UAS UASInterface* newUAS = UASManager::instance()->getUASForId(id); - if (newUAS) { + if (newUAS) + { // New UAS exists, connect nameLabel->setText(QString("RC Input of %1").arg(newUAS->getUASName())); calibrationWindow->setUASId(id); @@ -140,11 +148,10 @@ void QGCRemoteControlView::setChannelRaw(int channelId, float raw) void QGCRemoteControlView::setChannelScaled(int channelId, float normalized) { - if (this->raw.size() <= channelId) // using raw vector as size indicator + if (this->normalized.size() <= channelId) // using raw vector as size indicator { // This is a new channel, append it this->normalized.append(normalized); - this->raw.append(0); appendChannelWidget(channelId); updated = true; } -- 2.22.0