diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 5f4a5f83f1f3eeaed4e9f7ed4945e0785b507e13..0f2f072d7e3b6ed4e636e3bb8e6f4dba9aca994e 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -156,7 +156,8 @@ resources/Kill.svg resources/Shutdown.svg - resources/antenna.svg + resources/Antenna_T.svg + resources/Antenna_RC.svg resources/Gps.svg resources/Megaphone.png resources/Yield.png diff --git a/resources/Antenna_RC.svg b/resources/Antenna_RC.svg new file mode 100644 index 0000000000000000000000000000000000000000..69ee3012389743469a51c90e11a9f5071db19ee0 --- /dev/null +++ b/resources/Antenna_RC.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/resources/Antenna_T.svg b/resources/Antenna_T.svg new file mode 100644 index 0000000000000000000000000000000000000000..eb935bc6ecd2576a74de3deb76779b819b9a341e --- /dev/null +++ b/resources/Antenna_T.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + diff --git a/resources/antenna.svg b/resources/antenna.svg deleted file mode 100644 index 66555490ba924ef2cfd5246eb050036500504871..0000000000000000000000000000000000000000 --- a/resources/antenna.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 1eab9d35414d6a4beacd620629bd48ae8646ffc8..028ac9a61087c46e75e88ad6f778ee17745c59ac 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -923,10 +923,28 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) mavlink_rc_channels_t channels; mavlink_msg_rc_channels_decode(&message, &channels); - // UINT8_MAX indicates this value is unknown - if (channels.rssi != UINT8_MAX) { - emit remoteControlRSSIChanged(channels.rssi/100.0f); - } + /* + * Full RSSI field: 0b 1 111 1111 + * | | | + * | | ^ These four bits encode a total of + * | | 16 RSSI levels. 15 = full, 0 = no signal + * | | + * | ^ These three bits encode a total of 8 + * | digital RC input types. + * | 0: PPM, 1: SBUS, 2: Spektrum, 3: ST24 + * | + * ^ If bit is set, RSSI encodes type + RSSI + */ + + // TODO: Because the code on the firmware side never sets rssi to 0 on loss of connection + // we get a minimum value of 1 (3.5dB). This is what it does to compute it: + // msg.rssi |= (rc.rssi <= 100) ? ((rc.rssi / 7) + 1) : 15; + // Therefore, I'm eliminating bit 0 as well. + int tRssi = (channels.rssi & 0x0E) * 7; + if(tRssi > 100) { + tRssi = 100; + } + emit remoteControlRSSIChanged((uint8_t)tRssi); if (channels.chan1_raw != UINT16_MAX && channels.chancount > 0) emit remoteControlChannelRawChanged(0, channels.chan1_raw); @@ -967,6 +985,8 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) } break; + + // TODO: (gg 20150420) PX4 Firmware does not seem to send this message. Don't know what to do about it. case MAVLINK_MSG_ID_RC_CHANNELS_SCALED: { mavlink_rc_channels_scaled_t channels; @@ -974,7 +994,8 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) const unsigned int portWidth = 8; // XXX magic number - emit remoteControlRSSIChanged(channels.rssi/255.0f); + // TODO: This makes an assumption the RSSI has been normalized to 0-100 + emit remoteControlRSSIChanged(channels.rssi); if (static_cast(channels.chan1_scaled) != UINT16_MAX) emit remoteControlChannelScaledChanged(channels.port * portWidth + 0, channels.chan1_scaled/10000.0f); if (static_cast(channels.chan2_scaled) != UINT16_MAX) diff --git a/src/uas/UASInterface.h b/src/uas/UASInterface.h index a30f6685c5cdd69e867c014d8c27f565bcf4afb4..4d0c34bce0fe5c5e5bcef8f740b9943cda19146c 100644 --- a/src/uas/UASInterface.h +++ b/src/uas/UASInterface.h @@ -570,8 +570,8 @@ signals: void remoteControlChannelRawChanged(int channelId, float raw); /** @brief Value of a remote control channel (scaled)*/ void remoteControlChannelScaledChanged(int channelId, float normalized); - /** @brief Remote control RSSI changed */ - void remoteControlRSSIChanged(float rssi); + /** @brief Remote control RSSI changed (0% - 100%)*/ + void remoteControlRSSIChanged(uint8_t rssi); /** * @brief Localization quality changed diff --git a/src/ui/toolbar/MainToolBar.cc b/src/ui/toolbar/MainToolBar.cc index a18960cb84aa26e354a9bca056c0deff817b5937..25763de2a7936f05a68ce95567a2092264ad10a7 100644 --- a/src/ui/toolbar/MainToolBar.cc +++ b/src/ui/toolbar/MainToolBar.cc @@ -61,8 +61,9 @@ MainToolBar::MainToolBar(QWidget* parent) , _showRSSI(true) , _showBattery(true) , _progressBarValue(0.0f) - , _remoteRSSI(0.0f) - , _telemetryRSSI(0) + , _remoteRSSI(0) + , _telemetryRRSSI(0) + , _telemetryLRSSI(0) , _rollDownMessages(0) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -359,13 +360,19 @@ void MainToolBar::_setActiveUAS(UASInterface* active) emit mavPresentChanged(_mav != NULL); } -void MainToolBar::_telemetryChanged(LinkInterface*, unsigned, unsigned, unsigned rssi, unsigned, unsigned, unsigned, unsigned) +void MainToolBar::_telemetryChanged(LinkInterface*, unsigned, unsigned, unsigned rssi, unsigned remrssi, unsigned, unsigned, unsigned) { // We only care if we haveone single connection if(_connectionCount == 1) { - if((unsigned)_telemetryRSSI != rssi) { - _telemetryRSSI = rssi; - emit telemetryRSSIChanged(_telemetryRSSI); + if((unsigned)_telemetryLRSSI != rssi) { + // According to the Silabs data sheet, the RSSI value is 0.5db per bit + _telemetryLRSSI = rssi >> 1; + emit telemetryLRSSIChanged(_telemetryLRSSI); + } + if((unsigned)_telemetryRRSSI != remrssi) { + // According to the Silabs data sheet, the RSSI value is 0.5db per bit + _telemetryRRSSI = remrssi >> 1; + emit telemetryRRSSIChanged(_telemetryRRSSI); } } } @@ -461,12 +468,16 @@ void MainToolBar::_updateConnection(LinkInterface *disconnectedLink) emit connectedListChanged(_connectedList); } // Update telemetry RSSI display - if(_connectionCount != 1 && _telemetryRSSI > 0) { - _telemetryRSSI = 0; - emit telemetryRSSIChanged(_telemetryRSSI); + if(_connectionCount != 1 && _telemetryRRSSI > 0) { + _telemetryRRSSI = 0; + emit telemetryRRSSIChanged(_telemetryRRSSI); + } + if(_connectionCount != 1 && _telemetryLRSSI > 0) { + _telemetryLRSSI = 0; + emit telemetryLRSSIChanged(_telemetryLRSSI); } - if(_connectionCount != 1 && _remoteRSSI > 0.0f) { - _remoteRSSI = 0.0f; + if(_connectionCount != 1 && _remoteRSSI > 0) { + _remoteRSSI = 0; emit remoteRSSIChanged(_remoteRSSI); } } diff --git a/src/ui/toolbar/MainToolBar.h b/src/ui/toolbar/MainToolBar.h index 240e9778808dab481b3ded40ccfd3c7e00cd7362..23e19b3ceca8749c5c52cb08053e7a0d4b471362 100644 --- a/src/ui/toolbar/MainToolBar.h +++ b/src/ui/toolbar/MainToolBar.h @@ -99,12 +99,14 @@ public: Q_PROPERTY(bool showBattery MEMBER _showBattery NOTIFY showBatteryChanged) Q_PROPERTY(bool showRSSI MEMBER _showRSSI NOTIFY showRSSIChanged) Q_PROPERTY(float progressBarValue MEMBER _progressBarValue NOTIFY progressBarValueChanged) - Q_PROPERTY(float remoteRSSI READ remoteRSSI NOTIFY remoteRSSIChanged) - Q_PROPERTY(int telemetryRSSI READ telemetryRSSI NOTIFY telemetryRSSIChanged) + Q_PROPERTY(int remoteRSSI READ remoteRSSI NOTIFY remoteRSSIChanged) + Q_PROPERTY(int telemetryRRSSI READ telemetryRRSSI NOTIFY telemetryRRSSIChanged) + Q_PROPERTY(int telemetryLRSSI READ telemetryLRSSI NOTIFY telemetryLRSSIChanged) bool mavPresent () { return _mav != NULL; } - float remoteRSSI () { return _remoteRSSI; } - int telemetryRSSI () { return _telemetryRSSI; } + int remoteRSSI () { return _remoteRSSI; } + int telemetryRRSSI () { return _telemetryRRSSI; } + int telemetryLRSSI () { return _telemetryLRSSI; } void setCurrentView (int currentView); void viewStateChanged (const QString& key, bool value); @@ -134,8 +136,9 @@ signals: void showBatteryChanged (bool value); void showRSSIChanged (bool value); void progressBarValueChanged (float value); - void remoteRSSIChanged (float value); - void telemetryRSSIChanged (int value); + void remoteRSSIChanged (int value); + void telemetryRRSSIChanged (int value); + void telemetryLRSSIChanged (int value); private slots: void _setActiveUAS (UASInterface* active); @@ -194,8 +197,9 @@ private: bool _showRSSI; bool _showBattery; float _progressBarValue; - float _remoteRSSI; - int _telemetryRSSI; + int _remoteRSSI; + int _telemetryRRSSI; + int _telemetryLRSSI; UASMessageViewRollDown* _rollDownMessages; }; diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index c2570ed23025ebd2134234f60391e48d0602c4c0..b8448f6952e92ff0f53475f7354025c1d643b5f0 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -126,9 +126,12 @@ Rectangle { return colorGreen; } - function getRSSIColor() { - // TODO: Figure out RSSI threshold values - return colorBlue; + function getRSSIColor(value) { + if(value < 10) + return colorRed; + if(value < 50) + return colorOrange; + return colorGreen; } function showMavStatus() { @@ -231,7 +234,7 @@ Rectangle { visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages) anchors.verticalCenter: parent.verticalCenter color: getMessageColor() - radius: cellRadius + //radius: cellRadius border.color: "#00000000" border.width: 0 property bool showTriangle: false @@ -305,7 +308,7 @@ Rectangle { visible: showMavStatus() && (mainToolBar.showMav) anchors.verticalCenter: parent.verticalCenter color: colorBlue - radius: cellRadius + //radius: cellRadius border.color: "#00000000" border.width: 0 Image { @@ -324,7 +327,7 @@ Rectangle { visible: showMavStatus() && (mainToolBar.showGPS) anchors.verticalCenter: parent.verticalCenter color: getSatelliteColor(); - radius: cellRadius + //radius: cellRadius border.color: "#00000000" border.width: 0 @@ -353,19 +356,18 @@ Rectangle { } Rectangle { - id: rssi - width: getProportionalDimmension(70) + id: rssiRC + width: getProportionalDimmension(55) height: cellHeight - visible: showMavStatus() && (mainToolBar.showRSSI) && ((mainToolBar.remoteRSSI > 0) || (mainToolBar.telemetryRSSI > 0)) + visible: showMavStatus() && mainToolBar.showRSSI anchors.verticalCenter: parent.verticalCenter - color: getRSSIColor(); - radius: cellRadius + color: getRSSIColor(mainToolBar.remoteRSSI); + //radius: cellRadius border.color: "#00000000" border.width: 0 - Image { - source: "qrc:/res/Antenna"; - height: cellHeight * 0.65 + source: "qrc:/res/AntennaRC"; + width: cellHeight * 0.7 fillMode: Image.PreserveAspectFit anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left @@ -373,26 +375,55 @@ Rectangle { mipmap: true smooth: true } + QGCLabel { + text: mainToolBar.remoteRSSI + anchors.right: parent.right + anchors.rightMargin: getProportionalDimmension(6) + anchors.verticalCenter: parent.verticalCenter + horizontalAlignment: Text.AlignRight + font.pointSize: screenTools.dpiAdjustedPointSize(12); + font.weight: Font.DemiBold + color: colorWhite + } + } + Rectangle { + id: rssiTelemetry + width: getProportionalDimmension(80) + height: cellHeight + visible: showMavStatus() && (mainToolBar.showRSSI) && ((mainToolBar.telemetryRRSSI > 0) && (mainToolBar.telemetryLRSSI > 0)) + anchors.verticalCenter: parent.verticalCenter + color: getRSSIColor(Math.min(mainToolBar.telemetryRRSSI,mainToolBar.telemetryLRSSI)); + //radius: cellRadius + border.color: "#00000000" + border.width: 0 + Image { + source: "qrc:/res/AntennaT"; + width: cellHeight * 0.7 + fillMode: Image.PreserveAspectFit + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: getProportionalDimmension(6) + mipmap: true + smooth: true + } Column { - id: rssiCombined anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: getProportionalDimmension(6) - visible: (mainToolBar.remoteRSSI > 0) && (mainToolBar.telemetryRSSI > 0) Row { anchors.right: parent.right QGCLabel { text: 'R ' - font.pointSize: screenTools.dpiAdjustedPointSize(12); + font.pointSize: screenTools.dpiAdjustedPointSize(11); font.weight: Font.DemiBold color: colorWhite } QGCLabel { - text: (mainToolBar.remoteRSSI * 100).toFixed(0) - width: getProportionalDimmension(20) + text: mainToolBar.telemetryRRSSI + 'dB' + width: getProportionalDimmension(30) horizontalAlignment: Text.AlignRight - font.pointSize: screenTools.dpiAdjustedPointSize(12); + font.pointSize: screenTools.dpiAdjustedPointSize(11); font.weight: Font.DemiBold color: colorWhite } @@ -400,65 +431,21 @@ Rectangle { Row { anchors.right: parent.right QGCLabel { - text: 'T ' - font.pointSize: screenTools.dpiAdjustedPointSize(12); + text: 'L ' + font.pointSize: screenTools.dpiAdjustedPointSize(11); font.weight: Font.DemiBold color: colorWhite } QGCLabel { - text: mainToolBar.telemetryRSSI - width: getProportionalDimmension(20) + text: mainToolBar.telemetryLRSSI + 'dB' + width: getProportionalDimmension(30) horizontalAlignment: Text.AlignRight - font.pointSize: screenTools.dpiAdjustedPointSize(12); + font.pointSize: screenTools.dpiAdjustedPointSize(11); font.weight: Font.DemiBold color: colorWhite } } } - - Row { - id: telemetryRSSISingle - anchors.right: parent.right - anchors.rightMargin: getProportionalDimmension(6) - visible: (mainToolBar.remoteRSSI < 0.01) && (mainToolBar.telemetryRSSI > 0) - anchors.verticalCenter: parent.verticalCenter - QGCLabel { - text: 'T ' - font.pointSize: screenTools.dpiAdjustedPointSize(12); - font.weight: Font.DemiBold - color: colorWhite - } - QGCLabel { - text: mainToolBar.telemetryRSSI - width: getProportionalDimmension(20) - horizontalAlignment: Text.AlignRight - font.pointSize: screenTools.dpiAdjustedPointSize(12); - font.weight: Font.DemiBold - color: colorWhite - } - } - - Row { - id: remoteRSSISingle - anchors.right: parent.right - anchors.rightMargin: getProportionalDimmension(6) - visible: (mainToolBar.remoteRSSI > 0) && (mainToolBar.telemetryRSSI === 0) - anchors.verticalCenter: parent.verticalCenter - QGCLabel { - text: 'R ' - font.pointSize: screenTools.dpiAdjustedPointSize(12); - font.weight: Font.DemiBold - color: colorWhite - } - QGCLabel { - text: (mainToolBar.remoteRSSI * 100).toFixed(0) - width: getProportionalDimmension(20) - horizontalAlignment: Text.AlignRight - font.pointSize: screenTools.dpiAdjustedPointSize(12); - font.weight: Font.DemiBold - color: colorWhite - } - } } Rectangle { @@ -468,7 +455,7 @@ Rectangle { visible: showMavStatus() && (mainToolBar.showBattery) anchors.verticalCenter: parent.verticalCenter color: (mainToolBar.batteryPercent > 40.0 || mainToolBar.batteryPercent < 0.01) ? colorBlue : colorRed - radius: cellRadius + //radius: cellRadius border.color: "#00000000" border.width: 0