diff --git a/src/FlightDisplay/GuidedActionsController.qml b/src/FlightDisplay/GuidedActionsController.qml index c62766d2ffe368592e2d6293d6672f53f2512f7c..b7eb7b1db0456d3da88e7b560d7836665c64433d 100644 --- a/src/FlightDisplay/GuidedActionsController.qml +++ b/src/FlightDisplay/GuidedActionsController.qml @@ -130,7 +130,7 @@ Item { property bool _hideEmergenyStop: !QGroundControl.corePlugin.options.guidedBarShowEmergencyStop property bool _hideOrbit: !QGroundControl.corePlugin.options.guidedBarShowOrbit property bool _vehicleWasFlying: false - property bool _rcRSSIAvailable: _activeVehicle ? _activeVehicle.rcRSSI > 0 && _activeVehicle.rcRSSI < 255 : false + property bool _rcRSSIAvailable: _activeVehicle ? _activeVehicle.rcRSSI > 0 && _activeVehicle.rcRSSI <= 100 : false //Handy code for debugging state problems property bool __debugGuidedStates: false diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index cdd1d130d7bc7282f19d148f0c2e99011b5d0d4a..81984b98c0d4ad8abb08c3e445710d22b837b679 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -110,7 +110,7 @@ Vehicle::Vehicle(LinkInterface* link, , _currentMessageType(MessageNone) , _updateCount(0) , _rcRSSI(255) - , _rcRSSIstore(255) + , _rcRSSIstore(255.) , _autoDisconnect(false) , _flying(false) , _landing(false) @@ -303,7 +303,7 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, , _currentMessageType(MessageNone) , _updateCount(0) , _rcRSSI(255) - , _rcRSSIstore(255) + , _rcRSSIstore(255.) , _autoDisconnect(false) , _flying(false) , _landing(false) @@ -2447,10 +2447,18 @@ void Vehicle::_imageReady(UASInterface*) void Vehicle::_remoteControlRSSIChanged(uint8_t rssi) { - if (_rcRSSIstore < 0 || _rcRSSIstore > 100) { - _rcRSSIstore = rssi; + //-- 0 <= rssi <= 100 - 255 means "invalid/unknown" + if(rssi > 100) { // Anything over 100 doesn't make sense + if(_rcRSSI != 255) { + _rcRSSI = 255; + emit rcRSSIChanged(_rcRSSI); + } + return; + } + //-- Initialize it + if(_rcRSSIstore == 255.) { + _rcRSSIstore = (double)rssi; } - // Low pass to git rid of jitter _rcRSSIstore = (_rcRSSIstore * 0.9f) + ((float)rssi * 0.1); uint8_t filteredRSSI = (uint8_t)ceil(_rcRSSIstore); diff --git a/src/ui/toolbar/RCRSSIIndicator.qml b/src/ui/toolbar/RCRSSIIndicator.qml index baf04b172e0d9009237c76614c81b09aa67ac795..aaed4813b2c0b3ebb2fb7a80ea9cbdcf1cb9bbf9 100644 --- a/src/ui/toolbar/RCRSSIIndicator.qml +++ b/src/ui/toolbar/RCRSSIIndicator.qml @@ -26,7 +26,8 @@ Item { anchors.bottom: parent.bottom visible: _activeVehicle ? _activeVehicle.supportsRadio : true - property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + property bool _rcRSSIAvailable: _activeVehicle ? _activeVehicle.rcRSSI > 0 && _activeVehicle.rcRSSI <= 100 : false Component { id: rcRSSIInfo @@ -54,7 +55,7 @@ Item { GridLayout { id: rcrssiGrid - visible: _activeVehicle && _activeVehicle.rcRSSI != 255 + visible: _rcRSSIAvailable anchors.margins: ScreenTools.defaultFontPixelHeight columnSpacing: ScreenTools.defaultFontPixelWidth columns: 2 @@ -86,14 +87,14 @@ Item { sourceSize.height: height source: "/qmlimages/RC.svg" fillMode: Image.PreserveAspectFit - opacity: _activeVehicle ? (((_activeVehicle.rcRSSI < 0) || (_activeVehicle.rcRSSI > 100)) ? 0.5 : 1) : 0.5 + opacity: _rcRSSIAvailable ? 1 : 0.5 color: qgcPal.buttonText } SignalStrength { anchors.verticalCenter: parent.verticalCenter size: parent.height * 0.5 - percent: _activeVehicle ? ((_activeVehicle.rcRSSI > 100) ? 0 : _activeVehicle.rcRSSI) : 0 + percent: _rcRSSIAvailable ? _activeVehicle.rcRSSI : 0 } }